I'm writing a simple 2D physics engine to help me understand the inner workings of physics engines. I'm following Randy Gaul's tutorial which can be found here and It's been extremely useful and interesting. I'm now on the fourth and final article in the series which covers rotation, but I've spent weeks trying to figure it out and I've hit a brick wall. I've looked all over for other tutorials or explanations, but I have yet to find any that help. No matter how I impliment it, to the point of translating the source code of the tutorial to C# I seem to get completely counter intuative behavour.
The first cause of confusion is that the tutorial states that the collision resolution impulse for two bodies according to the tutorial is the first of the equations below, but the source code accompanying the tutorials appears to be using the second. These two don't appear to be equivalent to me, but I may be wrong.
I'm using the second equation in my code, as implemented in the example source code. I alter the angular velocity as follows:
angularVelocity += ColumnVector2.crossProduct(contactVector, impulse);
Assuming neither of these are the problem, then I must be doing something fundamentally wrong. Can anyone explain, or point me to a good explanation of how to calculate the angular components of my physics engine because I am completely stuck!
Thanks in advance (and sorry for the lengthy question), Adam