39
Simulation in Computer Graphics Rigid Body Dynamics Matthias Teschner Computer Science Department University of Freiburg

Simulation in Computer Graphics Rigid Body Dynamics · PDF fileSimulation in Computer Graphics Rigid Body Dynamics ... rigid body kinematics ... 12 angular velocity

Embed Size (px)

Citation preview

Page 1: Simulation in Computer Graphics Rigid Body Dynamics · PDF fileSimulation in Computer Graphics Rigid Body Dynamics ... rigid body kinematics ... 12 angular velocity

Simulation in Computer Graphics

Rigid Body Dynamics

Matthias Teschner

Computer Science DepartmentUniversity of Freiburg

Page 2: Simulation in Computer Graphics Rigid Body Dynamics · PDF fileSimulation in Computer Graphics Rigid Body Dynamics ... rigid body kinematics ... 12 angular velocity

University of Freiburg – Computer Science Department – Computer Graphics - 2

Motivation

www.hairyharry.de

Page 3: Simulation in Computer Graphics Rigid Body Dynamics · PDF fileSimulation in Computer Graphics Rigid Body Dynamics ... rigid body kinematics ... 12 angular velocity

University of Freiburg – Computer Science Department – Computer Graphics - 3

Outline

representation of a rigid body position (center of mass) orientation

rigid body kinematics linear velocity angular velocity

rigid body dynamics inertia tensor linear and angular momentum force and torque simulation loop

orientation contact handling

Page 4: Simulation in Computer Graphics Rigid Body Dynamics · PDF fileSimulation in Computer Graphics Rigid Body Dynamics ... rigid body kinematics ... 12 angular velocity

University of Freiburg – Computer Science Department – Computer Graphics - 4

Mass-Point System

3n degrees of freedom (dof)

interaction modeled explicitly

system of 3n unknown

no notion of orientation

scalar mass

Mass-Point System vs. Rigid Body

Rigid Body

springs with infinite stiffness

modeled implicitly

6 remaining dof (position and orientation of the entire body)

meaningful orientation

mass distribution

Page 5: Simulation in Computer Graphics Rigid Body Dynamics · PDF fileSimulation in Computer Graphics Rigid Body Dynamics ... rigid body kinematics ... 12 angular velocity

University of Freiburg – Computer Science Department – Computer Graphics - 5

Particle Representation of a Rigid Body

world framecoordinates

body framecoordinates

initialstate

transformedstate

body frame (localcoordinate system)

world frame (globalcoordinate system)

translation + rotation

Page 6: Simulation in Computer Graphics Rigid Body Dynamics · PDF fileSimulation in Computer Graphics Rigid Body Dynamics ... rigid body kinematics ... 12 angular velocity

University of Freiburg – Computer Science Department – Computer Graphics - 6

Center of Mass(Massenmittelpunkt, Schwerpunkt)

same point undertranslation and rotation

Page 7: Simulation in Computer Graphics Rigid Body Dynamics · PDF fileSimulation in Computer Graphics Rigid Body Dynamics ... rigid body kinematics ... 12 angular velocity

University of Freiburg – Computer Science Department – Computer Graphics - 7

Center of Mass - Motivation

Newton's Second Law

Page 8: Simulation in Computer Graphics Rigid Body Dynamics · PDF fileSimulation in Computer Graphics Rigid Body Dynamics ... rigid body kinematics ... 12 angular velocity

University of Freiburg – Computer Science Department – Computer Graphics - 8

rotation matrix 3 x 3 elements to represent 3 degrees of freedom

Orientation in 3D

Page 9: Simulation in Computer Graphics Rigid Body Dynamics · PDF fileSimulation in Computer Graphics Rigid Body Dynamics ... rigid body kinematics ... 12 angular velocity

University of Freiburg – Computer Science Department – Computer Graphics - 9

has to be orthonormal

magnitude of eigenvalues is 1, so preserves the length of

position of a body point

Orientation in 3D

translation + rotation

Page 10: Simulation in Computer Graphics Rigid Body Dynamics · PDF fileSimulation in Computer Graphics Rigid Body Dynamics ... rigid body kinematics ... 12 angular velocity

University of Freiburg – Computer Science Department – Computer Graphics - 10

