Dynamics-Physics based animation Keyframing can be tedious - especially to get realism Using physics to define the animation, Subset of procedural animation Provide the physical rules-laws that govern the motion, let the system evaluate the positions/shape Animator gives up control, gets realistic motion automatically. Can use augmented laws of physics Reusable code, autonomous agents, automatically captures compleity Ice skater, child on a swing
Dynamics-Physics based animation Point masses (particle systems), rigid bodies, deformable bodies, articulated objects One should specify forces, material properties, initial conditions, constraints Solving ordinary differential equations, inclusion of constraints Collision detection and handling
A Canonical Differential Equation 1 f(,t) = f(,t) (t): a moving point. f(,t): 's velocity. 2 SIGGRAPH 97 COURSE NOTES SB2 PHYSICALLY BASED MODELING
Vector Field The differential equation = f (,t) defines a vector field over. SIGGRAPH 97 COURSE NOTES SB3 PHYSICALLY BASED MODELING
Integral Curves Start Here Pick any starting point, and follow the vectors. SIGGRAPH 97 COURSE NOTES SB4 PHYSICALLY BASED MODELING
Initial Value Problems Given the starting point, follow the integral curve. SIGGRAPH 97 COURSE NOTES SB5 PHYSICALLY BASED MODELING
Solving ODE &( t) = f (, t) Given the differential equations and a starting point ( t i ) (known as an initial value problem) find (t) Interest in numerical solutions (discrete time steps (t 0 ), (t 0 +h), (t 0 +2h)) not analytical ones. We need to integrate to find the new position/state t+ h t+ h t '( τ ) dτ = ( t+ h) ( t) = f(, τ) dτ t
Euler method Assumes that the derivative f is constant over the timestep ( t+ h) ( t) + hf( ( t), t) First order approimation given Taylor epansion gives ( t ( t ( t i i i + dt) + dt) + dt) &( t) = f (, t) and t ) = ( t ( t ( t i i i ) ) ) + & ( t i + & ( t i ) ) + f ( ( t dt dt i ), t i ) dt ( i + O( dt 2 )
Euler's Method Simplest numerical solution method Discrete time steps Bigger steps, bigger errors. (t + t) = (t) + t f(,t) SIGGRAPH 97 COURSE NOTES SB6 PHYSICALLY BASED MODELING
Euler method Inaccurate smaller timesteps only slow the problems down Unstable f (, t) = k reasonable if dt <1/ Instability if dt > 2 / k k
Method performance Compleity depends on the number of derivative function calculations per time step. However performance is also related to the number of time steps required to obtain a certain accuracy and stability Sophisticated methods: more evaluations per step but they allow bigger steps
Midpoint Method Second order approimation 2 dt ( ti + dt) = ( ti ) + & ( ti ) dt + & ( ti ) + with f ( dt 2 2 f d &&(t i ) = = f dt f 2 O( dt 2 f ( ) f ( ) f i + = i + ( i ) + O( ) dt dt + f ( )) ( ) ( ) ( ) ( 2 i = f i + f 2 i f i O dt 3 dt && + O dt ) = dt ( f ( + f ( )) f ( )) i + ( i 2 i i 2 ) 3 ) dt ( ti + dt) = ( ti ) + dt ( f ( i + f ( 2 i ))) i = ( t i )
Midpoint Method Requires 2 derivative evaluations per step Geometric Interpretation dt ( ti + dt) = ( ti ) + dt ( f ( i + f ( 2 i Euler result ))) + i i f ( dt 2 i ) dt f ( i + f ( )) 2 i Midpoint result we can use higher orders (e: runge-kutta 4)
Adaptive Timestepping Fied timestep: proceed only as fast as worst section of (t) allows. Allow the timestep to change over the course of the solution e = a b 1 timestep 2 timesteps Scale the timestep based on the error s e e desired = current 1/ errororder See: Numerical recipes in C
ODE solver For(time=t0; time<t1; time+=delta){ derivative=derivative_function(time, ); =ode(derivative, time,, delta); } The user should provide derivative_function. Alternatively, derivative_function is fed to ode.
Particles Particles are objects modeled as point masses Particle systems are collections of particles Particle systems can represent: fire smoke/clouds flow of fluids debris/shrapnel soft bodies flocks/crowds etc.
Particles Particles respond to forces (Newtonian particles) We represent this using differential equations Newton s second law && = f m & v& = = v f m 2 nd order ODE 1 st order ODEs
Particle Systems The state of the system is fully determined by, v. Phase space Particle properties: mass position velocity total forces age, lifespan rendering properties etc.
Newtonian συστήµατα σωµατιδίων Ησυµπεριφορά του συστήµατος προσδιορίζεται από τις χρονοµεταβλητές δυνάµεις που ασκούνται. Εσωτερικές δυνάµεις (σύστηµα ελατηρίων) ή/και εξωτερικές δυνάµεις (βαρύτητα) Καθορίζοντας κατάλληλα τις δυνάµεις πετυχαίνουµε να µοντελοποιήσουµε την επιθυµητή συµπεριφορά.
Particle Systems Separate the data structures and integration Particle System particles time state send data as 6n vectors state/derivatives Solver state derivatives Particle v f m v f m v f m L v f m
Particle Motion (t) v(t) SIGGRAPH 97 COURSE NOTES SD2 PHYSICALLY BASED MODELING
Particle State Y = (t) v(t) (t) v(t) 6 4 7 4 4 8 6 4 7 4 4 8 Y = SIGGRAPH 97 COURSE NOTES SD3 PHYSICALLY BASED MODELING
Particle Dynamics (t) v(t) F(t) SIGGRAPH 97 COURSE NOTES SD4 PHYSICALLY BASED MODELING
State Derivative d dt Y = d dt (t) = v(t) v(t) F(t)/m d dt Y = v(t) F(t)/m 6 4 7 4 4 8 6 4 7 4 4 8 SIGGRAPH 97 COURSE NOTES SD5 PHYSICALLY BASED MODELING
Multiple Particles SIGGRAPH 97 COURSE NOTES SD6 PHYSICALLY BASED MODELING
State Derivative d dt Y = d dt 1 (t) v 1 (t) M n (t) v n (t) = v 1 (t) F 1 (t)/m 1 M v n (t) F n (t)/m n d dt Y =...... 6n elements SIGGRAPH 97 COURSE NOTES SD7 PHYSICALLY BASED MODELING
ODE solution d dt Y(t 0 + t)... Y(t 1 ) d dt Y(t 0) Y(t 0 + t) Y(t 0 ) SIGGRAPH 97 COURSE NOTES SD8 PHYSICALLY BASED MODELING
Y(t 0 ) len t 0 t 1 dydt ODE solver Y(t 1 ) void dydt(double t, double y[], double ydot[]) SIGGRAPH 97 COURSE NOTES SD9 PHYSICALLY BASED MODELING
Y(t) = 1 (t) v 1 (t) n (t) v n (t) dydt d dt Y(t) = v 1 (t) F 1 (t)/ m 1 v n (t) F n (t)/m n SIGGRAPH 97 COURSE NOTES SD10 PHYSICALLY BASED MODELING
v f m v f m v f m Clear Force Accumulators 1 2 Deriv Eval Loop F F F F Invoke apply_force functions v f m v f m v f m 3 Return [v, f/m, ] to solver. SIGGRAPH 97 COURSE NOTES SC17 PHYSICALLY BASED MODELING
Forces Unary forces :forces that only depend on 1 particle. O(n) compleity f drag v Gravity Dampening Wind Fields f mg f = k = drag d f = k v wind v
Forces Binary forces - forces that only depend on 2 particles f a f b ) ( 0 b a b a b a s a l k f = ) ( ) ( b a b a b a b a b a k d v v f b =- f a Springs Generalizes to n-ary forces
υνάµεις από σύστηµα ελατηρίων Χρήση σωµατιδίων για µοντελοποίηση επιφάνειας που µεταβάλλεται µε το χρόνο: ύφασµα στον άνεµο Κάθε σωµατίδιο κόµβος σε πλέγµα Εξωτερικές δυνάµεις (βαρύτητα, άνεµος) υνάµεις µεταξύ σωµατιδίων που τα καθιστούν συνεκτική επιφάνεια
υνάµεις από σύστηµα ελατηρίων Θεώρηση ότι τα σωµατίδια συνδέονται µε ελατήρια. Πολυπλοκότητα O(n) (επίδραση µόνο από γειτονικά σωµατίδια)
Ελκτικές-απωθητικές δυνάµεις Spatial interaction forces Οι δυνάµεις σε σύστηµα ελατηρίων κρατούν τα σωµατίδια στην ίδια τοπολογική διάταξη, Επιδρούν πάντα στο ίδιο ζεύγος. Οι ελκτικές ή απωθητικές δυνάµεις τα φέρνουν κοντά ή τα αποµακρύνουν. Απωθητικές δυνάµεις για να κατανείµουµε σωµατίδια σε επιφάνεια ή να τα αποτρέψουµε να συγκρουστούν Ελκτικές δυνάµεις: µοντέλο ηλιακού
Ελκτικές-απωθητικές δυνάµεις ρουν στην κατεύθυνση d = p -q και είναι αντιστρόφως ανάλογες της απόστασης Απωθητική αντίστροφου τετράγωνου f = k r d d 3 Στη γενική περίπτωση ο υπολογισµός των δυνάµεων είναι O(n 2 ).
Ελκτικές-απωθητικές δυνάµεις Χωρισµός του χώρου σε υποχώρους και υπόθεση ότι δυνάµεις από σωµατίδια σε γειτονικούς υποχώρους αµελητέες. Κόστος για αρχική διαµοίραση των σωµατιδίων και υπολογισµό µετάβασης σωµατιδίων σε άλλο υποχώρο για κάθε
Forces Controlled particles: motion not controlled by forces Fied particles (anchors and pivots) Procedurally controlled particles (e.g. particles moving in a circle) User Interaction forces (for interactive animation) : forces applied to particles by the user f user Usually just use springs
Soft Constraints Forces: provided by the user to specify the desired behavior (e.g. spring forces keep particles together) It is often easier to specify a condition that we want to be true rather than a force to make it true Constraint (or behavior) functions: specify a condition that we wish to have fulfilled C (, = 0 a b) = a b or C(, ) = r = a b a b 0 C: vector Constraint functions But how do we make it true? Convert constraints to force laws
Energy Functions Minimize the energy of the constraint The smaller the energy the more the constraint is satisfied ks E = C C 2 Force the particle towards the constraint E C fi = = ks C i i Add damping in order to avoid oscillations around the constraint dampening C f = k C& i d i Jacobian matri
Energy Functions Eample b a C = I C = a I C = b v a v b C = & a derivative b derivative time derivative Plug into the force equation C C C C f & i d i s i k k = ) ( ) ( b a d b a s a k k v v f = Just a damped spring
Collisions What should we do when there is a collision? Usually an interpenetration, not the eact collision is detected. t ) ( 0 ( t 1 ) ( t 2 ) ( t 3 )
Collision Detection Checked at every step, should be done efficiently Some collisions might be missed (collisions with thin objects)
Collision Detection Determine when a particle has collided (simple case) N N ( p) < 0 N ( p) = 0 Particle has collided iff p: point on the surface N ( p) < 0
Collision Response What should we do when a particle has collided? The correct thing to do is rollback the simulation to the eact point of contact Restart the simulation at the time of the collision On collision the state changes discontinuously
Rolling Back the Simulation ( t 0 ) ( t 1 ) ( t 2 ) ( t c ) ( t 3 ) Collision time, position can be found by interpolation, bisection, etc.
Rolling Back the Simulation: Bisection Bisect the time interval between the positions before and after the collision Run the simulation to evaluate position at the mid-time and check if this position is legal or not Bisect one of the two new time intervals depending on the previous step and repeat until the position is close to the surface
Collision Detection
Rolling Back the Simulation: Linear interpolation Assume that the particle follows linear constant velocity motion between the two positions (prior and after the detected collision) Evaluate collision time and position using this assumption.
Collision Response After finding the eact collision time and position: Kinematic response: negate (and perhaps modify) the perpendicular velocity. v n Run the simulation again from this point using the new initial velocity. v t v N new v After the collision: new v = ε vn + v t ε=1 elastic collision coefficient of restitution
Collision Response After finding the eact collision time and position: Dynamic response (more accurate): apply an instant impulse force on the particle in one step of the simulation Continue normally afterwards
Collision Response Easier handling: do not rollback the simulation Evaluate the new direction of the particle from the collision point onwards Evaluate the new velocity Place the particle on the new direction and in a distance equal to the one traveled after the real collision
Συγκρούσεις Ανελαστική σύγκρουση: το σωµατίδιο δεν χάνει ενέργεια, το µέτρο της ταχύτητας σταθερό Η πορεία µετά τη σύγκρουση ίδια µε αυτή φωτός ανακλώµενου σε επιφάνεια. Κατεύθυνση ανάκλασης: r = 2( p p ) nn ( p p ) 0 c 0 c
Συγκρούσεις Το σωµατίδιο σε απόσταση από το σηµείο σύγκρουσης όση και αν αυτή δεν συνέβαινε
Contact Forces Contact: the particle is on the collision surface with zero normal velocity A contact force resists penetration c ( N f ) < 0 f = ( N f ) N Contact forces do not resist leaving the surface f c = 0 Simple friction can be modeled f f f t ( N f ) > = k ( N f ) v ( N f ) < 0 0