In the Box2D source code I found this formula in the contact solver code: (I changed it to fit my own engine)
sqr(x) is a macro for ((x)*(x)).
But here (3rd article) I found this formula:
What is the difference between these formulas? I have tested both and I don't see any difference.
Code:
rn1 = contacts[ci].xx1*contacts[ci].nx+contacts[ci].yy1*contacts[ci].ny;
rn2 = contacts[ci].xx2*contacts[ci].nx+contacts[ci].yy2*contacts[ci].ny;
normalmass = 1.0/(
contacts[ci].obj1->mass_inverted+
contacts[ci].obj2->mass_inverted+
(contacts[ci].xx1*contacts[ci].xx1+contacts[ci].yy1*contacts[ci].yy1-sqr(rn1))*contacts[ci].obj1->inertia_inverted+
(contacts[ci].xx2*contacts[ci].xx2+contacts[ci].yy2*contacts[ci].yy2-sqr(rn2))*contacts[ci].obj2->inertia_inverted);
rn2 = contacts[ci].xx2*contacts[ci].nx+contacts[ci].yy2*contacts[ci].ny;
normalmass = 1.0/(
contacts[ci].obj1->mass_inverted+
contacts[ci].obj2->mass_inverted+
(contacts[ci].xx1*contacts[ci].xx1+contacts[ci].yy1*contacts[ci].yy1-sqr(rn1))*contacts[ci].obj1->inertia_inverted+
(contacts[ci].xx2*contacts[ci].xx2+contacts[ci].yy2*contacts[ci].yy2-sqr(rn2))*contacts[ci].obj2->inertia_inverted);
sqr(x) is a macro for ((x)*(x)).
But here (3rd article) I found this formula:
Code:
rxn1 = contacts[ci].yy1*contacts[ci].nx-contacts[ci].xx1*contacts[ci].ny;
rxn2 = contacts[ci].yy2*contacts[ci].nx-contacts[ci].xx2*contacts[ci].ny;
normalmass = 1.0/(
contacts[ci].obj1->mass_inverted+
contacts[ci].obj2->mass_inverted+
sqr(rxn1)*contacts[ci].obj1->inertia_inverted+
sqr(rxn2)*contacts[ci].obj2->inertia_inverted);
rxn2 = contacts[ci].yy2*contacts[ci].nx-contacts[ci].xx2*contacts[ci].ny;
normalmass = 1.0/(
contacts[ci].obj1->mass_inverted+
contacts[ci].obj2->mass_inverted+
sqr(rxn1)*contacts[ci].obj1->inertia_inverted+
sqr(rxn2)*contacts[ci].obj2->inertia_inverted);
What is the difference between these formulas? I have tested both and I don't see any difference.