Lecture 7 - Rigid Body Dynamics
Download
Report
Transcript Lecture 7 - Rigid Body Dynamics
CS274: Computer Animation and Simulation
Lecture VII
Rigid Body Dynamics
CS274 Spring 01 Lecture 7
Copyright © Mark Meyer
Rigid Bodies
Rigid bodies have both a position and orientation
Rigid bodies assume no object deformation
Rigid body motion is represented by 2 parameters
x(t ) - center of mass
R (t ) - orientation (rotation matrix)
CS274 Spring 01 Lecture 7
Copyright © Mark Meyer
Rigid Bodies
Objects are defined in body space and transformed
by the position and orientation into world space
p(t ) R(t ) p 0 x(t )
CS274 Spring 01 Lecture 7
Copyright © Mark Meyer
Linear Velocity
The change of the center of mass over time
x (t ) v (t )
For a pure translation ( R (t ) constant), all points
move with velocity v (t )
CS274 Spring 01 Lecture 7
Copyright © Mark Meyer
Angular Velocity
The change in orientation over time
ω(t )
Encodes both the axis and speed of the rotation
direction encodes the axis
magnitude encodes the speed (rad/s)
But, how are ω(t ) and R (t ) related?
CS274 Spring 01 Lecture 7
Copyright © Mark Meyer
Angular Velocity
ω
For a given vector
r (t ) ω(t ) r (t )
r
The columns of R (t ) represent the transformed axes
(t ) ω(t ) R (t )
R
.j
.j
e2
R. 2
R.1
e1
e3
CS274 Spring 01 Lecture 7
R. 3
Copyright © Mark Meyer
Angular Velocity
We can represent the cross product with a matrix
0
a b a b ax
a y
*
az
0
az
ax b
0
ay
Therefore
*
R(t ) ω (t ) R(t )
CS274 Spring 01 Lecture 7
Copyright © Mark Meyer
Velocity of a Point
Since a point can be represented at any time by
r(t ) R(t ) r0 x(t )
Total velocity can then be expressed as
(t ) r v(t )
r (t ) R
0
Which can be rewritten as
r (t ) ω* R (t ) r0 v(t )
r (t ) ω (r (t ) x(t )) v(t )
CS274 Spring 01 Lecture 7
Copyright © Mark Meyer
Force
We can apply forces to the object at any point
F2 (t )
F1 (t )
Total force on an object is simply
F(t ) Fi (t )
No information about where the forces are applied
CS274 Spring 01 Lecture 7
Copyright © Mark Meyer
Torque
Torque describes the “rotational force”
τ i (t ) (ri (t ) x(t )) Fi (t )
x(t )
F2 (t )
r1 (t )
F1 (t )
Total torque on an object is simply
τ(t ) τ i (t ) (ri (t ) x(t )) Fi (t )
Tells us about the force distribution over the object
CS274 Spring 01 Lecture 7
Copyright © Mark Meyer
Linear Momentum
Linear momentum of a particle is
pmv
Linear momentum of a rigid body is then
P (t ) r (t ) dV
density
integration over the body
CS274 Spring 01 Lecture 7
Copyright © Mark Meyer
Linear Momentum
Linear momentum can be simplified as follows
P (t ) r (t ) dV
P(t ) v(t ) ω (r (t ) x(t )) dV
P(t ) M v(t )
Assuming constant mass gives
P (t ) M v (t )
P (t ) F(t )
CS274 Spring 01 Lecture 7
Copyright © Mark Meyer
Angular Momentum
Angular momentum of a rigid body
L(t ) I(t ) ω(t )
inertia tensor
Taking the time derivative
(t ) τ(t )
L
Angular momentum is conserved for no torque
CS274 Spring 01 Lecture 7
Copyright © Mark Meyer
Inertia Tensor
Describes how mass is distributed in the body
I xx
I (t) I yx
I zx
I xy
I yy
I zy
I xz
I yz
I zz
I xx ( yˆ 2 zˆ 2 ) dV
I xy ( xˆyˆ ) dV
xˆ x xcen terOfMass
Analogous to mass in linear velocity
Measures the preferred axis of rotation
Expensive to compute this at every time step
CS274 Spring 01 Lecture 7
Copyright © Mark Meyer
Inertia Tensor
Rewrite the tensor as
T
ˆ
ˆ
ˆ
ˆ
I (t ) (r (t ) r (t ) Id r (t ) r (t ) ) dV
I (t ) (( R (t )r0 )T R (t )r0 Id R (t )r0 (R (t )r0 )T ) dV
I (t ) (R (t )(r0 r0 Id r0r0 )R T (t )) dV
T
T
I(t ) R(t ) I body R (t )
T
Integrals can now be precomputed
CS274 Spring 01 Lecture 7
Copyright © Mark Meyer
Rigid Body Equations of Motion
Combining the equations
x(t )
R (t )
d
dt P(t )
L(t )
v (t )
ω* R (t )
F (t )
τ (t )
Discretize these continuous equations and integrate
CS274 Spring 01 Lecture 7
Copyright © Mark Meyer
Using Quaternions
Use quaternions to represent orientation
cos( / 2)
q(t )
sin( / 2) axis
The update rule is then
1
q (t ) ω(t ) q(t )
2
CS274 Spring 01 Lecture 7
Copyright © Mark Meyer
Rigid Body Equations of Motion
Using quaternions gives
x(t )
q(t )
d
dt P (t )
L(t )
v (t )
1 ω q(t )
2
F (t )
τ (t )
Discretize these continuous equations and integrate
CS274 Spring 01 Lecture 7
Copyright © Mark Meyer
Collisions and Contact
So far, no interaction between rigid bodies
Collision detection –
determining if, when and where a collision occurs
Collision response –
calculating the state (velocity, …) after the collision
CS274 Spring 01 Lecture 7
Copyright © Mark Meyer
Collisions and Contact
What should we do when there is a collision?
x(t0 )
x(t1 )
x(t2 )
x(t3 )
CS274 Spring 01 Lecture 7
Copyright © Mark Meyer
Rolling Back the Simulation
Restart the simulation at the time of the collision
x(t0 )
x(t1 )
x(t2 )
x(tc )
x(t3 )
Collision time can be found by bisection, etc.
CS274 Spring 01 Lecture 7
Copyright © Mark Meyer
Collision Detection
Exploit coherency through witnessing
Two convex objects are
non-penetrating iff there exists a
separating plane between them
separating plane
First find a separating plane and
see if it is still valid after the next
simulation step
Speed up with bounding boxes, grids, hierarchies, etc.
CS274 Spring 01 Lecture 7
Copyright © Mark Meyer
Collision Detection
Conditions for collision
p a (t ) v a (t ) ωa (t ) (p a (t ) x a (t ))
A
p a p b
N
A
N
B
N (p a (t ) p b (t )) 0
separating
CS274 Spring 01 Lecture 7
A
p a p b
N
B
N (p a (t ) p b (t )) 0
contact
B
p a p b
N (p a (t ) p b (t )) 0
colliding
Copyright © Mark Meyer
Collision
Soft Body Collision
Force is applied to prevent interpenetration
CS274 Spring 01 Lecture 7
Copyright © Mark Meyer
Collision
Soft Body Collision
Apply forces and change the velocity
CS274 Spring 01 Lecture 7
Copyright © Mark Meyer
Collision
Harder Collision
Higher force over a shorter time
CS274 Spring 01 Lecture 7
Copyright © Mark Meyer
Collision
Rigid Body Collision
Impulsive force produces a discontinuous velocity
CS274 Spring 01 Lecture 7
Copyright © Mark Meyer
Impulse
We need to change velocity instantaneously
Infinite force in an infinitesimal time
J F t
An impulse changes the velocity as
J
v
M
CS274 Spring 01 Lecture 7
or
P J
Copyright © Mark Meyer
Impulse
An impulse also creates an impulsive torque
τ impulse (p(t ) x(t )) J
The impulsive torque changes the angular velocity
1
ω I (t ) τ impulse
CS274 Spring 01 Lecture 7
or
L τ impulse
Copyright © Mark Meyer
Impulse
For a frictionless collision
J jN
A Ja
N
B
Jb
But how do we calculate j ?
CS274 Spring 01 Lecture 7
Copyright © Mark Meyer
Impulse
For a frictionless collision
N (p a (t ) p b (t )) (N (p a (t ) p b (t )))
Given this equation and knowing how j affects the
linear and angular velocities of the two bodies,
we can solve for j
.̂
CS274 Spring 01 Lecture 7
.̂
.̂
Copyright © Mark Meyer
.̂
Resting Contact
Bodies are neither colliding nor separating
We want a force strong enough to resist
penetration but only enough to maintain contact
CS274 Spring 01 Lecture 7
Copyright © Mark Meyer
Resting Contact
We want to prevent interpenetration
d (t ) N (p a (t ) pb (t )) 0
Since d (tc ) 0 we should keep it from decreasing
(p (t ) p (t )) N (p (t ) p (t )) 0
d (t ) N
a
b
a
b
Since d (tc ) 0 we should keep it from decreasing
(p (t ) p (t )) 0
a (tc ) p
b (tc )) 2 N
d(tc ) N (p
a c
b c
Describes the objects’ acceleration towards one another
CS274 Spring 01 Lecture 7
Copyright © Mark Meyer
Resting Contact
Contact forces only act in the normal direction
Fc f N(tc )
Contact forces should
avoid interpenetration
d(tc ) 0
be repulsive
f 0
become zero if the bodies begin to separate
f d(tc ) 0
CS274 Spring 01 Lecture 7
workless force
Copyright © Mark Meyer
Resting Contact
The relative accelerations can be written in terms
of all of the contact forces
di (tc ) a0 f 0 ... an f n bi
So we can simply solve a Quadratic Program to
find the solution to all the constraints
CS274 Spring 01 Lecture 7
Copyright © Mark Meyer
Simulation Algorithm
Algorithm with collisions and contact
current state
compute new state
next state
detect collisions and backtrack
collision state
compute and apply impulses
post-collision state
compute and apply constraint forces
CS274 Spring 01 Lecture 7
Copyright © Mark Meyer