The Loop
The basic simulation loop that we'll use in this class is to integrate, check for collisions, determine and resolve them, repeat.
Simulation Loop
- Set initial conditions
 
- t ← 0
 
-  
 
- while t<tmax do
- T ← min(h,Tdisp−t)
 
- a ← m1Ftotal
 
- xnew,vnew ← 
Integrate(x,v,T) 
-  
 
- if DetectCollision(x,v,xnew,vnew) then
- f ← fractional timestep of collision
 
- xc,vc ← 
Integrate(x,v,T) 
- v ← 
CollisionResponse(xc,vc) 
- x ← xc
 
 
- else
- x ← xnew
 
 
-  
 
- t ← t+T
 
-  
 
- if t>Tdisp then
- render and output frame
 
- update Tdisp
 
 
 
 Resting Situations
We want to stop the simulation for an object whenever it comes to rest; this saves on computational resources, avoids numerical issues, and jitter effects.
For an object to come to rest, it must satisfy all of the following
- ∥v∥≤δ1; the speed of the object is less than some small threshold
 
- There exists a surface s such that dist(s,x)≤δ2; i.e. it touches a some surface
 
- Acceleration must be towards the touching surface, a⋅n^<0.
 
- Friction must overcome the tangential acceleration, ∥a∥∥≤μ∥a⊥∥
 
 Numerical Error
Roundoff error grows and propagates as we chain computations.
We won't get into the specifics in this course, but some guidelines are to
- use tolerances; do not check if a=?b but rather ∥a−b∥≤?ε, and to
 
- not assume transitivity; e.g. equality (A=B)∧(B=C)⟹A=C.