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

Popular posts from this blog

php - How can I edit my code to echo the data of child's element where my search term was found in, in XMLReader? -

jQuery Ajax Render Fragments OR Whole Page -

java - Why is BlockingQueue.take() not releasing the thread? -