Color Problem Have a black-box function that returns a bright color in 24-bit RGB Want a paler version of the output What to do?
Collision Resolution
Collision resolution Pre-collision positions, velocities known Collision: black box Post-collision positions, velocities known Assumption: we know collision location
Impulse Instantaneous change in momentum j = ∆P Apply within one timestep Effectively, infinite force
Aside: Alternatives Not the only approach to collision resolution "soft body": force proportional to penetration distance (one-way spring force)
One-body collisions Most common case: collision of object with scenery Calculations generalize to two-body – perform calculations in reference frame where one body is at rest, i.e., add one body's velocity to the other before starting Simpler to set up this way
Collision Normal direction in which bodies collide often simple: – line joining centres – normal of collision point on obstacle (often good approximation anyway)
Closing Velocity velocity with which things collide magnitude: dot product of velocity and collision normal If colliding: negative value If separating: positive
Post-Collision Velocity Perfectly elastic collision: v'.n c = -v.n c Perfectly plastic collision: v'.n c = 0 "Coefficient of restitution": linear interpolation between these extremes – v'.n c = -c v.n c
Contact Contact management: avoid rattling effects of tiny collisions Threshold for contact: if closing velocity smaller than threshold, set coefficient of restitution to zero – and perhaps stop simulating this object for now
Impulse Given output velocity, update velocity of body using momentum (impulse): j = -(1+c)(v.n c )n c – Unpacking: v is relative velocity n c is collision normal c is coefficient of restitution
Closing rotational velocity Recall that rotation produces instantaneous linear velocity: v = ω x r so, add this velocity to centre of mass velocity to get velocity of collision point – r = distance from body centre to collision point – if using angular momentum, ω = I -1 L
Impulsive torque Compute impulse as before: have j = ∆P Now, compute impulsive torque ∆L Actually simple: ∆L = r x j – recall τ = r x F, same idea
Wrapping up Apply impulse, impulsive torque to both bodies (one positive, one negative) If one body is fixed: effectively infinite mass, moment of inertia (zero inverse mass) so no resulting velocity