Lecture VII Rigid Body Dynamics CS274: Computer Animation and Simulation.

37

Transcript of Lecture VII Rigid Body Dynamics CS274: Computer Animation and Simulation.

Page 1: Lecture VII Rigid Body Dynamics CS274: Computer Animation and Simulation.
Page 2: Lecture VII Rigid Body Dynamics CS274: Computer Animation and Simulation.

Lecture VII

Rigid Body Dynamics

CS274: Computer Animation and Simulation

Page 3: Lecture VII Rigid Body Dynamics CS274: Computer Animation and Simulation.

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)

Page 4: Lecture VII Rigid Body Dynamics CS274: Computer Animation and Simulation.

Rigid Bodies

Objects are defined in body space and transformed by the position and orientation into world space

)()()( 0 ttt xpRp

Page 5: Lecture VII Rigid Body Dynamics CS274: Computer Animation and Simulation.

Linear Velocity

The change of the center of mass over time

For a pure translation ( constant), all points move with velocity

)()( tt vx

)(tv)(tR

Page 6: Lecture VII Rigid Body Dynamics CS274: Computer Animation and Simulation.

Angular Velocity

The change in orientation over time

Encodes both the axis and speed of the rotation direction encodes the axis magnitude encodes the speed (rad/s)

)(tω

But, how are and related?)(tω )(tR

Page 7: Lecture VII Rigid Body Dynamics CS274: Computer Animation and Simulation.

Angular Velocity

For a given vector

The columns of represent the transformed axes

)()()( ttt rωr

)(tR

)()()( .. ttt jj RωR

1e

2e

3e

1.R2.R

3.R

ω

r

Page 8: Lecture VII Rigid Body Dynamics CS274: Computer Animation and Simulation.

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 9: Lecture VII Rigid Body Dynamics CS274: Computer Animation and Simulation.

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 10: Lecture VII Rigid Body Dynamics CS274: Computer Animation and Simulation.

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 11: Lecture VII Rigid Body Dynamics CS274: Computer Animation and Simulation.

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 12: Lecture VII Rigid Body Dynamics CS274: Computer Animation and Simulation.

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 13: Lecture VII Rigid Body Dynamics CS274: Computer Animation and Simulation.

Linear momentum can be simplified as follows

Linear Momentum

dVtt )()( rP

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

)()( tMt vP

Assuming constant mass gives

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

Page 14: Lecture VII Rigid Body Dynamics CS274: Computer Animation and Simulation.

Angular momentum of a rigid body

Angular Momentum

)()()( ttt ωIL

Taking the time derivative

)()( tt τL

inertia tensor

Angular momentum is conserved for no torque

Page 15: Lecture VII Rigid Body Dynamics CS274: Computer Animation and Simulation.

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

Measures the preferred axis of rotation

Expensive to compute this at every time step

dVyxI xy )ˆˆ(

sscenterOfMaxxx ˆ

Page 16: Lecture VII Rigid Body Dynamics CS274: Computer Animation and Simulation.

Rewrite the tensor as

Inertia Tensor

dVttttt T ))(ˆ)(ˆ)(ˆ)(ˆ()( rrIdrrI

Integrals can now be precomputed

dVttt TTT ))())((()( 0000 RrrIdrrRI

)()()( ttt Tbody RIRI

dVttttt TT )))(()()())((()( 0000 rRrRIdrRrRI

Page 17: Lecture VII Rigid Body Dynamics CS274: Computer Animation and Simulation.

Combining the equations

Rigid Body Equations of Motion

)(

)(

)(

)(

t

t

t

t

dt

d

L

P

R

x

Discretize these continuous equations and integrate

)(

)(

)(

)(*

t

t

t

t

τ

F

v

Page 18: Lecture VII Rigid Body Dynamics CS274: Computer Animation and Simulation.

Use quaternions to represent orientation

Using Quaternions

axisq

)2/sin(

)2/cos()(

t

The update rule is then

)()(2

1)( ttt qωq

Page 19: Lecture VII Rigid Body Dynamics CS274: Computer Animation and Simulation.

Using quaternions gives

Rigid Body Equations of Motion

)(

)(

)(

)(

t

t

t

t

dt

d

L

P

q

x

Discretize these continuous equations and integrate

)(

)(

)(

)(

2

1

t

t

t

t

τ

F

v

Page 20: Lecture VII Rigid Body Dynamics CS274: Computer Animation and Simulation.

So far, no interaction between rigid bodies

Collisions and Contact

Collision detection – determining if, when and where a collision occurs

Collision response – calculating the state (velocity, …) after the collision

Page 21: Lecture VII Rigid Body Dynamics CS274: Computer Animation and Simulation.

)( 3tx

)( 2tx

What should we do when there is a collision?

Collisions and Contact

)( 0tx

)( 1tx

Page 22: Lecture VII Rigid Body Dynamics CS274: Computer Animation and Simulation.

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 23: Lecture VII Rigid Body Dynamics CS274: Computer Animation and Simulation.

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 a separating plane between them

First find a separating plane and see if it is still valid after the next simulation step

Page 24: Lecture VII Rigid Body Dynamics CS274: Computer Animation and Simulation.

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 25: Lecture VII Rigid Body Dynamics CS274: Computer Animation and Simulation.

Soft Body Collision

Collision

Force is applied to prevent interpenetration

Page 26: Lecture VII Rigid Body Dynamics CS274: Computer Animation and Simulation.

Soft Body Collision

Collision

Apply forces and change the velocity

Page 27: Lecture VII Rigid Body Dynamics CS274: Computer Animation and Simulation.

Harder Collision

Collision

Higher force over a shorter time

Page 28: Lecture VII Rigid Body Dynamics CS274: Computer Animation and Simulation.

Rigid Body Collision

Collision

Impulsive force produces a discontinuous velocity

Page 29: Lecture VII Rigid Body Dynamics CS274: Computer Animation and Simulation.

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 30: Lecture VII Rigid Body Dynamics CS274: Computer Animation and Simulation.

An impulse also creates an impulsive torque

Impulse

The impulsive torque changes the angular velocity

Jxpτ ))()(( ttimpulse

impulseτL impulset τIω )(1 or

Page 31: Lecture VII Rigid Body Dynamics CS274: Computer Animation and Simulation.

For a frictionless collision

Impulse

But how do we calculate ?

NJ j

j

N

A

B

aJ

bJ

Page 32: Lecture VII Rigid Body Dynamics CS274: Computer Animation and Simulation.

For a frictionless collision

Impulse

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

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

ppNppN

j

j

.̂.̂.̂ .̂

Page 33: Lecture VII Rigid Body Dynamics CS274: Computer Animation and Simulation.

Bodies are neither colliding nor separating

Resting Contact

We want a force strong enough to resist penetration but only enough to maintain contact

Page 34: Lecture VII Rigid Body Dynamics CS274: Computer Animation and Simulation.

We want to prevent interpenetration

Resting Contact

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

Since we should keep it from decreasing0)( ctd

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

Since we should keep it from decreasing0)( ctd

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

Describes the objects’ acceleration towards one another

Page 35: Lecture VII Rigid Body Dynamics CS274: Computer Animation and Simulation.

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 36: Lecture VII Rigid Body Dynamics CS274: Computer Animation and Simulation.

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

Resting Contact

innci bfafatd ...)( 00

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

Page 37: Lecture VII Rigid Body Dynamics CS274: Computer Animation and Simulation.

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