Search code examples
2dgame-engine

2D Physics Engine collision response rotation of objects


I'm writing my own basic physic engine and now I come to a problem I can't solve. Probably because I don't how to google this problem.

So here is my problem. I hope this image can explain it:

Collision response

I have two objects. The gray one is fixed and don't move and the green one which falls from the top. The green object has three vectors: a force, the acceleration and the velocity. It collides with the fixed gray object.

The real question is how can I get the rotation of the green object when it falls down?


Solution

  • It sounds like you may not have an understanding of the fundamental physics underlying rigid body dynamics. I say that only because you don't mention any of the terminology commonly used when talking about this kind of problem. You'll need to introduce the idea of orientation and angular velocity (the rotational analogs of position and linear velocity) to each dynamic body in the system, and compute all kinds of intermediate quantities like moment of inertia, angular acceleration, and torque.

    Perhaps the best introductory reference for this is Chris Hecker's series of articles for Game Developer Magazine. Assuming you already have non-rotational dynamics (covered in part 1) and collision detection (not covered by this series) solved, you should begin with part 2 and proceed to part 3. They'll give you a solid foundation in the physics and mathematics necessary for implementing rotational collision response.