representation of a rigid body position (center of mass) orientation

rigid body kinematics linear velocity angular velocity

rigid body dynamics inertia tensor linear and angular momentum force and torque simulation loop

orientation contact handling

Outline

Page 11: Simulation in Computer Graphics Rigid Body Dynamics · PDF fileSimulation in Computer Graphics Rigid Body Dynamics ... rigid body kinematics ... 12 angular velocity

University of Freiburg – Computer Science Department – Computer Graphics - 11

time-dependent position

velocity

Body in Motion

linear velocity + angular velocity

Page 12: Simulation in Computer Graphics Rigid Body Dynamics · PDF fileSimulation in Computer Graphics Rigid Body Dynamics ... rigid body kinematics ... 12 angular velocity

University of Freiburg – Computer Science Department – Computer Graphics - 12

angular velocity is a 3D vector in direction of axis of rotation

is the magnitude of the angular velocity [rad/s]

Angular Velocity in 3D(Winkelgeschwindigkeit)

Page 13: Simulation in Computer Graphics Rigid Body Dynamics · PDF fileSimulation in Computer Graphics Rigid Body Dynamics ... rigid body kinematics ... 12 angular velocity

University of Freiburg – Computer Science Department – Computer Graphics - 13

What is the relation between and ?

angular velocity rotates all axis (columns of )

position of a point

velocity of a point

Rigid Body Kinematics

Page 14: Simulation in Computer Graphics Rigid Body Dynamics · PDF fileSimulation in Computer Graphics Rigid Body Dynamics ... rigid body kinematics ... 12 angular velocity

University of Freiburg – Computer Science Department – Computer Graphics - 14

particle rigid body

State Vector

Page 15: Simulation in Computer Graphics Rigid Body Dynamics · PDF fileSimulation in Computer Graphics Rigid Body Dynamics ... rigid body kinematics ... 12 angular velocity

University of Freiburg – Computer Science Department – Computer Graphics - 15

representation of a rigid body position (center of mass) orientation

rigid body kinematics linear velocity angular velocity

rigid body dynamics inertia tensor linear and angular momentum force and torque simulation loop

orientation contact handling

Outline

Page 16: Simulation in Computer Graphics Rigid Body Dynamics · PDF fileSimulation in Computer Graphics Rigid Body Dynamics ... rigid body kinematics ... 12 angular velocity

University of Freiburg – Computer Science Department – Computer Graphics - 16

forces change linear velocity

angular velocity

linear velocity change

like a particle, but ...

Rigid Body Dynamics

Page 17: Simulation in Computer Graphics Rigid Body Dynamics · PDF fileSimulation in Computer Graphics Rigid Body Dynamics ... rigid body kinematics ... 12 angular velocity

University of Freiburg – Computer Science Department – Computer Graphics - 17

the angular momentum of a particle w.r.t. the center of mass is

the total angular momentum of the body is

Angular Momentum (Drehimpuls)

Page 18: Simulation in Computer Graphics Rigid Body Dynamics · PDF fileSimulation in Computer Graphics Rigid Body Dynamics ... rigid body kinematics ... 12 angular velocity

University of Freiburg – Computer Science Department – Computer Graphics - 18

the total angular momentum is with being a 3 x 3 matrix (the inertia tensor of the body)

depends on the rotated configuration

the inertia tensor for the original body can be pre-computed, e.g.

similarity transform relates time-dependent and pre-computed :

Inertia Tensor (Trägheitstensor)

Page 19: Simulation in Computer Graphics Rigid Body Dynamics · PDF fileSimulation in Computer Graphics Rigid Body Dynamics ... rigid body kinematics ... 12 angular velocity

University of Freiburg – Computer Science Department – Computer Graphics - 19

the torque of a particle w.r.t. the center of mass is

the total torque of the body is

Torque (Drehmoment)

Page 20: Simulation in Computer Graphics Rigid Body Dynamics · PDF fileSimulation in Computer Graphics Rigid Body Dynamics ... rigid body kinematics ... 12 angular velocity

University of Freiburg – Computer Science Department – Computer Graphics - 20

angular momentum

torque

the angular version of Newton's Second law reads

tells us, how the forces change the angular velocity

