I have a very silly question about 2d vector dot product and matrix multiply problem
this is a piece of code from 2d Polygon collision tutorial
the vector and matrix are defined like this
class Vector
{
public:
float x,y;
inline float operator * (const Vector &V) const { return (x*V.x) + (y*V.y); } // dot product
inline Vector operator * (float s) const { return Vector(x*s, y*s); }
...
...
}
here is what i don't understand
// two objects collided at time t. stop them at that time
void CBody::ProcessCollision(CBody& xBody, const Vector& N, float t)
{
//N is direction to push polyA away from polyB,D is relative velocity i think
Vector D = m_xDisplacement - xBody.m_xDisplacement;
//what is the following three line calculating?
float n = D * N;
Vector Dn = N * n;
Vector Dt = D - Dn;
if (n > 0.0f) Dn = Vector(0, 0);
//what does a vector dot product itself stand for?square of its length?
float dt = Dt * Dt;
float CoF = s_fFriction;
if (dt < s_fGlue*s_fGlue) CoF = 1.01f;
D = -(1.0f + s_fRestitution) * Dn - (CoF) * Dt;
float m0 = GetInvMass();
float m1 = xBody.GetInvMass();
float m = m0 + m1;
float r0 = m0 / m;
float r1 = m1 / m;
m_xDisplacement += D * r0;
xBody.m_xDisplacement -= D * r1;
}