Sign in to follow this  

Bouncing of a Ping Pong Ball

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
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 this post


Link to post
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;
}
}

Share this post


Link to post
Share on other sites

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

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this