Dynamics 101 Jim Van Verth Red Storm Entertainment

Slides:



Advertisements
Similar presentations
Numerical Integration
Advertisements

AP Physics C Mechanics Review.
Numeric Integration Methods Jim Van Verth Red Storm Entertainment
Dynamics 101 Jim Van Verth Red Storm Entertainment
Formal Computational Skills
Collision Response Jim Van Verth
Real-Time Game Physics
Rigid Body Dynamics Jim Van Verth
1cs533d-winter-2005 Notes  Assignment 1 is not out yet :-)  courses/533d-winter-2005.
Manipulator Dynamics Amirkabir University of Technology Computer Engineering & Information Technology Department.
Integration Techniques
Ordinary Differential Equations
Chris Hall Aerospace and Ocean Engineering
Chapter 11 Angular Momentum.
Dynamics of Articulated Robots Kris Hauser CS B659: Principles of Intelligent Robot Motion Spring 2013.
Game Physics – Part II Dan Fleck. Linear Dynamics Recap  Change in position (displacement) over time is velocity  Change in velocity over time is acceleration.
1Notes. 2 Building implicit surfaces  Simplest examples: a plane, a sphere  Can do unions and intersections with min and max  This works great for.
1Notes  Demetri Terzopoulos talk: Thursday, 4pm Dempster 310.
MAT 594CM S10Fundamentals of Spatial ComputingAngus Forbes Week 2 : Dynamics & Numerical Methods Goal : To write a simple physics simulation Topics: Intro.
Robot Dynamics – Newton- Euler Recursive Approach ME 4135 Robotics & Controls R. Lindeke, Ph. D.
Particle Systems 1 Adapted from: E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012.
Ch. 7: Dynamics.
Game Physics Chris Miles. The Goal To learn how to create game objects with realistic physics models To learn how to simulate aspects of reality in order.
1cs533d-winter-2005 Notes  Assignment 2 going okay? Make sure you understand what needs to be done before the weekend  Read Guendelman et al, “Nonconvex.
Manipulator Dynamics Amirkabir University of Technology Computer Engineering & Information Technology Department.
Physics 106: Mechanics Lecture 02
Modeling Fluid Phenomena -Vinay Bondhugula (25 th & 27 th April 2006)
Computer graphics & visualization Rigid Body Simulation.
3.7. O THER G AME P HYSICS A PPROACHES Overview of other game engine physics approaches.
Physics for Game Developers Jim Van Verth Christer Ericson Squirrel Eiserloh Gino van den Bergen Erin Catto Marq Singer.
Spring Topic Outline for Physics 1 Spring 2011.
Lecture VII Rigid Body Dynamics CS274: Computer Animation and Simulation.
Game Physics – Part IV Moving to 3D
Game Physics – Part I Dan Fleck Coming up: Rigid Body Dynamics.
Erin Catto Blizzard Entertainment Numerical Integration.
Spring Rigid Body Simulation. Spring Contents Unconstrained Collision Contact Resting Contact.
Numerical Integration and Rigid Body Dynamics for Potential Field Planners David Johnson.
Lecture Fall 2001 Physically Based Animation Ordinary Differential Equations Particle Dynamics Rigid-Body Dynamics Collisions.
Advanced Computer Graphics Rigid Body Simulation Spring 2002 Professor Brogan.
Chapter 11 Angular Momentum. Angular momentum plays a key role in rotational dynamics. There is a principle of conservation of angular momentum.  In.
Spring Rigid Body Simulation. Spring Contents Unconstrained Collision Contact Resting Contact.
Robotics II Copyright Martin P. Aalund, Ph.D.
4.1 Rotational kinematics 4.2 Moment of inertia 4.3 Parallel axis theorem 4.4 Angular momentum and rotational energy CHAPTER 4: ROTATIONAL MOTION.
Geometric Algebra Dr Chris Doran ARM Research 3. Applications to 3D dynamics.
CS274 Spring 01 Lecture 7 Copyright © Mark Meyer Lecture VII Rigid Body Dynamics CS274: Computer Animation and Simulation.
Rigid Body Dynamics CSE169: Computer Animation
Lecture 40 Numerical Analysis. Chapter 7 Ordinary Differential Equations.
Game Technology Animation V Generate motion of objects using numerical simulation methods Physically Based Animation.
Rick Parent - CIS682 Rigid Body Dynamics simulate basic physics of an object subject to forces Keyframing can be tedious - especially to get ‘realism’
Advanced Computer Graphics Spring 2014 K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology.
Rotational Motion – Part I AP Physics C. The radian  There are 2 types of pure unmixed motion:  Translational - linear motion  Rotational - motion.
Dynamics. Motion with Regard to Mass Particle Dynamics Mass concentrated in point Newton’s Equation Governs Motion f = M x.
UW EXTENSION CERTIFICATE PROGRAM IN GAME DEVELOPMENT 2 ND QUARTER: ADVANCED GRAPHICS Advanced Math.
Fundamentals of Computer Animation Rigid Body Simulation (1)
1 7. Rotational motion In pure rotation every point of an object moves in a circle whose center lies on the axis of rotation (in translational motion the.
Rotational Equilibrium and Dynamics Rotation and Inertia.
Advanced Computer Graphics Rigid Body Simulation
ECE 383 / ME 442 Fall 2015 Kris Hauser
Physically Based Simulations For Games
Manipulator Dynamics 1 Instructor: Jacob Rosen
7. Rotational motion In pure rotation every point of an object moves in a circle whose center lies on the axis of rotation (in translational motion the.
Lecture Rigid Body Dynamics.
Lecture 16 Newton Mechanics Inertial properties,Generalized Coordinates Ruzena Bajcsy EE
3.7. Other Game Physics Approaches
Manipulator Dynamics 2 Instructor: Jacob Rosen
Rigid Body Dynamics (unconstrained)
Computer Animation Algorithms and Techniques
Selected Problems in Dynamics: Stability of a Spinning Body -and- Derivation of the Lagrange Points John F. Fay June 24, 2014.
Physics 319 Classical Mechanics
Presentation transcript:

Dynamics 101 Jim Van Verth Red Storm Entertainment

What is Dynamics?  Want to move objects through the game world in the most realistic manner possible  Applying velocity not enough – need ramp up, ramp down – acceleration  Same with orientation

Calculus Review  Have function y(t)  Function y'(t) describes how y changes as t changes (also written dy/dt, or )  y'(t) gives slope at time t y(t)y(t) y'(t) y t y(t)y(t) y'(t)y'(t)

Calculus Review  Our function is position:  Derivative is velocity:  Derivative of velocity is acceleration

Basic Newtonian Physics  All objects affected by forces  Gravity  Ground (pushing up)  Other objects pushing against it  Force determines acceleration ( F = ma )  Acceleration changes velocity ( )  Velocity changes position ( )

Basic Newtonian Physics  Assume acceleration constant, then

Basic Newtonian Physics  Similarly

Basic Newtonian Physics  Key equations

Basic Newtonian Physics  One other quantity: momentum P  Note: force is derivative of momentum P  Integrate similarly:  Remember for later – easier for angular

Basic Newtonian Physics  General approach  Compute all forces on object, add up  Compute acceleration  (divide total force by mass)  Compute new position based on old position, velocity, acceleration  Compute new velocity based on old velocity, acceleration

Newtonian Physics  Works fine if acceleration is constant  Not good if acceleration dependant on position or velocity – changes over time step  E.g. spring force: F spring = – kx  E.g. drag force: F drag = – m  v

Analytic Solution  Can try and find an analytic solution  I.e. a formula for x and v  In case of simple drag:  But not always a solution  Or may want to try different simulation formulas  Better: approximate w/stepwise solution

Numeric Solution  Problem: Physical simulation with force dependant on position or velocity  Start at x(0) = x 0, v(0) = v 0  Only know:  Want: x(h), v(h) for some small h  Basic solution: Euler’s method

Euler’s Method  Idea: we have the slope ( or )  From calculus, know that  For sufficiently small h :

Euler’s Method  For sufficiently small h :  Can re-arrange as:  Gives us next function value in terms of current value and current derivative

Euler's Method  Step across vector field of functions  Not exact, but close x0x0 x2x2 x1x1 x t

Euler’s Method  Has problems  Expects the slope at the current point is a good estimate of the slope on the interval  Approximation can drift off the actual function – adds energy to system!  Gets worse the farther we get from known initial value  Especially bad when time step gets larger

Euler’s Method (cont’d)  Example of drift x0x0 x1x1 x2x2 t x

Stiffness  Running into classic problem of stiff equations  Have terms with rapidly decaying values  Faster decay = stiffer equation = need smaller h  Often seen in equations with stiff springs (hence the name)

Midpoint Method  Take two approximations  Approximate at half the time step  Use slope there for final approximation h h/2 x 0.5 x0x0 x1x1 t x

Midpoint Method  Writing it out:  Can still oscillate if h is too large

Runge-Kutta  Use weighted average of slopes across interval  How error-resistant indicates order  Midpoint method is order two  Usually use Runge-Kutta Order Four, or RK4

Runge-Kutta (cont’d)  Better fit, good for larger time steps  Expensive – requires many evaluations  If function is known and fixed (like in physical simulation) can reduce it to one big formula  But for large timesteps, still have trouble with stiff equations

Implicit Methods  Explicit Euler methods add energy  Implicit Euler removes it  Use next velocity, not current  E.g. Backwards Euler:  Better for stiff equations

Implicit Methods  Result of backwards Euler  Solution converges more slowly  But it converges! x0x0 x1x1 x2x2 t x

Implicit Methods  How to compute or ?  Derive from formula (most accurate)  Compute using explicit method and plug in value (predictor-corrector)  Solve using linear system (slowest, but general)  Run Euler’s in reverse: compute velocity first, then position (called symplectic Euler).

Verlet Integration  Velocity-less scheme  From molecular dynamics  Uses position from previous time step  Stable, but velocity estimated  Has error similar to symplectic Euler  Good for particle systems, not rigid body

Which To Use?  In practice, Midpoint or Euler’s method may be enough if time step is small  At 60 fps, that’s probably the case  In case of long frame times, can clamp simulation time step to 1/10 sec  Having trouble w/sim exploding? Try symplectic Euler or Verlet

Final Formulas  Using Euler’s method with time step h

What About Orientation?  Previous assumption:  Force ( F ) applied anywhere on body creates translation  Reality:  Force ( F ) applies to center of mass of object – creates translation  Force ( F ) applied anywhere else, also creates rotation

Center of Mass  Point on body where applying a force acts just like single particle  “Balance point” of object  Varies with density, shape of object  Pull/push anywhere but CoM, get torque

Force vs. Torque (cont’d)  To compute torque, take cross product of vector r (from CoM to point where force is applied), and force vector F  Applies torque ccw around vector  Add up torques just like forces r F

Other Angular Equivalents  Force F vs. torque   Velocity v vs. angular velocity   Position x vs. orientation R  Mass m vs. moments of inertia I  Momentum P vs. angular momentum L

Why L ?  Normally integrate to get vel from accel.  Not easy to pull angular acceleration from torque equation:  Instead, compute ang. momentum by integrating torque

Why L ?  Then compute ang. velocity from momentum  Since then

Moments of Inertia  Moments of inertia are 3 x 3 matrix, not single scalar factor (unlike m )  Many factors because rotation depends on shape  Describe how object rotates around various axes  Not always easy to compute  Change as object changes orientation

Computing I  Can use moments of inertia for closest box or cylinder  Can use sphere (one factor: 2mr 2 /5 )  Or, can just consider rotations around one axis and fake(!) the rest  With the bottom two you end up with just one value… can simplify equations

Computing I  Alternatively, can compute based on geometry  Assume constant density, constant mass at each vertex  Solid integral across shape  See Mirtich,Eberly for more details

 Remember,  I computed in local space, must transform to world space  If using rotation matrix R, use formula  If using quaternion, convert to matrix Using I in World Space

Computing New Orientation  Have matrix R and vector   How to integrate?  Convert  to give change in R  Change to linear velocity at tips of basis vectors  One for each basis gives 3x3 matrix  Can use Euler's method after that

Computing New Orientation  Example:

Computing New Orientation    r gives linear velocity at r  Could do this for each basis vector  Better way:  Use symmetric skew matrix to compute cross products  Multiply by orientation matrix

Computing New Orientation  If have matrix R, then where

Computing New Orientation  If have quaternion q, then  See Baraff or Eberly for derivation where

Computing New Orientation  We can represent wq as matrix multiplication where  Assumes q = (w, x, y, z)

Angular Formulas

Summary  Basic Newtonian dynamics  Position, velocity, force, momentum  Integration techniques  Euler’s, RK* methods, implicit, Verlet  Linear simulation  Force -> acceleration -> velocity -> position  Rotational simulation  Torque -> ang. mom. -> ang. vel. -> orientation

What Next?  Robustness ( Christer )  Collision detection ( Squirrel, Gino )  Collision response ( Erin )  Constraints ( Erin, Marq )  Destruction ( Marq )  Inverse kinematics  Animation blending

References  Burden, Richard L. and J. Douglas Faires, Numerical Analysis, PWS Publishing Company, Boston, MA,  Hecker, Chris, “Behind the Screen,” Game Developer, Miller Freeman, San Francisco, Dec Jun  Witken, Andrew, David Baraff, Michael Kass, SIGGRAPH Course Notes, Physically Based Modelling, SIGGRAPH  Eberly, David, Game Physics, Morgan Kaufmann, 2003.