Advertisement

Bouncing ball trajectory as function of time

Started by June 13, 2013 08:28 AM
6 comments, last by 0r0d 11 years, 8 months ago

Hello. Sorry, google didn't give me an answer. Is it possible at all - just supply time to function and get ball position at that time?

No, not in general, as it depends on geometry and lots of other stuff. Typically you calculate the simulation via small time steps as time goes on (and usually you can't go backwards in time, though in simplified models you might be able to).

On the other hand, if it is a ball with no obstacle in its trajectory being subjected to known forces (in terms of time), then, yes, you can, sort of, though it might not be the best solution for what you are trying to do.

“If I understand the standard right it is legal and safe to do this but the resulting value could be anything.”

Advertisement

I'm guessing OP is assuming no obstacles and flat terrain. And no drag/lift or air resistance (so not a golf sim!)

It's not hard if there is no damping of velocity after a bounce, it's just a sequence of parabolas stitched together. Just wraparound the time parameter using fmodf.

If the velocity is damped after each bounce the parabolas are reduced in height exponentially after each bounce. You can work this out as well but you probably want to draw yourself a diagram and work it out from there - it involves logarithms ;) Time between bounces should form a geometric series, I think (caveat: I'm pretty bad at Physics stuff).

"Most people think, great God will come from the sky, take away everything, and make everybody feel high" - Bob Marley

Yes yes, I need just simple simulation - flat ground, no collisions. Paradigm Shifter, case with parabolas is interesting. But I'm affraid it will look bad. I already tried with damping sin function and it was not good visually.

Don't confuse parabolas with sin :) When the ball is just falling freely, it has a constant acceleration, linearly increasing velocity, and your trajectory will be a parabola.

So, try it, it won't look bad :) Realistic, most probably.

Ok, thanks, you convince me. I'll try )

Advertisement

If you need help with the equations, have a look at the tutorials I posted here: http://www.marekknows.com/downloads.php5?vmk=physics

I show how to animate a ball trajectory being shot out of a cannon.

Hello. Sorry, google didn't give me an answer. Is it possible at all - just supply time to function and get ball position at that time?

Just use the equation of motion under constant acceleration, then add things like air resistance as needed. When the ball hits the ground just reflect the velocity about the plane of the ground and subtract some velocity to account for the inelasticity of the collision.

Given initial values for things like mass, position, velocity, drag coefficient, you should get an equation for the motion that only needs the time variable. You only need to have special code to do something when the ball touches the ground.

This topic is closed to new replies.

Advertisement