Lecture 2: Collision Detection
26 Aug 2024
§ Collisions
Collisions do not usually occur at time step boundaries, so we must detect whether a collision has occurred, determine the exact time that it happened, and compute its response.
Specifically, this lecture goes over continuous collision detection (CCD) for the basic case of a ball and a plane.
While planes are used as an intuitive example in this discussion, it is actually a specific case of using a surface described by a signed-distance function (SDF).
§ Detection
Detection
Suppose we are given positions and with distances and , respectively, and let the surface be defined as a level-set .
If , then an object travelling from to will collide with the level-set surface.
Detection doesn't tell us when or where a collision happened, just that it did happen.
Typically we use a zero level-set surface (i.e. let ).
§ Determination
Determination
In determining a collision, we want to determine the time and point of contact.
Again, suppose we are given positions and with distances and , respectively, and let the surface be defined as a level-set .
Let denote the fraction of a time step at which the collision occurred,
We can find the velocity and position at the time of contact by integrating with the fractional time step instead of ,
In our case, we've only talked about explicit Euler integration; for other integration techniques we also find and by integrating and over instead of .
Note that it is difficult to compute the exact time and point of contact.
Here, we used a linear interpolation to compute the fractional time step; for small enough time steps, this is a good enough approximation.
§ Response
Response
Given and , we want to find the collision response and based on the material properties of the colliding objects.
Typically collisions are not perfectly elastic, meaning that they lose some energy -- this could be from a myriad of forms, such as the sound of the impact, friction, object deformation, etc.
The most common responses: restitution and friction, have physical models based solely on the tangential and normal components of the velocity, respectively.
Suppose we have determined a collision with velocity and position .
Next, we can get the collision normal by computing the surface normal of the object we are colliding with at the point of collision.
We can imagine a separating plane between the two colliding objects defined by the point of contact and the surface normal.
Normal velocity by doing a vector projection of onto the collision normal
And the tangent velocity by taking the difference between the velocity and its projection onto
§ Resitution
An example of a normal response is restitution; i.e. how bouncy something is.
Restitution
Restitution is a measure of the elasticity of a collision, and its response is computed as
where is the coefficient of restitution.
In this case is a perfectly inelastic collision, and is perfectly elastic.
§ Friction
A common tangential response is friction.
A very simple, and very wrong, model of friction that some people might've learned in high-school is
where is the coefficient of friction.
A not much more complicated model, and the one that I was taught by the best high-school physics teachers, is the Coulomb model.
Coulomb Friction
In the Coulomb model, the force of friction is proportional to the normal force.
Friction can completely stop, but not reverse, motion; hence the .