Simulation and Animation Rigid Body Simulation computer graphics & visualization The next few lectures… Simulation and Animation – SS07 Jens Krüger – Computer Graphics and Visualization Group computer graphics & visualization Comming up… Point Dynamics • no extend • only position Rigid Bodies • extended • positioned & oriented • „a set of points“ Simulation and Animation – SS07 Jens Krüger – Computer Graphics and Visualization Group computer graphics & visualization Dynamic simulation • Movement of point masses, rigid bodies, systems of point masses etc. with respect to – Forces – Body charcteristics (mass, shape) – Derivation of accelerations from properties and physical laws • Dynamic of point masses • Dynamic of rigid bodies Simulation and Animation – SS07 Jens Krüger – Computer Graphics and Visualization Group computer graphics & visualization Dynamic simulation • Newtons Axioms – Without external forces, a body moves uniformly (Inertia) – An external force F applied to a mass m results in an acceleration a: F = ma – Actio = reactio Simulation and Animation – SS07 Jens Krüger – Computer Graphics and Visualization Group computer graphics & visualization Now… Point Dynamics • no extend • no orientation Rigid Bodies • Extended • Oriented • „a set of points“ Simulation and Animation – SS07 Jens Krüger – Computer Graphics and Visualization Group computer graphics & visualization Point dynamics • Dynamic simulation of particles – Position r, mass m, velocity v, acceleration a, but no extend – Forces F act on particles v(t ) r(t ) a(t ) v (t ) F m a(t ) F,a,v,r are 3D vectors!!! v(t dt) v(t) F dt m v(t dt) v(t) F dt m 1 F 2 1 r(t dt) r(t) v(t)dt dt r(t) v(t) v t dt dt 2m 2 Simulation and Animation – SS07 Jens Krüger – Computer Graphics and Visualization Group computer graphics & visualization Point dynamics • Dynamic simulation of particles – Multiple forces may act on particles • Forces are added by vector addition – F is usually a function of time – Mass might change as well • Change of momentum (Impuls) with change of time d (mv) F dt Simulation and Animation – SS07 Jens Krüger – Computer Graphics and Visualization Group computer graphics & visualization Point dynamics • Particles have no internal structure • 3 DOF = degrees of freedom (position only) • Direct kinematic: from a v r • Indirect kinematic: from r and boundary conditions v a Simulation and Animation – SS07 Jens Krüger – Computer Graphics and Visualization Group computer graphics & visualization Point dynamics • Relation between force F and acceleration a a(t ) F(t ) m Point mass • Direct dynamics a(t ) F(t ) m t v (t ) a(t ) v(t ) a(t ) dt v 0 t0 t r(t ) v(t ) r (t ) v(t ) dt r0 t0 Simulation and Animation – SS07 Jens Krüger – Computer Graphics and Visualization Group computer graphics & visualization Point dynamics • Important Forces – Gravity F mg – Hooke's Law F ku – Friction F v Simulation and Animation – SS07 Jens Krüger – Computer Graphics and Visualization Group computer graphics & visualization Point dynamics • Linear momentum (Impuls) – Force F act on center of mass p mv • Force F p • Conservation of momentum p 0 • Example: elastic push Simulation and Animation – SS07 Jens Krüger – Computer Graphics and Visualization Group computer graphics & visualization Point dynamics • Angular momentum (Drall) p L r p r (mr ) • Torque (Drehmoment) TL r Moment of inertia: I = mr2 d (r p) r F dt • Conservation of angular momentum L r F 0 Simulation and Animation – SS07 Jens Krüger – Computer Graphics and Visualization Group computer graphics & visualization Point dynamics • Angular velocity of a point (rate at which the point is rotating): r0 ω r0 ω r0 ω r0|| ω r0 ω magnitude of change r0 • Notation: r0|| a b a *b mit 0 * a az a y az 0 ax ay ax 0 r0 Simulation and Animation – SS07 Jens Krüger – Computer Graphics and Visualization Group computer graphics & visualization Point dynamics • Analog for rotation matrix R - it changes under angular velocity Ryx Rxx Rzx R ω(t ) Rxy ω(t ) Ryy ω(t ) Rzy ω *R R R R xz zz yz • Aggregate movement of a body point – (r0/r(t): position in local/world space coordinate system) r(t ) R(t )r0 rCM r (t ) v CM (t ) ω(t )* R (t )r0 v CM (t ) ω(t )* R (t )r0 rCM rCM v CM (t ) ω(t ) r (t ) rCM (t ) Simulation and Animation – SS07 Jens Krüger – Computer Graphics and Visualization Group computer graphics & visualization Point dynamics • Relation between angular momentum and angular velocity L r p r (mr) mr r mr (ω r) Iω • Inertia tensor I (Trägheitstensor) m(r 2 x 2 ) m yx m zx I m xy m(r 2 y 2 ) m zy 2 2 m xz m yz m(r z ) Example: Skater Symmetric tensor Simulation and Animation – SS07 Jens Krüger – Computer Graphics and Visualization Group computer graphics & visualization Point dynamics Summary Translation Rotation Position r Angle velocity v Angular velocity Momentum p Angular momentum L Force F Torque T Simulation and Animation – SS07 Jens Krüger – Computer Graphics and Visualization Group computer graphics & visualization Next… Point Dynamics • no extend • no orientation Rigid Bodies • Extended • Oriented • „a set of points“ Simulation and Animation – SS07 Jens Krüger – Computer Graphics and Visualization Group computer graphics & visualization Rigid body simulation • Idea – – – – – – Combination of many small particles to a rigid body Bodies that do not deform – they are stiff They do not penetrate They bounce back if they collide Rigid convex polyhedra of constant density 6 DOF instead of 3n DOF (for n particles) • Distinguish between – Movement of center of mass (CM) – Rotation around (CM) Simulation and Animation – SS07 Jens Krüger – Computer Graphics and Visualization Group computer graphics & visualization Rigid body simulation • Mass M M mi small, discrete mass points in continuous case M (r ) dV 3 V Volume integral over entire body Mass density (= specific weight = Mass/Volume) Simulation and Animation – SS07 Jens Krüger – Computer Graphics and Visualization Group computer graphics & visualization Rigid body simulation • CM (center of mass) m r (t ) rCM (t ) i i M in continuous case rCM (t) V (r, t) r(t) dV3 M Simulation and Animation – SS07 Jens Krüger – Computer Graphics and Visualization Group computer graphics & visualization Rigid body simulation • Dynamic simulation of rigid bodies – Motion consist of translational and angular component – Velocity v(t) is rate of change of position r(t) over time • v(t) = r´(t) • v(t) is linear velocity at center of mass – Bodies also have a spin • About an axis (vector) through the center of mass • Magnitude of the vector defines how fast the body is spinning Simulation and Animation – SS07 Jens Krüger – Computer Graphics and Visualization Group computer graphics & visualization Rigid body simulation • Translation and Rotation: r(t ) rCM (t ) R(t )r0 CM local/fixed coordinate system • Rotation R: – 3*3 Matrix – Redundancies – only 3 DOF Simulation and Animation – SS07 Jens Krüger – Computer Graphics and Visualization Group computer graphics & visualization Rigid body simulation Translation Rotation Simulation and Animation – SS07 Jens Krüger – Computer Graphics and Visualization Group computer graphics & visualization Rigid body simulation • Momentum pCM (t) MrCM (t) • Movement of CM vCM (t) rCM (t) pCM (t) MrCM (t) MvCM (t) Fext (t) • Force Fext is sum of all external forces Fext (t ) Fext,i (t ) Fext,i R Fext Simulation and Animation – SS07 Jens Krüger – Computer Graphics and Visualization Group computer graphics & visualization Rigid body simulation • Angular momentum L ri p i ri (mi ri ) mi (ri (ω ri )) Iω • Inertia tensor I mi (ri 2 x i 2 ) I mi x i yi mi x i z i mi yi x i 2 2 m (r y i i i) m i z i x i mi z i x i m i z i y i 2 2 m (r z i i i ) Simulation and Animation – SS07 Jens Krüger – Computer Graphics and Visualization Group computer graphics & visualization Rigid body simulation • Angular momentum L Iω • Inertia tensor I in continuous case I jk (r) (r 2 jk rjrk ) dV3 V x,y,z coordinates Kronecker-symbol Simulation and Animation – SS07 Jens Krüger – Computer Graphics and Visualization Group computer graphics & visualization Rigid body simulation • Translation vs. Rotation Mass Inertia Moment (Trägheitsmoment) I (r)r 2dr m V Velocity v =dr/dt Momentum p = mv Force F = dp/dt Angular Velocity = d/dt Angular Momentum L = I = r x p Torque T = r x F = dL/dt Kinetc Energy Kinetic Energy E = ½ mv2 E = ½ I2 Simulation and Animation – SS07 Jens Krüger – Computer Graphics and Visualization Group computer graphics & visualization Rigid body simulation • Properties of the Inertia tensor – Diagonal elements are moments of inertia with respect to coordinate axes – It is symmetric and real • Has three principal axis (eigenvectors) Iri Ii ri (I diag(Ii , Ii , Ii ))r 0 I diag(Ii , Ii , Ii ) 0 i 1, 2,3 • Eigenvectors are orthogonal: directions of inertia (Hauptträgheitsachsen) • Eigenvalues are real: moments of inertia (Hauptträgheitsmomente) Simulation and Animation – SS07 Jens Krüger – Computer Graphics and Visualization Group computer graphics & visualization Rigid body simulation • Inertia tensor – In this (directions of inertia) coordinate system, I can be diagonalized by RIRT, where R is a rotation matrix: I1 I 0 0 0 I2 0 0 0 I 3 • Inertia moment (scalar) for rotation around axis n (normalized) I n n T I n Iik ni n k Simulation and Animation – SS07 Jens Krüger – Computer Graphics and Visualization Group computer graphics & visualization Rigid body simulation • Torque of single „body element“ Ti (t ) (ri (t ) rCM(t )) Fi • Total torque T(t ) (ri (t ) rCM(t )) Fi • Important: starting point of force • Equations of motion for rotation (Euler equations for fixed coordinate system) L T Simulation and Animation – SS07 Jens Krüger – Computer Graphics and Visualization Group computer graphics & visualization Rigid body simulation • State vector of a rigid body rCM (t ) R(t ) X( t ) pCM (t ) L(t ) Position Orientation (rotation matrix) Impuls Angular momentum • Constants: – Inertia tensor IKS – Mass M Simulation and Animation – SS07 Jens Krüger – Computer Graphics and Visualization Group computer graphics & visualization Rigid body simulation • Derived variables p CM (t) v CM (t) M I(t) R(t)I KSR(t) T I 1 (t) R(t)I KS1 R(t) T ω(t) I(t) 1 L(t) Simulation and Animation – SS07 Jens Krüger – Computer Graphics and Visualization Group computer graphics & visualization Rigid body simulation • Equations of motion rCM (t ) v CM (t ) * (t ) d R(t ) ω(t ) R(t ) X dt p CM (t ) Fext (t ) L(t ) T(t ) Simulation and Animation – SS07 Jens Krüger – Computer Graphics and Visualization Group computer graphics & visualization Rigid body simulation • System of ordinary partial differential equations • Initial boundary problem • Structure x (t ) f (t , x(t )) x(t 0 ) x 0 • In general, numeric solution (Integration) – Explicit solve: Euler, Runge-Kutta – Implicit solver Simulation and Animation – SS07 Jens Krüger – Computer Graphics and Visualization Group computer graphics & visualization Numerical Integration • Initial value problem: x (t ) f ( x, t ) • Simple approach: Euler x(t t ) x(t ) t f ( x, t ) • Derivation: Taylor expansion x(t t ) x(t ) t x (t ) O( t 2 ) • First order scheme • Higher accuracy with smaller step size Simulation and Animation – SS07 Jens Krüger – Computer Graphics and Visualization Group computer graphics & visualization Numerical Integration • Problems of Euler-Scheme • Inaccurate • Unstable • Example: f (x, t) kx x(t) e kt Divergenz für t > 2/k Simulation and Animation – SS07 Jens Krüger – Computer Graphics and Visualization Group computer graphics & visualization Numerical Integration • Midpoint method: 1. Euler-Step x t f ( x, t ) 2. Evaluation of f at midpoint x t fmid f x ,t 2 2 3. Step with value at midpoint x(t t ) t fmid • Second order scheme Simulation and Animation – SS07 Jens Krüger – Computer Graphics and Visualization Group computer graphics & visualization Numerical Integration • Fourth order Runge-Kutta k1 t f ( x, t ) k t k 2 t f x 1 , t 2 2 k t k 3 t f x 2 , t 2 2 k 4 t f x k 3 , t t x(t t ) x k1 k 2 k 3 k 4 O t 5 6 3 3 6 • Adaptive step size control Simulation and Animation – SS07 Jens Krüger – Computer Graphics and Visualization Group computer graphics & visualization Numerical Integration • So far: Explicit techniques • Stable integration by means of implicit integration schemes • Implicit Euler-Step x(t t ) x(t ) t f x(t t ), t t • „rewind“ the explicit Euler-Step • Taylor-expansion around t + t instead of t • Solving the non-linear system of equations for x(t + t) Simulation and Animation – SS07 Jens Krüger – Computer Graphics and Visualization Group computer graphics & visualization Rigid body simulation Simulation and Animation – SS07 Jens Krüger – Computer Graphics and Visualization Group computer graphics & visualization Rigid body simulation • Demo Simulation and Animation – SS07 Jens Krüger – Computer Graphics and Visualization Group computer graphics & visualization Rigid body simulation • Summary Translation Rotation Position rCM Orientation R Velocity vCM Angular velocity Impuls pCM Angular moment L Forces Fext Torque T Mass M Inertia tensor Simulation and Animation – SS07 Jens Krüger – Computer Graphics and Visualization Group computer graphics & visualization