physics - Projectile Distance/Time -
i'm making game , need figure out how long take object fall height.
the object has initial y value (y), initial vertical velocity (vy), gravity constant (gravity), , vertical target distance supposed drop (destination).
i can figure out using loop:
int = 0; while(y < destination) { y += vy; vy += gravity; i++; } return i;
the problem need several hundred objects , have every frame.
is there way figure out using kind of formula? way can speed game while still figuring out problem.
thanks
you can solve explicitly using elementary physics (kinematics).
given initial velocity v, constant acceleration , fixed distance x, time is:
(1/2)at^2 + vt - x = 0
or
at^2 + 2vt - 2x = 0
solve quadratic formula , take positive time.
Comments
Post a Comment