Hard Constraints
Simple Collision Resolution
The Closing Velocity
The closing velocity is the total speed at which two objects are moving together. Two objects that are moving apart from one another will have a closing velocity that is less than zero.
$\nu_{c} = \dot{P_{a}} \cdot \hat{(P_{b} - P_{a})} + \dot{P_{b}} \cdot \hat{(P_{a} - P_{b})}$
where $\nu_{c}$ is closing velocity (a scala quantity), $P_{a}$ and $P_{b}$ are the positions of objects a and b and $\hat{P}$ is the unit length vector in the same direction as p. This can be simplified to give
$\nu_{c} = -(\dot{P_{a}} - \dot{P_{b}}) \cdot \hat{(P_{a} - P_{b})}$[1]
Two objects that are closing in on one another will have a negative relative velocity and objects that are separating will have a positive velocity. Mathematically, this is simply a matter of changing the sign of Equation 1 to give
$\nu_{s} = (\dot{P_{a}} - \dot{P_{b}}) \cdot \hat{(P_{a} - P_{b})}$[2]
where $\nu_{s}$ is the separating velocity
The Coefficient of Restitution
The spring model assumes that momentum (the product of mass and velocity) is conserved during the collision as in
$m_{a}\dot{P_{a}} + m_{b}\dot{P_{b}}$ = $m_{a}\dot{P'_{a}} + m_{b}\dot{P'_{b}}$ [3]
where $m_{a}$ is the mass of object a; $\dot{P_{a}}$ is the velocity of object a before the collision , and $\dot{P'_{a}}$ is the velocity after the collision
Equation 3 tells us about the total velocity before and after the collision, but it doesn't tell us about the individual velocities of each object. The individual velocities are linked together using the closing velocity, according to the equation
$\nu_{s}' = - c\nu_{s}$
where $\nu_{s}'$ is the separating velocity after the collision and $\nu_{s}$ is the separating velocity before the collision and c is a constant called the coefficient of restitution.
The coefficient of restitution controls the speed at which the objects will separate after colliding. It depends on the materials that are in collision. If the coefficient is 1, then the objects will bounce apart with the same speed as they were closing. If the coefficient is zero, then the objects will coalesce and travel together
The Collision Direction and the Contact Normal
In cases where we have two particles colliding, then the contact normal will always be given by
$\hat{n} = \hat{(P_{a} - P_{b})}$
By convention, we always give the contact normal from object a's perspective. In this case, from a's perspective the contact is incoming from b, To give the direction of collision from b's point of view, we could simply multiply by -1.
When a particle is colliding with the ground, we only have an object a and no object b. In this case from object as perspective, the contact normal will be
$\hat{n} = \left[ \begin{array}{cc} 0 \\1 \\0 \end{array} \right]$
assuming that the ground is level at the point of collision
With the correct contact normal, Equation 2 becomes
$\nu_{s} = (\dot{P_{a}} - \dot{P_{b}}) \cdot \hat{n}$[2]
Impulses
Recall that applying a force changes the acceleration of an object. If we instantly change the force, the acceleration instantly changes too. We can think of acting on an object to change its velocity in a similar way. Rather than a force, this is called impulse, an instantaneous change in velocity. In the same way as we have
$f = m\ddot{p}$[5]
for forces, we have:
$g = m\dot{p}$[6]
for impulses
We will apply impulses as they arise during the collision resolution process. Each will be applied one at a time using the equation:
$\dot{P}' = \dot{P} + \frac{1}{m}g$
The result of our collision resolution will be an impluse to apply to each object. The impluse will be immediately applied and will instantly changed the velocity of the object
There is one more important result to note about impulses before we move on to using them in collision resolution, and it is best seen using a technique called "dimensional analysis" If we fill in the units for Equation 5, we might put the mass m in kilograms and the velocity in meters per second. so that force is measured in $kg m s^{-2}$. This unit is called a Newton (N). Doing the same with Equation 6 give a unit of $kg ms^{-1}$. We can write this in terms of Newtons in this way:
$kgms^{-1} = kgms^{-2} \times s = Ns$
So, impluses are measured in units of force multiplied by time. Or put another way, 1Ns of impluse is equivalent to 1N of force applied for 1s. We can use this result to convert between forces and impulses: an impluse can always be represented as a force applied for some specific length of time as in
$g = ft$