Bouncing of a Ping Pong Ball

Started by
4 comments, last by oliii 16 years, 11 months ago
How would I simulate the bouncing of a ping-pong ball on a table. I need to be able it incorporate lateral velocity as well, not just vertical. Just to simulate the bounce for a ping-pong game.
Advertisement
just use physX. it's super easy.
I know PhysX does that but I would rather not use it. I am trying to use my own physics for the project I'm working on now. All I really need to know is the equation for a bouncing ball.
Just reflect the ball velocity vector over the normal vector of the table.

2N (N dot V) - V
Okay thanks. How do I simulate the speed of acceleration and falling of the ball? Would it be an exponential function of time or something?
very basically,

void Update(float dt){    acceleration = vector(0, -10); // gravity    velocity += acceleration * dt;    position += velocity * dt;    if (position.y - radius < table.y)    {        position.y = table.y + radius;        if (velocity.y < 0.0f)            velocity.y = -velocity.y;    }}

Everything is better with Metal.

This topic is closed to new replies.

Advertisement