Collision Detection and Resolution
Tom Kelliher, CS 320
Mar. 7, 2011
Read Section 4.1, Appendices B and C.
Vectors.
- Continued discussion of
collision.c
: ball placement, collision
detection, collision resolution.
Animation.
placeBalls()
:
- Placement of the first ball along unit circle.
Velocity computation. Target: origin. Scaling velocity.
Translating position to circle of radius 40.
- Avoiding initial collision: Constrained placement of second ball;
or more away.
- Options: Aiming second ball at a point other than the origin.
Computing and normalizing the velocity vector.
Making the second ball stationary, at an arbitrary position.
idle()
:
- Updating ball position -- this is animation.
- Collision detection and response, checks.
- Beginning the next simulation when either ball leaves the
``arena.'' No square roots.
- Post a re-display event to render the new scene.
collision()
- Simply, if the distance between the centers points is less than or
equal to the sum of the radii, we've had a collision.
- No square roots.
- Discrete time step simulation: penetration problems.
collisionResponse()
- Dealing with penetration:
- Binary search over time step interval to find exact point of
impact and take it from there. Computationally expensive.
- Ignore. Approximate collision point and normal. Allow
collision response to push objects apart. May not look realistic, if
collision response doesn't separate objects quickly enough.
- Approximate collision normal and move each object 1/2 of
penetration distance apart along normal. This may look abrupt.
Could cause a cascade of penetrations. Assumes equal forces
involved.
This is what we use.
- We apply equal and opposite impulses along the collision normal to
the two objects to bring them apart.
- Collision normal (), relative velocity vector (),
and the projection back onto the normal ():
- Coefficient of restitution:
, or
- Conservation of momentum:
or:
Similarly for .
- Substituting and solving for :
Thomas P. Kelliher
2011-03-07
Tom Kelliher