Download - Rigid Body Dynamics - Hanyangcalab.hanyang.ac.kr/courses/CG_taesoo/14_2_rigidbody.pdf · Rigid Bodies Rigid bodies have both a position and orientation Rigid bodies assume no object

Transcript
Page 1: Rigid Body Dynamics - Hanyangcalab.hanyang.ac.kr/courses/CG_taesoo/14_2_rigidbody.pdf · Rigid Bodies Rigid bodies have both a position and orientation Rigid bodies assume no object

Rigid Body Dynamics

Page 2: Rigid Body Dynamics - Hanyangcalab.hanyang.ac.kr/courses/CG_taesoo/14_2_rigidbody.pdf · Rigid Bodies Rigid bodies have both a position and orientation Rigid bodies assume no object

From Particles to Rigid Bodies

• Particles

– No rotations

– Linear velocity v only

• Rigid bodies

– Body rotations

– Linear velocity v

– Angular velocity ω

Page 3: Rigid Body Dynamics - Hanyangcalab.hanyang.ac.kr/courses/CG_taesoo/14_2_rigidbody.pdf · Rigid Bodies Rigid bodies have both a position and orientation Rigid bodies assume no object

Rigid Bodies

Rigid bodies have both a position and orientation

Rigid bodies assume no object deformation

