- #1
KiroNeem
- 1
- 0
I am programming a simple physics simulation and have been following along with some books about the subject. Everything has gone well so far, although at the moment I'm stuck on how to calculate the impulse when two rigid bodies collide. I'll explain the algorithms that I'm using below.
In a frictionless environment I would use this equation to find the impulse that would be applied to both rigid bodies in the collision.
J = -Vr(1+e) / {1/m1 + 1/m2 + n . [(r1 x n)/I1] x r1 + n . [(r2 x n)/I2] x r2}
J - The scalar impulse
Vr - The relative closing velocity of the two bodies
e - The coefficient of restitution
m1 - The mass of rigid body 1
m2 - The mass of rigid body 2
n - The normal of the collision
r1 - The vector from the center of mass of rigid body 1 to the point of collision
r2 - The vector from the center of mass of rigid body 2 to the point of collision
I1 - Inertia tensor for rigid body 1
I2 - Inertia tensor for rigid body 2
I apply the impulse to the objects as such.
v1 = v1 + (Jn)/m1
v2 = v2 + (-Jn)/m2
w1 = w1 + (r1 x Jn)/I1
w2 = w2 + (r2 x -Jn)/I2
v1 - Velocity of rigid body 1
v2 - Velocity of rigid body 2
w1 - Angular velocity of rigid body 1
w2 - Angular velocity of rigid body 2
I have tested this and everything works correctly. The thing that I'm clueless about is when I then decide to throw dynamic/kinetic friction into the equation. So far from the books I'm reading this is what I have been able to figure out.
This is the updated equations to update the rigid bodies.
v1 = v1 + [Jn + (uJ)t]/m1
v2 = v2 + [-Jn + (uJ)t]/m2
w1 = w1 + {r1 x [Jn + (uJ)t]}/I1
w2 = w2 + {r2 x [-Jn + (uJ)t]}/I2
u - The coefficient of friction
t - The tangent normal, this is a unit vector that is perpendicular to the contact normal.
The tangent normal is calculated with this equation.
t = [(n x Vr) x n]
t = t/|t|
I can understand the concept of what his happening in the above equations. I also know that I'm going to need to change the impulse calculation equation because of friction, although I'm not sure how this is done. The books I have only skim over this aspect and I'm a little unsure how to continue. I would imagine it is not difficult, although my searching has not turned up any useful information. So my question is, when two rigid bodies collide in a frictional environment how does one go about calculating the impulse?
Thank for reading. :p
In a frictionless environment I would use this equation to find the impulse that would be applied to both rigid bodies in the collision.
J = -Vr(1+e) / {1/m1 + 1/m2 + n . [(r1 x n)/I1] x r1 + n . [(r2 x n)/I2] x r2}
J - The scalar impulse
Vr - The relative closing velocity of the two bodies
e - The coefficient of restitution
m1 - The mass of rigid body 1
m2 - The mass of rigid body 2
n - The normal of the collision
r1 - The vector from the center of mass of rigid body 1 to the point of collision
r2 - The vector from the center of mass of rigid body 2 to the point of collision
I1 - Inertia tensor for rigid body 1
I2 - Inertia tensor for rigid body 2
I apply the impulse to the objects as such.
v1 = v1 + (Jn)/m1
v2 = v2 + (-Jn)/m2
w1 = w1 + (r1 x Jn)/I1
w2 = w2 + (r2 x -Jn)/I2
v1 - Velocity of rigid body 1
v2 - Velocity of rigid body 2
w1 - Angular velocity of rigid body 1
w2 - Angular velocity of rigid body 2
I have tested this and everything works correctly. The thing that I'm clueless about is when I then decide to throw dynamic/kinetic friction into the equation. So far from the books I'm reading this is what I have been able to figure out.
This is the updated equations to update the rigid bodies.
v1 = v1 + [Jn + (uJ)t]/m1
v2 = v2 + [-Jn + (uJ)t]/m2
w1 = w1 + {r1 x [Jn + (uJ)t]}/I1
w2 = w2 + {r2 x [-Jn + (uJ)t]}/I2
u - The coefficient of friction
t - The tangent normal, this is a unit vector that is perpendicular to the contact normal.
The tangent normal is calculated with this equation.
t = [(n x Vr) x n]
t = t/|t|
I can understand the concept of what his happening in the above equations. I also know that I'm going to need to change the impulse calculation equation because of friction, although I'm not sure how this is done. The books I have only skim over this aspect and I'm a little unsure how to continue. I would imagine it is not difficult, although my searching has not turned up any useful information. So my question is, when two rigid bodies collide in a frictional environment how does one go about calculating the impulse?
Thank for reading. :p