I'm trying to implement this method.. i'm not asking for you post your code but if you could help me you'll help the others too!
The angular velocity it's giving me numbers such like: 4.86313e-11 (something like that). I've checked out many many sources... Chris Hecker's website etc. and i didn't see the wrong side of this.
virtual void collide(Sphere& other)
{
Vector d;
float r;
float s;
d = (other.position - this->position); //collision normal (not normalized)
r = (this->radius + other.radius);
s = d.length() - r;
if (s < 0)
{
Vector cp, pt1, pt2, vel1, vel2, n, Vr;
cp = (other.position + this->position) / 2.0f; //collision point (sphere with same radius)
pt1 = cp - this->position; // collision point to center of mass vector
pt2 = cp - other.position;
//velocity at the point of contact
vel1 = this->velocity + this->ang_vel.cross(pt1);
vel2 = other.velocity + other.ang_vel.cross(pt2);
n = (other.position - this->position);
n.normalize();
Vr = (vel2 - vel1); //relative velocity
//collision data
collision.cn = n; // collision normal
collision.cp = cp; //collision point
collision.rv = Vr; //relative velocity
float f1 = -(1.0f + 0.804f) * Vr.dot(collision.cn);
float f2 = (1.0f / this->mass) + (1.0f / other.mass);
float f3 = ( (this->inverseInertia * pt1.cross(collision.cn).cross(pt1) ) +
(other.inverseInertia * pt2.cross(collision.cn).cross(pt2) ) ).dot(collision.cn);
float j = f1 / (f2 + f3);
velocity -= (j / mass) * collision.cn;
other.velocity += (j / other.mass) * collision.cn ;
ang_vel -= j * inverseInertia * pt1.cross(collision.cn);
other.ang_vel += j * other.inverseInertia * pt2.cross(collision.cn);
}
}