- #1
Akira__tyler
- 4
- 0
Hello. I am writing a 3D physics engine for use in a game engine I'm creating with some friends. This is the first time I've written a 3D physics engine and I am having some difficulty understanding some of the math behind it all.
The section I am currently struggling with is collision resolution. At this point two bodies have collided and their velocities and penetration are being resolved. I am trying to do this with impulses, as guided by a book (Game Physics Engine Development). There are a few sections I do not understand fully.
In one section I try to find the amount of rotational velocity change for every unit of impulse, implemented something like this:
The relativeContact is a vector from the CoM to the point of collision.
The contactNormal is the normal towards the other object from relativeContact.
The tensor is the inverse inertia tensor of the object in world space.
What I THINK the code is doing is finding how much of the relativeContact vector is not in the direction of the contact normal, changing that to angular velocity, and then ending up with the right result. I am missing a lot here and I'm having a lot of difficulty understanding why this does what it does.
Although it would be easiest for me to understand if someone just walked through this code in their own words, any help would be greatly appreciated. Thank you.
The section I am currently struggling with is collision resolution. At this point two bodies have collided and their velocities and penetration are being resolved. I am trying to do this with impulses, as guided by a book (Game Physics Engine Development). There are a few sections I do not understand fully.
In one section I try to find the amount of rotational velocity change for every unit of impulse, implemented something like this:
Code:
Vec3 impulsiveTorque = CrossProduct(relativeContact, contactNormal);
Vec3 angularVelocity = inverseInertiaTensor * impulsiveTorque;
Vec3 rotChangePerUnitImp = CrossProduct(angularVelocity, relativeContact);
The relativeContact is a vector from the CoM to the point of collision.
The contactNormal is the normal towards the other object from relativeContact.
The tensor is the inverse inertia tensor of the object in world space.
What I THINK the code is doing is finding how much of the relativeContact vector is not in the direction of the contact normal, changing that to angular velocity, and then ending up with the right result. I am missing a lot here and I'm having a lot of difficulty understanding why this does what it does.
Although it would be easiest for me to understand if someone just walked through this code in their own words, any help would be greatly appreciated. Thank you.