I'm reading a book on building a physics engine. I am currently stuck on nonlinear projection, which is a way to resolve penetration between Rigidbodies, because I don't fully understand the code.
Here is a brief description to the best of my understanding. Nonlinear projection is more believable than linear projection because it adds rotation to linear projection. The book uses this algorithm:
Linear inertia: I fully understand the linear inertia part.
Angular inertia: The book calculates the angular inertia of an object using the following algorithm, which I do not understand, because it gives no explanation and assigns every step to the same variable, angularInertiaWorld.
I'm wondering what's going on in each step of the algorithm. All I can figure out is you start with some values and you end up with a value that's supposed to be the angular inertia of the object.
Linear projection: I fully understand the linear part of the nonlinear projection algorithm.
Angular rotation: The book uses this algorithm to calculate by how much to rotate the object. There are a few more meaningful variable names here, which helps me understand things a little more.
I get all the unit analysis and the impulse stuff the book does to get to a rotation amount. What I don't quite grasp is the usage of the inverse inertia tensor.
Maybe I haven't been fully understanding that. I had originally thought that it was just like the scalar moment of inertia of an object and used in torque = I * alpha, where I is moment of inertia and alpha is angular acceleration. Then, when you apply a torque, you get alpha = torque / I so multiplying torque by the inverse moment of inertia would get you alpha. As a result, I thought that was what the inverse inertia tensor was for.
I would appreciate it if anyone could explain to me how it's being used here.
Finally, thank you for taking the time to read through all that. I would really appreciate any explanations on the angular inertia and/or angular rotation parts.
As to angular inertia:
In this algorithm you compute the change in velocity as a response to the force normal to the surface of the object (contact normal vector is the normal force vector):
step 2: (relative contact position) x (the contact normal [force]) = (moment of inertia)
step 3: (inverse inertia tensor) applied to (moment of inertia) = (angular velocity)
step 4: (angular velocity) x (relative contact position) = (linear velocity)
step 5: (linear velocity) * (the contact normal [force]) = change in velocity in the direction of the applied force