I have xy co-ordinate like (200,200). I know the angle calculation from the origin the ball throws. How can I find the initial velocity to reach that particular xy co-ordinate when ball is thrown in 2d Environment?
Iam using
x = v0cosq0t;
y = v0sinq0t - (1/2)gt2.
but time is needed. Without time can I do it? any help please?
I’m assuming that you want the ball to hit that specific point (200,200) at the apex of its path. Well, my physics is a bit rusty, but this is what I’ve thrown together:
v_y = square_root(2*g*y),where g is a positive number reflecting the acceleration due to gravity, and y being how high you want to go (200 in this case).
v_x = (x*g) / v_y,where x is how far in the x direction you want to go (200 in this case), g is as before, and Vy is the answer we got in the previous equation.
These equations remove the need for an angle. However, if you’d rather have the velocity + angle, that’s simple:
v0 = square_root(v_x^2 + v_y^2)and
angle = arctan(v_y / v_x).Here is the derivation, if you’re interested:
(1/2)at^2 + v_yt + 0 = y(1/2)at^2 + v_yt - y = 0by quadratic formula,
t = (-v_y +/- square_root(v_y^2 - 2ay)) / awe also have another equation, because at the apex the vertical velocity is 0:
0 = v_y + atsubstitute:
0 = v_y + (-v_y +/- square_root(v_y^2 - 2ay))0 = square_root(v_y^2 - 2ay)0 = v_y^2 - 2ayv_y = square_root(-2ay), orv_y = square_root(2gy)For v_x:
v_x*t = xfrom before, t = v_y / a, so
v_x = (x*g)/v_yI hope that made enough sense.