Rigid body motion is represented by 2 parameters

)(tx - center of mass

)(tR - orientation (rotation matrix)

Meaning of R(t): columns represent the coordinates

of the body space base vectors (1,0,0), (0,1,0), (0,0,1)

in world space.

Page 4: Rigid Body Dynamics - Hanyangcalab.hanyang.ac.kr/courses/CG_taesoo/14_2_rigidbody.pdf · Rigid Bodies Rigid bodies have both a position and orientation Rigid bodies assume no object

Rigid Bodies

Objects are defined in body space (local coordinate system) and transformed into world space

)()()( 0 ttt xpRp

110

)()(

1

)( 0pxRp ttt

Page 5: Rigid Body Dynamics - Hanyangcalab.hanyang.ac.kr/courses/CG_taesoo/14_2_rigidbody.pdf · Rigid Bodies Rigid bodies have both a position and orientation Rigid bodies assume no object

Body Space

Objects are defined in body space (local coordinate system) and transformed into world space

– bodies are specified relative to this system

– center of mass is the origin

(for convenience)

• We will specify body-related physical properties (inertia, …) in this frame

Page 6: Rigid Body Dynamics - Hanyangcalab.hanyang.ac.kr/courses/CG_taesoo/14_2_rigidbody.pdf · Rigid Bodies Rigid bodies have both a position and orientation Rigid bodies assume no object

Outline

• Rigid Body Preliminaries– velocity, acceleration, and inertia

• State and Evolution

• Collision Detection and Contact Determination

• Colliding Contact Response

Page 7: Rigid Body Dynamics - Hanyangcalab.hanyang.ac.kr/courses/CG_taesoo/14_2_rigidbody.pdf · Rigid Bodies Rigid bodies have both a position and orientation Rigid bodies assume no object

Kinematics: Velocities

• How do x(t) and R(t) change over time?

• Linear velocity v(t) = dx(t)/dt is the same:

– Describes the velocity of the center of mass (m/s)

• Angular velocity (t) is new!

– Direction is the axis of rotation

– Magnitude is the angularvelocity about the axis (rad/s)

– There is a simple relationship between R(t) and (t)

Page 8: Rigid Body Dynamics - Hanyangcalab.hanyang.ac.kr/courses/CG_taesoo/14_2_rigidbody.pdf · Rigid Bodies Rigid bodies have both a position and orientation Rigid bodies assume no object

Kinematics: Velocities

Then

Page 9: Rigid Body Dynamics - Hanyangcalab.hanyang.ac.kr/courses/CG_taesoo/14_2_rigidbody.pdf · Rigid Bodies Rigid bodies have both a position and orientation Rigid bodies assume no object

We can represent the cross product with a matrix

Angular Velocity

bbaba

0

0

0*

zy

xx

yz

aa

aa

aa

)()()( * ttt RωR Therefore

Page 10: Rigid Body Dynamics - Hanyangcalab.hanyang.ac.kr/courses/CG_taesoo/14_2_rigidbody.pdf · Rigid Bodies Rigid bodies have both a position and orientation Rigid bodies assume no object

Since a point can be represented at any time by

Velocity of a Point

Total velocity can then be expressed as

)()()( 0 ttt xrRr

)()()( 0 ttt vrRr

)()()( 0

* ttt vrRωr

)())()(()( tttt vxrωr

Which can be rewritten as

Page 11: Rigid Body Dynamics - Hanyangcalab.hanyang.ac.kr/courses/CG_taesoo/14_2_rigidbody.pdf · Rigid Bodies Rigid bodies have both a position and orientation Rigid bodies assume no object

Dynamics: Accelerations

• How do v(t) and dR(t)/dt change over time?

• First we need some more machinery

– Forces and Torques

– Momentums

– Inertia Tensor

• Simplify equations by formulating accelerations in terms of momentum derivatives instead of velocity derivatives

Page 12: Rigid Body Dynamics - Hanyangcalab.hanyang.ac.kr/courses/CG_taesoo/14_2_rigidbody.pdf · Rigid Bodies Rigid bodies have both a position and orientation Rigid bodies assume no object

We can apply forces to the object at any point

Force

)()( tt iFF

Total force on an object is simply

No information about where the forces are applied

)(1 tF)(2 tF

Page 13: Rigid Body Dynamics - Hanyangcalab.hanyang.ac.kr/courses/CG_taesoo/14_2_rigidbody.pdf · Rigid Bodies Rigid bodies have both a position and orientation Rigid bodies assume no object

Torque describes the “rotational force”

Torque

)())()(()()( ttttt iii Fxrττ

Total torque on an object is simply

Tells us about the force distribution over the object

)(1 tF)(2 tF

)())()(()( tttt iii Fxrτ

)(tx )(1 tr

Page 14: Rigid Body Dynamics - Hanyangcalab.hanyang.ac.kr/courses/CG_taesoo/14_2_rigidbody.pdf · Rigid Bodies Rigid bodies have both a position and orientation Rigid bodies assume no object

Forces and Torques

• External forces Fi(t) act on particles– Total external force F= Fi(t)

• Torques depend on distance from the center of mass:

i (t) = (ri(t) – x(t)) x Fi(t)

– Total external torque = ((ri(t)-x(t)) x Fi(t)

• F(t) doesn’t convey any information about where the various forces act

• (t) does tell us about the distribution of forces

Page 15: Rigid Body Dynamics - Hanyangcalab.hanyang.ac.kr/courses/CG_taesoo/14_2_rigidbody.pdf · Rigid Bodies Rigid bodies have both a position and orientation Rigid bodies assume no object

Linear momentum of a particle is

Linear Momentum

Linear momentum of a rigid body is then

vp m

dVtt )()( rP

density

integration over the body

Page 16: Rigid Body Dynamics - Hanyangcalab.hanyang.ac.kr/courses/CG_taesoo/14_2_rigidbody.pdf · Rigid Bodies Rigid bodies have both a position and orientation Rigid bodies assume no object

Linear momentum can be simplified as follows

Linear Momentum

dVtt )()( rP

dVtttt ))()(()()( xrωvP

)()( tMt vP

Assuming constant mass gives

)()( tt FP )()( tMt vP Just as if body were a particle with

mass M and velocity v(t)

Page 17: Rigid Body Dynamics - Hanyangcalab.hanyang.ac.kr/courses/CG_taesoo/14_2_rigidbody.pdf · Rigid Bodies Rigid bodies have both a position and orientation Rigid bodies assume no object

Linear momentum can be simplified as follows

Linear Momentum

dVtt )()( rP

dVtttt ))()(()()( xrωvP

)()( tMt vP

Assuming constant mass gives

)()( tt FP )()( tMt vP

This term vanishes because of the definition of COM

Page 18: Rigid Body Dynamics - Hanyangcalab.hanyang.ac.kr/courses/CG_taesoo/14_2_rigidbody.pdf · Rigid Bodies Rigid bodies have both a position and orientation Rigid bodies assume no object

Angular momentum of a rigid body

Angular Momentum

)()()( ttt ωIL

Taking the time derivative

)()( tt τL

inertia tensor

Angular momentum is conserved when there is no torque

Page 19: Rigid Body Dynamics - Hanyangcalab.hanyang.ac.kr/courses/CG_taesoo/14_2_rigidbody.pdf · Rigid Bodies Rigid bodies have both a position and orientation Rigid bodies assume no object

Describes how mass is distributed in the body

Inertia Tensor

zzzyzx

yzyyyx

xzxyxx

III

III

III

t)(I

dVzyI xx )ˆˆ( 22

Analogous to mass in linear velocity- rotational mass

Measures the preferred axis of rotation

Expensive to compute this at every time step

dVyxI xy )ˆˆ(

sscenterOfMaxxx ˆ

Page 20: Rigid Body Dynamics - Hanyangcalab.hanyang.ac.kr/courses/CG_taesoo/14_2_rigidbody.pdf · Rigid Bodies Rigid bodies have both a position and orientation Rigid bodies assume no object

Rewrite the tensor as

Inertia Tensor

dVttttt T

))(̂)(̂)(̂)(̂()( rrIrrI

Integrals can now be precomputed

dVttt TTT

))())((()( 0000 RrrIrrRI

)()()( ttt T

body RIRI

dVttttt TT

)))(()()())((()( 0000 rRrRIrRrRI

Page 21: Rigid Body Dynamics - Hanyangcalab.hanyang.ac.kr/courses/CG_taesoo/14_2_rigidbody.pdf · Rigid Bodies Rigid bodies have both a position and orientation Rigid bodies assume no object

Outline

• Rigid Body Preliminaries

• State and Evolution

– Variables and derivatives

• Quaternions

• Collision Detection and Contact Determination

• Colliding Contact Response

Page 22: Rigid Body Dynamics - Hanyangcalab.hanyang.ac.kr/courses/CG_taesoo/14_2_rigidbody.pdf · Rigid Bodies Rigid bodies have both a position and orientation Rigid bodies assume no object

New State Space

v(t) replaced by linear momentum P(t)

(t) replaced by angular momentum L(t)

Size of the vector: (3+9+3+3)N = 18N

Spatial information

Velocity information

Page 23: Rigid Body Dynamics - Hanyangcalab.hanyang.ac.kr/courses/CG_taesoo/14_2_rigidbody.pdf · Rigid Bodies Rigid bodies have both a position and orientation Rigid bodies assume no object

Taking the Derivative

Conservation of momentum (P(t), L(t)) lets us express the accelerations in terms of forces and torques.

Discretize these continuous equations and integrate

Page 24: Rigid Body Dynamics - Hanyangcalab.hanyang.ac.kr/courses/CG_taesoo/14_2_rigidbody.pdf · Rigid Bodies Rigid bodies have both a position and orientation Rigid bodies assume no object

Simulate: next state computation

• From X(t) certain quantities are computedI-1(t) = R(t) Ibody

-1 RT(t) v(t) = P(t) / Mω(t) = I-1(t) L(t)

• We must be content with a finite number of discrete time points

• Use your favorite ODE solver to solve for the new state X(t), given previous state X(t-t) and applied forces F(t) and (t)

X(t) = Solver::Step(X(t- t), F(t), (t))

Page 25: Rigid Body Dynamics - Hanyangcalab.hanyang.ac.kr/courses/CG_taesoo/14_2_rigidbody.pdf · Rigid Bodies Rigid bodies have both a position and orientation Rigid bodies assume no object

Simple simulation algorithm

X = InitializeState()

For t=t0 to tfinal with step t

ClearForces(F(t), (t))

AddExternalForces(F(t), (t))

Xnew =Solver::Step(X, F(t), (t))

X =Xnew

t = t + t

End for

Page 26: Rigid Body Dynamics - Hanyangcalab.hanyang.ac.kr/courses/CG_taesoo/14_2_rigidbody.pdf · Rigid Bodies Rigid bodies have both a position and orientation Rigid bodies assume no object

Outline

• Rigid Body Preliminaries

• State and Evolution

• Collision Detection and Contact Determination– Contact classification

– Intersection testing, bisection, and nearest features

• Colliding Contact Response

Page 27: Rigid Body Dynamics - Hanyangcalab.hanyang.ac.kr/courses/CG_taesoo/14_2_rigidbody.pdf · Rigid Bodies Rigid bodies have both a position and orientation Rigid bodies assume no object

)( 3tx

)( 2tx

What should we do when there is a collision?

Collisions and Contact

)( 0tx

)( 1tx

Page 28: Rigid Body Dynamics - Hanyangcalab.hanyang.ac.kr/courses/CG_taesoo/14_2_rigidbody.pdf · Rigid Bodies Rigid bodies have both a position and orientation Rigid bodies assume no object

Restart the simulation at the time of the collision

Rolling Back the Simulation

Collision time can be found by bisection, etc.

)( 3tx

)( 2tx

)( 0tx

)( 1tx

)( ctx

Page 29: Rigid Body Dynamics - Hanyangcalab.hanyang.ac.kr/courses/CG_taesoo/14_2_rigidbody.pdf · Rigid Bodies Rigid bodies have both a position and orientation Rigid bodies assume no object

Exploit coherency through witnessing

Collision Detection

Speed up with bounding boxes, grids, hierarchies, etc.

separating plane

Two convex objects are non-penetrating iff there exists aseparating plane between them

First find a separating plane andsee if it is still valid after the

nextsimulation step

Page 30: Rigid Body Dynamics - Hanyangcalab.hanyang.ac.kr/courses/CG_taesoo/14_2_rigidbody.pdf · Rigid Bodies Rigid bodies have both a position and orientation Rigid bodies assume no object

Conditions for collision

Collision Detection

N

A

B

ba pp

N

A

B

ba pp

N

A

Bba pp

))()(()()()( ttttt aaaaa xpωvp

0))()(( tt ba ppN 0))()(( tt ba ppN 0))()(( tt ba ppN

separating contact colliding

Page 31: Rigid Body Dynamics - Hanyangcalab.hanyang.ac.kr/courses/CG_taesoo/14_2_rigidbody.pdf · Rigid Bodies Rigid bodies have both a position and orientation Rigid bodies assume no object

Soft Body Collision

Collision

Force is applied to prevent interpenetration

Page 32: Rigid Body Dynamics - Hanyangcalab.hanyang.ac.kr/courses/CG_taesoo/14_2_rigidbody.pdf · Rigid Bodies Rigid bodies have both a position and orientation Rigid bodies assume no object

Soft Body Collision

Collision

Apply forces and change the velocity

Page 33: Rigid Body Dynamics - Hanyangcalab.hanyang.ac.kr/courses/CG_taesoo/14_2_rigidbody.pdf · Rigid Bodies Rigid bodies have both a position and orientation Rigid bodies assume no object

Harder Collision

Collision

Higher force over a shorter time

Page 34: Rigid Body Dynamics - Hanyangcalab.hanyang.ac.kr/courses/CG_taesoo/14_2_rigidbody.pdf · Rigid Bodies Rigid bodies have both a position and orientation Rigid bodies assume no object

Rigid Body Collision

Collision

Impulsive force produces a discontinuous velocity

Page 35: Rigid Body Dynamics - Hanyangcalab.hanyang.ac.kr/courses/CG_taesoo/14_2_rigidbody.pdf · Rigid Bodies Rigid bodies have both a position and orientation Rigid bodies assume no object

We need to change velocity instantaneously

Impulse

Infinite force in an infinitesimal time

tFJ

JP M

Jv

An impulse changes the velocity as

or

Page 36: Rigid Body Dynamics - Hanyangcalab.hanyang.ac.kr/courses/CG_taesoo/14_2_rigidbody.pdf · Rigid Bodies Rigid bodies have both a position and orientation Rigid bodies assume no object

An impulse also creates an impulsive torque

Impulse

The impulsive torque changes the angular velocity

Jxpτ ))()(( ttimpulse

impulseτL impulset τIω )(1 or

Page 37: Rigid Body Dynamics - Hanyangcalab.hanyang.ac.kr/courses/CG_taesoo/14_2_rigidbody.pdf · Rigid Bodies Rigid bodies have both a position and orientation Rigid bodies assume no object

For a frictionless collision

Impulse

But how do we calculate ?

NJ j

j

N

A

B

aJ

bJ

Page 38: Rigid Body Dynamics - Hanyangcalab.hanyang.ac.kr/courses/CG_taesoo/14_2_rigidbody.pdf · Rigid Bodies Rigid bodies have both a position and orientation Rigid bodies assume no object

For a frictionless collision

Impulse

Given this equation and knowing how affects thelinear and angular velocities of the two bodies,we can solve for

)))()((())()(( ttttbaba

ppNppN

j

j

.̂.̂.̂ .̂

Page 39: Rigid Body Dynamics - Hanyangcalab.hanyang.ac.kr/courses/CG_taesoo/14_2_rigidbody.pdf · Rigid Bodies Rigid bodies have both a position and orientation Rigid bodies assume no object

Bodies are neither colliding nor separating

Resting Contact

We want a force strong enough to resistpenetration but only enough to maintain contact

Page 40: Rigid Body Dynamics - Hanyangcalab.hanyang.ac.kr/courses/CG_taesoo/14_2_rigidbody.pdf · Rigid Bodies Rigid bodies have both a position and orientation Rigid bodies assume no object

We want to prevent interpenetration

Resting Contact

0))()(()( tttd ba ppN

Since we should keep it from decreasing

0)( ctd

0))()(())()(()( tttttd baba ppNppN

Since we should keep it from decreasing

0)( ctd

0))()((2))()(()( cbcacbcac tttttd ppNppN

Describes the objects’ acceleration towards one another

Page 41: Rigid Body Dynamics - Hanyangcalab.hanyang.ac.kr/courses/CG_taesoo/14_2_rigidbody.pdf · Rigid Bodies Rigid bodies have both a position and orientation Rigid bodies assume no object

Contact forces only act in the normal direction

Resting Contact

Contact forces should

)( cc tf NF

0)( ctd avoid interpenetration

0f be repulsive

0)( ctdf workless force

become zero if the bodies begin to separate

Page 42: Rigid Body Dynamics - Hanyangcalab.hanyang.ac.kr/courses/CG_taesoo/14_2_rigidbody.pdf · Rigid Bodies Rigid bodies have both a position and orientation Rigid bodies assume no object

The relative accelerations can be written in termsof all of the contact forces

Resting Contact

innci bfafatd ...)( 00

So we can simply solve a Quadratic Program tofind the solution to all the constraints

Page 43: Rigid Body Dynamics - Hanyangcalab.hanyang.ac.kr/courses/CG_taesoo/14_2_rigidbody.pdf · Rigid Bodies Rigid bodies have both a position and orientation Rigid bodies assume no object

Algorithm with collisions and contact

Simulation Algorithm

compute new state

detect collisions and backtrack

compute and apply impulses

compute and apply constraint forces

current state

next state

collision state

post-collision state