Newton's Second Law (Angular)

Page 21: Simulation in Computer Graphics Rigid Body Dynamics · PDF fileSimulation in Computer Graphics Rigid Body Dynamics ... rigid body kinematics ... 12 angular velocity

University of Freiburg – Computer Science Department – Computer Graphics - 21

linear momentum angular momentum

linear velocity angular velocity

time-derivative of time-derivative of thethe linear momentum angular momentum

Linear vs. Angular Quantities

Page 22: Simulation in Computer Graphics Rigid Body Dynamics · PDF fileSimulation in Computer Graphics Rigid Body Dynamics ... rigid body kinematics ... 12 angular velocity

University of Freiburg – Computer Science Department – Computer Graphics - 22

Dynamics

Page 23: Simulation in Computer Graphics Rigid Body Dynamics · PDF fileSimulation in Computer Graphics Rigid Body Dynamics ... rigid body kinematics ... 12 angular velocity

University of Freiburg – Computer Science Department – Computer Graphics - 23

Simulation Loop (Euler)

Initialize:

Pre-compute: sum up external forces

perform Euler integration step

per particle quantities

Page 24: Simulation in Computer Graphics Rigid Body Dynamics · PDF fileSimulation in Computer Graphics Rigid Body Dynamics ... rigid body kinematics ... 12 angular velocity

University of Freiburg – Computer Science Department – Computer Graphics - 24

orientation matrix is updated every time step

errors accumulate

is not orthonormal anymore

Gram-Schmidt orthonormalization

Reorthonormalization of the Orientation

Page 25: Simulation in Computer Graphics Rigid Body Dynamics · PDF fileSimulation in Computer Graphics Rigid Body Dynamics ... rigid body kinematics ... 12 angular velocity

University of Freiburg – Computer Science Department – Computer Graphics - 25

Force vs. Torque Puzzle

10 s later

10 s later

longer path!

is force being considered twice? to accelerate center of mass

to cause the body to spin

Page 26: Simulation in Computer Graphics Rigid Body Dynamics · PDF fileSimulation in Computer Graphics Rigid Body Dynamics ... rigid body kinematics ... 12 angular velocity

University of Freiburg – Computer Science Department – Computer Graphics - 26

representation of a rigid body position (center of mass) orientation

rigid body kinematics linear velocity angular velocity

rigid body dynamics inertia tensor linear and angular momentum force and torque simulation loop

orientation contact handling

Outline

Page 27: Simulation in Computer Graphics Rigid Body Dynamics · PDF fileSimulation in Computer Graphics Rigid Body Dynamics ... rigid body kinematics ... 12 angular velocity

University of Freiburg – Computer Science Department – Computer Graphics - 27

quaternions

4 components represent 3 dof

often used in rigid body computations for rotations

Alternative OrientationRepresentations

Page 28: Simulation in Computer Graphics Rigid Body Dynamics · PDF fileSimulation in Computer Graphics Rigid Body Dynamics ... rigid body kinematics ... 12 angular velocity

University of Freiburg – Computer Science Department – Computer Graphics - 28

quaternions are an extension of complex numbers

Quaternions

Page 29: Simulation in Computer Graphics Rigid Body Dynamics · PDF fileSimulation in Computer Graphics Rigid Body Dynamics ... rigid body kinematics ... 12 angular velocity

University of Freiburg – Computer Science Department – Computer Graphics - 29

Basic Operations

addition

dot product

conjugate

magnitude (module)

inverse

Page 30: Simulation in Computer Graphics Rigid Body Dynamics · PDF fileSimulation in Computer Graphics Rigid Body Dynamics ... rigid body kinematics ... 12 angular velocity

University of Freiburg – Computer Science Department – Computer Graphics - 30

Basic Operations

multiplication

Page 31: Simulation in Computer Graphics Rigid Body Dynamics · PDF fileSimulation in Computer Graphics Rigid Body Dynamics ... rigid body kinematics ... 12 angular velocity

University of Freiburg – Computer Science Department – Computer Graphics - 31

quaternions with can be used to represent rotations

corresponding rotation matrix

rotation of a point

Unit Quaternions

Page 32: Simulation in Computer Graphics Rigid Body Dynamics · PDF fileSimulation in Computer Graphics Rigid Body Dynamics ... rigid body kinematics ... 12 angular velocity

University of Freiburg – Computer Science Department – Computer Graphics - 32

initialization of orientation and angular velocity in the body frame

update of the angular velocity using

update of the orientation using

updated orientation has to be normalized

torque needs to be transformed from world to body frame,angular velocity from body to world frame

Application in the Simulation Loop

Page 33: Simulation in Computer Graphics Rigid Body Dynamics · PDF fileSimulation in Computer Graphics Rigid Body Dynamics ... rigid body kinematics ... 12 angular velocity

University of Freiburg – Computer Science Department – Computer Graphics - 33

representation of a rigid body position (center of mass) orientation

rigid body kinematics linear velocity angular velocity

rigid body dynamics inertia tensor linear and angular momentum force and torque simulation loop

orientation contact handling

Outline

Page 34: Simulation in Computer Graphics Rigid Body Dynamics · PDF fileSimulation in Computer Graphics Rigid Body Dynamics ... rigid body kinematics ... 12 angular velocity

University of Freiburg – Computer Science Department – Computer Graphics - 34

Non-Penetration

detect collisions (see collision detection slides)

avoid penetrations change time step or

push body back

compute collision response colliding contact ("easy")

resting contact (very hard)

Page 35: Simulation in Computer Graphics Rigid Body Dynamics · PDF fileSimulation in Computer Graphics Rigid Body Dynamics ... rigid body kinematics ... 12 angular velocity

University of Freiburg – Computer Science Department – Computer Graphics - 35

force driven penetration causes force (late, slow, easy to compute)

impulse driven manipulation of velocities (J) instead of accelerations

(fast, more difficult to compute)

e – coefficient of restitution(e=0 plastic c., e=1 elastic c.)

Colliding Contact

Page 36: Simulation in Computer Graphics Rigid Body Dynamics · PDF fileSimulation in Computer Graphics Rigid Body Dynamics ... rigid body kinematics ... 12 angular velocity

University of Freiburg – Computer Science Department – Computer Graphics - 36

Resting Contact

find all collisions with small relative velocities

solve for all contact forces simultaneously such that for each contact force the force is strong enough to prevent interpenetration

the force is repulsive only (not glue like)

the force is zero if the bodies separate

Linear complementary problem (LCP)

Page 37: Simulation in Computer Graphics Rigid Body Dynamics · PDF fileSimulation in Computer Graphics Rigid Body Dynamics ... rigid body kinematics ... 12 angular velocity

University of Freiburg – Computer Science Department – Computer Graphics - 37

representation of a rigid body position (center of mass) orientation

rigid body kinematics linear velocity angular velocity

rigid body dynamics inertia tensor linear and angular momentum force and torque simulation loop

orientation contact handling

Summary

Page 38: Simulation in Computer Graphics Rigid Body Dynamics · PDF fileSimulation in Computer Graphics Rigid Body Dynamics ... rigid body kinematics ... 12 angular velocity

University of Freiburg – Computer Science Department – Computer Graphics - 38

References

Murilo G. Coutinho, "Dynamic Simulations of Multibody Systems",Springer, ISBN 0-387-95192-X

Andrew Witkin, David Baraff, Michael Kass,"Physically-based modeling",ACM SIGGRAPH '01, Course Notes, 2001.

David Eberly,"Game Physics",Elsevier, ISBN 1-55860-740-4.

Kenny Erleben, J. Sporring, K. Henriksen, H. Dohlmann,"Physics-based Animation",Charles River Media, Hingham, Massachusetts, ISBN 1-58450-380-7, 2005.

Jan Bender, "Impulsbasierte Dynamiksimulation von Mehrkoerpersystemen in der virtuellen Realitaet",Dissertation, Universitaet Karlsruhe, 2007

Page 39: Simulation in Computer Graphics Rigid Body Dynamics · PDF fileSimulation in Computer Graphics Rigid Body Dynamics ... rigid body kinematics ... 12 angular velocity

University of Freiburg – Computer Science Department – Computer Graphics - 39

This slide set is courtesy of Matthias Mueller-Fischer, NVIDIA Corp. It has been modified.

Acknowledgement