460 likes | 550 Views
Animation CS 551 / 651. Rigid-body Simulation Mirtich Paper. Mirtich, 2000. Assignment 1 Rigid-body Simulator. Email sent to class on Saturday Due: Monday, Sept 29 th at 5:00 p.m. Wednesday’s Class. I’ll be out of town Hopefully not trapped on a runway someplace
E N D
AnimationCS 551 / 651 Rigid-body SimulationMirtich Paper Mirtich, 2000
Assignment 1Rigid-body Simulator • Email sent to class on Saturday • Due: Monday, Sept 29th at 5:00 p.m.
Wednesday’s Class • I’ll be out of town • Hopefully not trapped on a runway someplace • Julian will be the projectionist • “Extras” from computer graphics DVDs
Rotation in 3-D • Looks similar to 2-D Case • Specify arbitrray rotation as three angles • One per coordinate axis • Called an Euler Angle • Common representation • But order of rotations matters
Rotation Matrices • Orthonormal matrix: • orthogonal (columns/rows linearly independent) • normalized (columns/rows length of 1) • The inverse of an orthogonal matrix is just its transpose:
Rotation Matrix • 9 DOFs must reduce to 3 • Rows must be unit length (-3 DOFs) • Rows must be orthogonal (-3 DOFs) • Drifting matrices is very bad • Numerical errors results when trying to gradually rotate matrix by adding derivatives • Resulting matrix may scale / shear • Gram-Schmidt algorithm will re-orthogonalize your matrix • Difficult to interpolate between matrices
Angular Velocity Vector • In 2D we just had w, a scalar • In 3D we need a vector, call it w
Calculating change in r • Computing change in r requires cross product • Cool matrix math does the same • Rotationmatrix
Kinematics for point on moving body Centripetal acceleration term!
3D Dynamics • Very similar to 2D • Angular momentum becomes a vector: r x p • r = vector from origin to point • p = linear momentum at point • It measures the amount of momentum that is perpendicular to r
Total angular momentum linear momentum substitute
Inertia Tensor • Use the tilde operator
Pieces come together • Linear terms are identical to their 2-D analogs • Angular terms follow same pattern • Orient the default inertial matrix to align with current orientation • Compute angular velocity by multiplying angular momentum by inertial matrix • Use angular velocity to compute change in orientation
Timewarp Rigid Body Simulation • Presented at SIGGRAPH 2000 • Brian Mirtich • MERL, A Mitsubishi Electric Research Lab (Cambridge, MA)
Big Idea • Simulations are slow • What part is so slow??? • Simulations are discontinuous • What’s the source of discontinuities? • But not discontinuities are unpredictable and only affect parts of simulation
General rigid body simulator • Nontrivial geometries • All pairs can potentially collide • Second-order physics equations of motion • Could be deployed on multiprocessor (simulation farm)
Discontinuities • When do they occur? • When the state or equations of motion change • Collisions • New contacts • Changing from rolling to sliding dynamics • Particle simulation example • Computing state of particle arbitrary time in the future is easy … f(t)
Discontinuities • What trouble do they cause? • Integrator must be stopped and restarted with new state, forces, or equations • Main control loop constantly checking for discontinuities so appropriate handling takes place • Two common methods • Retroactive detection and conservative advancement
Retroactive Detection • Catch discontinuities after the happen • Detect when two objects go through one another • Use root finding to detect exact time of impact • Roll back the clock to time of impact • All objects or just some? • Continue simulation only up to impact
Retroactive Detection • What’s bad about this algorithm? • You’re repeating work • Simulate, back up, simulate again • Additional collisions may be encountered during subsequent smaller simulation timesteps (and others won’t take place after all) • Synchronization requires repeated simulation of all objects if they are involved in collision or not • Doesn’t scale well in number of discontinuities
Conservative Advancement • Don’t simulate past discontinuities • Heuristics predict future discontinuities and impending events are stored in a priority queue • Upon approaching time of event in priority queue, take small steps
Conservative Advancement • What’s bad about this method? • Conservative, but slow as number of discontinuities increases • All simulated objects move forward at small timestep • Difficult to compute tight bounds on discontinuities
Timewarp Algorithm • Derived from a 1985 paper by David Jefferson • Be optimistic • Each object simulates as quickly as possible • Be responsive • If an object is informed of an event in the past, it must reset its state to that previous time
Timewarp • Multiple processes • Each models part of the system • Each has its own “time” called Local Virtual Time (LVT) • Process clocks are not synchronized
Timewarp • Message Passing • When a process experiences an event • message is sent to all processes with timestamp = LVT of sending process • When a process receives a message • If (message time > recipient’s LVT) • Message is placed on time-based queue • Process will advance clock to next event on queue • What if (message time < recipient’s LVT)?
Rollback • Occurs when a recipient has simulated “past” the time at which another process has generated an event • Go back in time (how?) • Put all processed events back on queue • “unsend” events sent to other processes • For each message sent, an antimessage is stored on a queue that can be easily flushed
Rollback • Overhead • Keeping track of previous states • Keeping track of processed events • Keeping track of submitted events • Global Virtual Time (GVT) • The minimum of all LVTs • All states before GVT can be purged • Monotonically increasing
Timewarp for rigid body sim • Every simulated body is a process • The state = position & velocity • Global event queue stores all bodies’ events • Event = timestamp and list of affected bodies • Main loop • Pull front item from event queue • Simulate affected bodies to that time • This can be put on a uniprocessor
Types of events • Collision Check • Between pairs of bodies • Group Check • Collision check for contacting bodies • Splitting groups of bodies when no longer contacting • Redraw • At every new rendered frame, copy positions to buffer • Callback • User-defined functions to be executed
Collisions • Safe-time • Each body keeps track of the last time it was known not to be in collision with other bodies • This helps limit how far a body must roll back upon detection of a collision • Safe-time is included in collision/group check events • Upon collision checking, safe-time is updated
Collisions (A collides with B) • Vertical connections join post-collision states • Gray states are new states after A-B collision check event
Multibodies • Jointed (articulated) bodies like a human • All bodies must be treated in unison • Easily integrated into their system
Contact Groups • Bodies in persistent contact • Simulated as a unit • Membership of group is dynamic • Complicated state keeping so, upon rollback, a body can be detached from its group and simulated
Collision checks • Active Pairs • The set of all bodies that must be checked for potential collisions • We want to keep this set small
Active Pairs • Looking for collisions • Each body has an axis-aligned bounding box • For each timestep between GVT and LVT • Record location of bounding box • Compute bounding box (swept volume) of all bounding boxes over time • Using six heaps for max/min {x, y, z} • GVT increment causes volume to shrink
Looking for collisions • If swept volumes do not intersect • Collision free between [GVT, tmin (A, B)] • Depending on LVT of A and B • A and B not an active pair
Looking for collisions • If newest timestep for B causes overlapping swept volume with A • Collision check at time tmin (A, B) • B, before integration (last known free time) • Rollback will resolve collisions
Results • Applications • Atoms: 200 spheres and 100 water molecules in divided box • Cars: 4 multibody vehicles and 400 pendula • Robots: 20 eight-link manipulators throwing blocks • Avalanche: 300 rocks tumbling down mountainside
Results • Note average integration step vs. time between discontinuities
Results • Atoms for 2 seconds • Average integration step
Results • Atoms for 2 seconds • Total simulation time
Euler Angles • (qx, qy, qz) = RzRyRx • Rotate qx degrees about x-axis • Rotate qy degrees about y-axis • Rotate qz degrees about z-axis • Axis order is not defined • (y, z, x), (x, z, y), (z, y, x)… are all legal • Pick one
Euler Angles • Rotations not uniquely defined • ex: (z, x, y) = (90, 45, 45) = (45, 0, -45)takes positive x-axis to (1, 1, 1) • cartesian coordinates are independent of one another, but Euler angles are not • Gimbal Lock • Term derived from mechanical problem that arises in gimbal mechanism that supports a compass or a gyro
Gimbal Lock • Occurs when two axes are aligned • Second and third rotations have effect of transforming earlier rotations • ex: Rot x, Rot y, Rot z • If Rot y = 90 degrees, Rot z == -Rot x