computer animation
play

Computer Animation Tim Weyrich March 2010 Physical simulation - PDF document

Computer Animation Tim Weyrich March 2010 Physical simulation Heavily based on slides by Marco Gillies Physical simulation Physical simulation: books ! Animation is about things moving ! One book that is OK: ! The motion of


  1. Computer Animation Tim Weyrich March 2010 Physical simulation Heavily based on slides by Marco Gillies Physical simulation Physical simulation: books • ! Animation is about things moving • ! One book that is OK: • ! The motion of “things” is governed by • ! “Physics for Game Developers” David the laws of physics M. Bourg – O’Reilly • ! These laws of physics are very well • ! A definitive guide is: understood and normally have • ! http://www2.cs.cmu.edu/~baraff/pbm/pbm.html computationally tractable mathematical formulae • ! So to get things to move lets use physics Newton’s third law Newton’s third law • ! The basis of physical simulations is • ! The basis of physical simulations is Newton’s third law Newton’s third law f = ma f = ma a = dv dt v = dp dt

  2. Newton’s third law Newton’s third law • ! Work out the forces acting on an object • ! The basis of physical simulations is Newton’s third law (vectors) – ! Gravity – ! Impulse forces (collisions) – ! Forces from springs, friction, other objects f = ma • ! Use Newton’s law to work out the position of an object at each time step a = dv • ! When we deal with forces and dt accelerations it is called “Dynamics” • ! Up to now we’ve just used velocities v = dp and positions “Kinematics” dt Integrating Newton’s laws Integrating Newton’s laws a = f • ! The correct formulas • ! The obvious approximation m a t' = f t' t m � v = adt t 0 v t' = v t +(t � t')a t' t p t' = p t +(t � t')v t' � p = vdt t 0 A projectile A Projectile • ! As an example choose a ball launched from the ground under gravity • ! Time step t=0.1 • ! Has initial conditions [ ] f = 0, � 9.81 m, 0 [ ] v 0 = 10 , 10 , 0 • ! a=-9.81 p 0 = 0,0,0 [ ]

  3. A Projectile A Projectile • ! a=-9.81 v=[10,10-0.981,0] • ! a=-9.81 v=[10,9.019,0] p=[1,0.9019, 0] A Projectile A Projectile • ! a=-9.81 v=[10,8.038,0] p=[2,1.7057, 0] • ! a=-9.81 v=[10,7.057,0] p=[3,2.4114, 0] A Projectile A Projectile • ! a=-9.81 v=[10,6.076,0] p=[4,3.019, 0] • ! a=-9.81 v=[10,5.095,0] p=[5,3.528, 0]

  4. Is the method valid? Is the method valid? • ! Is this a reasonable method? • ! Is this a reasonable method? • ! Taylor expansion of a function + ( � t) 2 d 2 y(t) y(t + � t) = y(t)+ � t dy(t) dt 2 � dt 2 ! Is the method valid? Is the method valid? • ! Is this a reasonable method? • ! Is this a reasonable method? • ! Taylor expansion of a function • ! Taylor expansion of a function + ( � t) 2 d 2 y(t) y(t + � t) = y(t)+ � t dy(t) y(t + � t) = y(t)+ � t dy(t) dt 2 � dt 2 ! dt • ! If � t is small we can ignore higher terms • ! If � t is small we can ignore higher terms • ! This is the same as our method • ! Called Euler’s method Step size Step size • ! � t is called the step size • ! What is worse is that errors can build up over time • ! It is very important in this sort of calculation • ! So for long(ish) animations you need a very small step size • ! If it is too large then the solution will be inaccurate • ! Can get very expensive • ! If it is too small then you will need a lot • ! Can make Euler’s method unusable of processing power

  5. How can we improve it? Adaptive step sizes • ! Dynamically change the step size as we • ! Only use as small a step size as you need it need • ! Use a different method • ! Every so often test the different between using step size � t and � t /2 • ! If the difference is big enough start using � t /2 • ! Do the same for � t *2 Other integration methods Midpoint method • ! This is a vast field • ! Euler’s method evaluates the derivative at t (The start of the step) • ! There are huge numbers of different methods you can use • ! Using 2 nd and higher derivatives • ! Evaluating the different derivatives for different values of t • ! I will describe one � t t Midpoint method Midpoint method • ! Can get more accuracy by evaluating it • ! The formula becomes: at t + � t/2 (the midpoint) p(t + � t) = p(t)+ � t dp dt (t + � t /2 ) t � t

  6. Midpoint method Summary • ! The formula becomes: • ! A physics simulation consists of – ! A set of particles p(t + � t) = p(t)+ � t dp – ! A set of forces on those particles dt (t + � t /2 ) – ! Initial position of those particles • ! The alogrithm: • ! This is one example from a many types of improvement – ! Use the forces to update the acceleration • ! Far more to go into but beyond the scope of – ! Integrate to update velocities and positions the course • ! We need appropriate forces Springs Springs • ! Stretching the spring creates forces on • ! Springs are a common source of forces both particles to restore the desired • ! The forces try to maintain a desired length length • ! These forces are proportional to the • ! Join two particles by a spring change in length L L � L F( � L) F( � L) Springs Springs • ! Ditto for squashing • ! Ditto for squashing L L � L F( � L) F( � L)

  7. Springs Springs • ! The Formula for spring forces on the particles • ! The problem with this formula is that the are given by Hooke’s Law spring can bounce about too much and never come to rest • ! Have a force pointing along the length of the spring that depends on the change of length: • ! We need to add a damping force • ! Damping forces reduce the motion of an F = � k s � L object (like friction) • ! They are proportional to the velocity of an • ! Where k s is a spring constant, which controls object (but opposite) how springy or rigid it is Springs Using springs • ! Introduce a damping force • ! Springs are a very useful tool because they can be used to build models of • ! Proportional to the relative velocity of the two particles (and negative) interesting physical systems [ ] F = � k s � L � k d v 2 � v 1 ( ) • ! Where k d is a damping constant, which controls how damped it is Using springs Hair • ! A string of springs can simulate hair, • ! Unfortunately there is nothing to stop grass etc. the hair bending • ! Need to add in extra forces to prevent bending • ! Many approaches but you can just add extra springs

  8. Hair Hair • ! Putting springs between every other • ! Animating each hair would be hugely particle expensive • ! Counteracts bending between 3 • ! Generally methods simulate a smallish particles number of strands and render each one as a clump of hair rather than an individual hair Hair Using springs • ! A lattice can simulate cloth • ! Many other methods • ! Often use more continuous representation of hair Using springs Cloth • ! A lattice can simulate cloth • ! This simple lattice allows you to simulate the in plane stretching properties of cloth well, but there are other forces that go on in cloth • ! Bending can be handled in the same way as for hair

  9. Cloth Cloth • ! Shearing • ! Add in diagonal springs for shearing • ! This becomes an issue going from 1D hair to 2D cloth • ! A force that prevents the cloth pulling against itself Cloth Cloth • ! Add in diagonal springs for shearing • ! And springs for bending Cloth Cloth • ! Demo • ! Springs aren’t all there is to physics, hair and clothing • ! There are lots of other approaches, more continuous methods, more realistic force functions etc

  10. Rigid bodies Rigid bodies • ! Up to now we have dealt with forces on • ! Can move around particles (points) • ! But cannot deform • ! What about more complex object? • ! A rigid body: Rigid bodies Rigid bodies • ! Could make it out of springs • ! Has a centre of mass that can be treated as a particle • ! But as you don’t want it to deform the spring constant must be very high • ! Very expensive to integrate Rigid bodies Rigid bodies • ! The movement of a rigid body can be • ! The motion of the centre of mass is decomposed into 2: treated the same as the particle dynamics discussed above • ! Motion of the centre of mass • ! The rotation adds a new set of • ! Rotation about the centre of mass components above the x,y,z position components • ! Won’t go into much detail about the maths here

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend