Good throwing (arc) equation?

Recommended Posts

chillypacman    100
OK this was one of those things which should not have taken as long as it has but hey what the hey. Basically I'm working on an equation which will control the y position of a thrown object as a parabolic function. My first attempt was to use sin however it has the (in this case)unfortunate habit of going in waves. at the point of origin the object must be at (0, 0) at x = distance thrown y should equal 0. Would anyone have any good ideas on an equation for this? I'm working on one right now but it doesn't look too pretty and was wondering if there is a standard equation that could work better.

Share on other sites
ToohrVyk    1595
[Low caffeine warning, take these with a grain of salt]

In a vacuum with constant vertical gravity G, if the initial velocity is (vx,vy) then the position as a function of time is x = 0 + t * vx (there's no slowdown) horizontally and y = 0 + t * vy - 0.5 * G * t * t (downwards acceleration due to gravity).

Solving for y = 0 yields t = 0 and t = 2 * vy / G, and thus a horizontal position of x = vx * vy * 2 / G.

Share on other sites
homer_3    173
Maybe I didn't do it right before, but I didn't like the way the projectile physics equation looked when implemented. It seemed to make triangles instead of arcs.

You could use projectile physics to determine the horizontal length to go, but for the vertical arc, I just used a 2D Bezier curve. http://en.wikipedia.org/wiki/Bezier_curves. A 3D one would probably look even better. But a 2D one does a pretty good job.