Ok... After a bit of research and effort, I think I have some code that will calculate the velocities of two pool balls after collision.
Does this look correct?Code:VECTOR a( myPoolBall[collision.GetObject1()].GetVelocity() );
VECTOR b( myPoolBall[collision.GetObject2()].GetVelocity() );
VECTOR n( myPoolBall[collision.GetObject2()].GetPosition(),
myPoolBall[collision.GetObject1()].GetPosition() );
VECTOR t(n);
swap(t[0], t[1]);
t[0] *= -1;
assert( abs( pow(a.Magnitude(), 2) + pow(b.Magnitude(), 2) - pow(a.Magnitude(), 2)
- pow(b.Magnitude(), 2) ) < DBL_MIN);
VECTOR af = proj(b, n) + proj(a, t);
VECTOR bf = proj(a, n) + proj(b, t);
assert( abs( pow(a.Magnitude(), 2) + pow(b.Magnitude(), 2) - pow(af.Magnitude(), 2)
- pow(bf.Magnitude(), 2) ) < DBL_MIN);
VECTOR axf = proj(af, n);
VECTOR bxf = proj(bf, n);
VECTOR ayf = proj(af, t);
VECTOR byf = proj(bf, t);
myPoolBall[collision.GetObject1()].SetVelocity(axf+ayf); // Set New Velocity Vectors
myPoolBall[collision.GetObject2()].SetVelocity(bxf+byf); // To The Colliding Balls
assert( abs( pow(a.Magnitude(), 2) + pow(b.Magnitude(), 2) - pow(VECTOR(axf + ayf).Magnitude(), 2)
- pow(VECTOR(bxf + byf).Magnitude(), 2) ) < DBL_MIN);
