<<

Physics-based Simulaon

• simple (independent parcles), or complex (robust colliding, stacking, sliding 3D rigid bodies) • many many simulators! – PhysX (Unity, Unreal), , , MuJoCo, , , , OpenSim, RBDL, Simulink (MATLAB), ADAMS, SD/FAST, DART, , SOFA, Avatar, , Cannon.js, … – many course projects, theses, abandon-ware Resources

• hps://processing.org/examples/ see “Simulate”; 2D parcle systems • Non-convex rigid bodies with stacking 3D collision processing and stacking hp://www.cs.ubc.ca/~rbridson/docs/rigid_bodies.pdf • Physically-based Modeling, course notes, SIGGRAPH 2001, Baraff & Witkin hp://www.pixar.com/companyinfo/research/pbm2001/ • Doug James CS 5643 course notes hp://www.cs.cornell.edu/courses/cs5643/2015sp/ • Rigid Body Dynamics, Chris Hecker hp://chrishecker.com/Rigid_Body_Dynamics • physics tutorial hps://www.toptal.com/game/video-game-physics-part-i-an-introducon-to-rigid-body-dynamics • Box2D javascript live demos hp://heikobehrens.net/misc/box2d.js/examples/ • Rigid body collisions javascript demo hps://www.myphysicslab.com/engine2D/collision-en.html • Rigid Body Collision Reponse, Michael Manzke, course slides hps://www.scss.tcd.ie/Michael.Manzke/CS7057/cs7057-1516-09-CollisionResponse-mm.pdf • Rigid Body Dynamics Algorithms. Roy Featherstone, 2008 • Parcle-based Fluid Simulaon for Interacve Applicaons, SCA 2003, PDF • Stable Fluids, Jos Stam, SIGGRAPH 1999. interacve demo: hps://29a.ch/2012/12/16/webgl-fluid-simulaon Simulaon Basics

• simulaon loop • basic parcle sim – Equaons of Moon sum forces & torques; solve for acceleraons – numerical integraon update posions, velocies – collision detecon – collision resoluon Physically-based Simulaon – movement governed by forces • parcle systems – fire, water, smoke, (fluids, cloth, hair) – heuriscs-based or more principled • rigid-body simulaon – blocks, robots, humans • connuum systems – deformable solids – fluids, cloth, hair • group movement – flocks, crowds Ordinary Differenal Equaons

dX(t) Given X0 = X(t0 ) = f (X(t),t) dt Compute X(t) for t > t0 Simulaon as a path through state-space, driven by a vector field Newtonian Physics as first-order ODE • moon of one parcle

• moon of many parcles Parcle Forces

• gravity • viscous damping • springs & dampers F = −kp x − kdv • Lennard-Jones potenals Proxy Forces

• behavior forces: Curl noise for procedural fluid flow flocking birds, schooling fish, etc. R. Bridson, J. Hourihan, M. Nordenstam, [“Boids”, Craig Reynolds, SIGGRAPH 1987] Proc. SIGGRAPH 2007. ODE Numerical Integraon: Explicit (Forward) Euler dX = f (X) dt ΔX = Δt f (X)

Images from MIT-OCW: Explicit Euler: problems

Soluon spirals outwards no maer how small the me step !

(although smaller me steps are sll beer)

Or can lead to instabilies:

[Physically Based Animaon Witkin & Baraff, SIGGRAPH course notes] Midpoint & Trapezoid methods

Second order accurate; Midpoint method also known as “second order Runge-Kua” [slide in part from MIT-OCW] Code

MIDPOINT METHOD

EXPLICIT EULER Implicit Euler

Idea: Use the derivave at the desnaon Problem: We don’t know the desnaon yet !!

forward “explicit” Euler Xn Xn+1 Xn+1 = Xn + h f (Xn )

xn+1 = xn + hvn xn+1 −kxn X = X + h f (X ) v = v + h( ) n+1 n n+1 n+1 n m backward “implicit” Euler

xn+1 = xn + hvn+1 −kx v = v + h( n+1 ) n+1 n m

Rigid Body Dynamics

• from parcles to rigid bodies…

Newton’s equaons of moon Newton-Euler equaons of moon Preliminaries

• cross product via a matrix mulply

a! Kinemacs of Rotaon

• Intuively, with scalars: v r ω r F m • More generally: ! F P ! ! ! ! ω r r r Newton’s Law Euler’s Law top view

side view Angular Momentum of a Set of Parcles Inera Tensor Newton-Euler Equaons of Moon Updang the Inera Tensor Simulaon Loop linear posion linear velocity angular orientaon angular velocity for each mestep

setup

solve eqns of moon

integrate Rigid Body Collisions

• Collision Detecon – broad phase: e.g., AABBs, bounding spheres – narrow phase: detailed checks • Collision Response – collision impulses – constraint forces: resng, sliding, hinges, …. Parcle-Plane Collisions hps://www.scss.tcd.ie/Michael.Manzke/CS7057/cs7057-1516-09-CollisionResponse-mm.pdf hps://www.scss.tcd.ie/Michael.Manzke/CS7057/cs7057-1516-09-CollisionResponse-mm.pdf hps://www.scss.tcd.ie/Michael.Manzke/CS7057/cs7057-1516-09-CollisionResponse-mm.pdf hps://www.scss.tcd.ie/Michael.Manzke/CS7057/cs7057-1516-09-CollisionResponse-mm.pdf hps://www.scss.tcd.ie/Michael.Manzke/CS7057/cs7057-1516-09-CollisionResponse-mm.pdf hps://www.scss.tcd.ie/Michael.Manzke/CS7057/cs7057-1516-09-CollisionResponse-mm.pdf