static public void Collide(Ball a, Ball b)
{
//How do I calculate the new angles and velocities
///we compute the contact normal first
vec2 normal = (a.position - b.position).normalized()
///then the contact velocity is given by
vec2 cVel = dot( a.speed - b.speed , normal );
///we can use a restituition coefficient e to model a collision
/// e is between 0 and 1 where 1 means an elastic collision and 0 an nonelastic collision
///and we alter the velocity as
a.speed += -0.5 *(1+e) *cVel * normal;
b.speed -= -0.5 *(1+e) * cVel * normal;
///all calculations are done in the world frame
}
Main Topics
Browse All Topics





by: ozoPosted on 2004-12-13 at 17:28:10ID: 12815480
In the center of gravity frame, see if the balls approach close enough to collide.
If so, reflect their velocities across the point of contact