Calculating a position of an object on a parabola.

357 Views Asked by At

I am working on a simple 2D computer game. In the game, I have a 'robot' that throws a ball towards another robot, in the shape of a parabola. Both 'robots' are positioned on the x axis, aka their y co-ordinates are the same.

The program knows the positions of the two robots, and it knows the position of the vertex.

enter image description here

As I said, I need the ball to travel along the parabola. This means (correct me if I'm wrong), that at any given time, I need to be able to calculate the y position of the ball, since I know it's x position. (Or is there a better way to do this?)

If so, how can I calculate the y position of the ball at any given time, as I said while knowing the location of the parabolas' vertex, and knowing it's two points of intersection with the x axis?

Thanks

EDIT: Please try to make your answers as clear as possible, since my math knowledge is very basic. Thanks

1

There are 1 best solutions below

4
On

If the robot separation is $S$ and the vertex is at $H$ height then

$$ y(x) = \frac{4 H}{S} x - \frac{4 H}{S^2} x^2 $$

The horizontal velocity is constant, or $x(t) = v_x t$, so as a function of time the above is

$$ y(t) = H \left( \frac{4 v_x}{S} t - \frac{4 v_x^2}{S^2} t^2 \right) $$

ALso note that the initial verical velocity is $ v_y = \frac{4 H}{S} v_x $ which leads to the expression of what is the horizontal velocity if the thowing speed $v$ is known:

$$ v_x = \frac{S}{\sqrt{16 H^2+S^2}} v $$

(this arises from $v=\sqrt{v_x^2+v_y^2}$)