Sign in to follow this  
ogl5

bouncing rectangle

Recommended Posts

I'm trying to understand computer game physics better, so I'm making a 2d program that features a rectangle bouncing around on the screen and rotating (no gravity now). Unfortunately, the rectangle seems to keep gaining energy, and eventually it goes ridiculously fast. I'm wondering if there is an error in my basic approach. Essentially, the edges of the screen are considered walls, so if a point on the rectangle goes outside an edge, a force and a torque are applied to the rectangle. The magnitude of the force is essentially twice the velocity going towards the edge. This velocity includes the rotational velocity. For instance, if a point is going at a velocity of 1 to the right without rotating, and it hits the right edge, the force it gets is 2 in the opposite direction. If the point is rotating, I try to add w x r (cross product of angular velocity and radius vector). So, for the aforementioned point, I would add the x component of w x r, and the force it gets is (2 * (1 + (x component of w x r))). Anyone see an error in this approach?

Share this post


Link to post
Share on other sites
Can't really see exactly what's going on, but the collision impulse equations are derived from the conservation of momentum principle, and you arrive at a impulse equation that is probably different from your 'intuitive' solution. I can only recommend you have a look at CHris Hecker's tutorials on 2D physics. You will have to consider many things, such as inertia, point of contact, normal of collision, velocity of the point of contact...

Share this post


Link to post
Share on other sites

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