Archived

This topic is now archived and is closed to further replies.

nitzan

bouncing ball

Recommended Posts

I have a simple ball that is bouncing up and down. The distance a ball moves in a frame is d = Vo t + 1/2 a t^2 Where Vo is the current velocity. t is the time for the last frame (cant measure this frame unfortunately), and a is the acceleration. My issue is that when the ball collides with the floor, the amount of time it took it to reach the collision could be less then the distance it travels in time t. How do I solve for t given d, Vo and a ? What I mean is, lets say Vo is 4, a is 1, and t is 10. The distance traveled in one frame is d = 4 * 10 + 1/2 * 1 * 10^2 = 40 + 50 = 90. Lets say the collision happened after a distance of 20. What would the correct t be ? Or if its easier, what is the final velocity at the point of collision ? If there isnt a simple equation, is there a simple way to figure all this out ? My collision detection is quiet costly so doing a binary search for the correct t is not an option. Thanks, Nitzan ------------------------- www.geocities.com/nitzanw www.scorchedearth3d.net -------------------------

Share this post


Link to post
Share on other sites
Whops, I think I may have just though of a solution.

If I determine that a collision has occured between my model and another model.

1. detect collision. get exact point of collision.

2. extend line from center of my object to the collision point

3. collide the line with my object and the collision object. 4

4. measure the distance between the two collision points.

5. use binary search to approximate a new t for given distance, velocity and acceleration.

6. calculate collision response based on the new t.

Since I can determine the point of collision, my binary search becomes relatively simple and not as costly as redoing the entire collision calculation.

If anyone has a better idea or finds flaws in my logic let me know.

Nitzan

-------------------------
www.geocities.com/nitzanw
www.scorchedearth3d.net
-------------------------

Share this post


Link to post
Share on other sites
Unless I'm mistaken, you're just solving a quadratic equation:

d = Vo t + 1/2 a t^2
1/2 a t^2 + Vo t - d = 0
-Vo +- sqrt(Vo^2 + 2 a d)
t = ---------------------------
a


I believe that's what you are looking for. Hope it helps

[EDIT] Actually I don't think you can eliminate one of the roots by default, just check which one is positive and take that one.

_____________________________

And the Phoenix shall rise from the ashes...

--Thunder_Hawk -- ¦þ
______________________________


[edited by - Thunder_Hawk on December 23, 2002 7:05:57 PM]

Share this post


Link to post
Share on other sites