04-05-2017 Keyframing Keyframing Motion of objects is described as a function of time from a set of key object positions ( keyframes ). s t ( ) • Keyframes are drawn by skilled animator. • Computer generates in-betweens using interpolation . Lecture 10 Slide 2 6.837 Fall 2003 1
04-05-2017 Keyframing Complex movements may require multiple keys. Interpolating Positions ( x , y , t ), i 0, , n Given positions: i i i x t ( ) x C ( ) t i C ( ) t find curve such that i y t ( ) y i ( x , y , t ) 2 2 2 u ( x , y , t ) C ( ) t 0 0 0 0 ( x , y , t ) 1 1 1 Slide 4 2
04-05-2017 Linear Interpolation ( x , y , t ) 2 2 2 ( x , y , t ) 0 0 0 ( x , y , t ) 1 1 1 x t ( ) x 1 t x t t =0 and =1 t Simple problem: 0 1 0 1 Any t i : t t x t t x , t t , t 1 0 0 1 0 1 t t t t 1 0 1 0 x t ( ) t t t t x x , t t , t 2 1 1 2 1 2 t t t t 2 1 2 1 Lecture 10 Slide 5 6.837 Fall 2003 Polynomial Interpolation ( x , y , t ) 2 2 2 ( x , y , t ) 0 0 0 parabola ( x , y , t ) 1 1 1 An n-degree polynomial can interpolate any n+1 points. The n+1 coefficients of an n-degree polynomial can be obtained from the n+1 points. Lecture 10 Slide 6 6.837 Fall 2003 3
04-05-2017 Spline Interpolation For large number of points (N), many polynomials of small degree can be used. Polynomials of small degree are faster and easier to control. t t t x t 8-degree spline spline vs. polynomial polynomial Lecture 10 Slide 7 Spline Interpolation A cubic polynomial between each pair of points: x t ( ) c c t c t 2 c t 3 0 1 2 3 4 parameters ( degrees of freedom ) for each spline segment. Input parameters: 4 points 2 points + 2 directions Lecture 10 4
04-05-2017 Interpolating Key Frames • Interpolation is not fool proof. • The splines may undershoot and cause interpenetration. • The animator must solve these types of side-effects. Lecture 10 Slide 12 6.837 Fall 2003 Keyframing Keyframe animation can be applied to different parameters Parameter to interpolate: position, orientation, deformation, lights, camera, opacity? 5
04-05-2017 Physics Simulation 6
04-05-2017 Physics Simulation Particles Rigid bodies Deformable bodies Fluid dynamics Vehicle dynamics Characters Definitions Kinematics : The study of motion without consideration of the underlying forces Dynamics : Study of physical motion (or more abstractly, the study of change in physical systems) Forward Dynamics : Computing motion resulting from applied forces Inverse Dynamics : Computing forces required to generate desired motion Mechanics, Statics, Kinetics 7
04-05-2017 Particles Particula p p , p , p x y z p ( t ) t ) p ( t + 8
04-05-2017 Kinematics of Particles Position : x Velocity: v = dx/dt a = dv/dt = d 2 x/dt 2 Acceleration: x v dt Aproximações númericas Exato se v 0 não varia em [0, t] x ( t ) x v t 0 0 x ( t ) x ( t t ) v ( t ) t Exato se v(t) não varia em t 9
04-05-2017 Aceleração Acceleration a=a 0 v a dt a t v Velocity 0 0 1 2 x v dt a t v t x Position 0 0 0 2 Aproximações númericas 1 Exato se a não varia em [0, t] 2 x ( t ) x v t a t o 0 0 2 1 2 x ( t ) x ( t t ) v ( t ) t a ( t ) t 2 Exato se a(t) não varia em t 10
04-05-2017 Forces Multiple forces can add up to a single total force: Forces cause change in momentum (accelerations) f f total i a f / M total Gravity Gravity near Earth’s surface is constant: f=m.g (g = -9.8 m/s 2 ) Gravity for distant objects: (G=6.673 × 10 -11 m 3 /kg·s 2 ) f=Gm 1 m 2 /r 2 11
04-05-2017 Spring-Damper Spring: f = -kx k=spring constant x=distance from rest state Damper: f=-cv c=damping factor v=velocity along spring axis Spring-damper: f=-kx-cv Aerodynamic Drag Drag force: f=(1/2) ρa c c d v 2 ρ=fluid density a c =cross sectional area c d =coefficient of drag (geometric constant based on shape of object, usually between 0 and 1, but can be higher) v=velocity of the object relative to velocity of the fluid Note: for simple cases, (1/2)ρa c c d is constant 12
04-05-2017 Friction Static friction: f ≤ f n μ s Dynamic friction: f = f n μ d f n =normal force μ s =coefficient of static friction μ d =coefficient of dynamic friction Force Fields Generic force fields can be created that use arbitrary rules to define a force at some location: f=f(x) Examples: vortex, attractors, turbulence, torus… 13
04-05-2017 Collisions: Impulse Momentum: p = m.v [kg.m.s -1 ] or [N.s] Impulse: J= Δp An impulse is a finite change in momentum Impulses are essentially large forces acting over a small time Modified momentum update: p/m = p 0 /m+f Δt/m+J/m p=p 0 +f Δt+J v = v 0 +a Δt+J/m Particle Simulation 1 Particle struct { Vector3d Velocity; Vector3d Position; float Mass; } UpdateParticle(float dtime) { Force = ComputeTotalForce(); Acel = Force/Mass; Velocity = Velocity + Acel * dtime; Position = Position + Velocity * dtime; } 14
04-05-2017 Particle Simulation 2 Particle struct { Vector3d Momentum; Vector3d Position; float Mass; } UpdateParticle(float dtime) { Impulse = ComputeTotalImpulse(dtime); Momentum = Momentum + Impulse; Velocity = Momentum / Mass; Position = Position + Velocity * dtime; } Integration Explicit Euler method: v=v 0 +a Δ t x=x 0 +v Δ t Optimize for: Other methods: • Stability Implicit Euler • Accuracy Runge-Kutta Crank-Nicholson • Convergence Multipoint • Performance Leapfrog DuFort-Frankel Adams, Adams-Moulton, Adams-Bashforth 15
04-05-2017 Rigid Bodies Angular Speed • The average angular speed, ω avg , of a rotating rigid f i avg t t t f i object is the ratio of the angular displacement to the time interval • The instantaneous angular d lim speed is defined as the t 0 t dt limit of the average speed as the time interval approaches zero • 16 • •
04-05-2017 Instantaneous Angular Acceleration • The instantaneous angular acceleration is defined as d lim t the limit of the average 0 t dt angular acceleration as the time goes to 0 • SI Units of angular acceleration: rad/s² Torque Torque, t , is tendency of a force to rotate object about some axis • F is the force t Fd d is the lever arm (or moment arm) • Units are Newton m • Torque is vector: Direction determined by axis of twist t Fd t Fr sin Φ is the angle between F and r 17
04-05-2017 Offset Forces Torque resulting from offset force: τ =r × f Total force: f res f i Total torque: t ( r f ) res i i Rotational Inertia • Rotational inertia or moment of inertia I is the resistance of an object to changes in its rotational motion. • Rotational inertia I is the rotational equal of mass M . • Rotational inertia depends on: • Mass • Distribution of that mass around the axis of rotation. I = ⌠ ⌡ r 2 dm Units: kg·m 2 18
04-05-2017 Moments of Inertia Rotational Inertia For arbitrary axis: I I I xx xy xz I I I I yx yy yz I I I zx zy zz 0 T I A I A 2 2 I ( ) y z dm xx I 0 0 xx I ( xy ) dm xy I 0 0 I 0 yy 0 0 I zz A=3x3 orientation matrix 19
04-05-2017 Torque and Rotational Inertia • Torque T is the application of a force which changes the angular acceleration of the object. Newton’s Second Law for Rotation: I T Angular Momentum Rigid body L I L mvr m r 2 Point particle Analogy between L and p Angular Momentum Linear momentum L = Iw p = mv t = dL/dt F = dp/dt t = I . F = m.a Conserved if no net Conserved if no net outside outside torques forces 20
04-05-2017 Angular Momentum L = I ω = A I 0 A T ω L =angular momentum I =rotational inertia ω=angular velocity A =3x3 orientation matrix Rigid Body Simulation RigidBody struct { Vector Position; Vector Velocity; Vector Orientation; Vector AngVelocity; float Mass; Matrix RotationInertia; } UpdateRigidBody(float dtime) { Force=ComputeTotalForce(); Torque=ComputeTotalTorque(); Aceleration = Force / Mass; Velocity = Velocity + Aceleration * dtime; Position = Position + Velocity * dtime; AngAceleration = Torque * Inverse(RotationalInertia); AngVelocity = AngVelocity + AngAceleration * dtime; Orientation = Orientation + AngVelocity * dtime; } 21
Recommend
More recommend