# Bouncing of a Ping Pong Ball

This topic is 3930 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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.

##### Share on other sites
just use physX. it's super easy.

##### Share on other sites
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.

##### Share on other sites
Just reflect the ball velocity vector over the normal vector of the table.

2N (N dot V) - V

##### Share on other sites
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?

##### Share on other sites
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;    }}