Rigid Body Dynamics CSE169: Computer Animation Instructor: Steve - - PowerPoint PPT Presentation
Rigid Body Dynamics CSE169: Computer Animation Instructor: Steve - - PowerPoint PPT Presentation
Rigid Body Dynamics CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Spring 2016 Cross Product i j k a b a a a x y z b b b x y z a b a b a b a b a b a b a b
Cross Product
x y y x z x x z y z z y z y x z y x
b a b a b a b a b a b a b b b a a a b a k j i b a
Properties of the Cross Product
Non-commutative:
𝐛 × 𝐜 ≠ 𝐜 × 𝐛
Non-associative:
𝐛 × 𝐜 × 𝐝 ≠ 𝐛 × 𝐜 × 𝐝
Cross Product
z y x x z z z x y x z y z y y z x x x y y x z x x z y z z y
b b a b a c b a b b a c b a b a b c b a b a b a b a b a b a b a c b a
Cross Product
z y x x y x z y z z y x z y x x z z z x y x z y z y y z x x
b b b a a a a a a c c c b b a b a c b a b b a c b a b a b c
Cross Product
ˆ ˆ
x y x z y z z y x x y x z y z z y x
a a a a a a b b b a a a a a a c c c a b a b a
Hat Operator
We’ve introduced the ‘hat’ operator which converts a
vector into a skew-symmetric matrix 𝐛 𝑈 = −𝐛
This allows us to turn a cross product of two vectors into
a dot product of a matrix and a vector
This is mainly for algebraic convenience, as the dot
product is associative (although still not commutative) 𝐛 ∙ 𝐜 = 𝐛 × 𝐜 𝐛 ∙ 𝐜 ≠ 𝐜 ∙ 𝐛 𝐛 ∙ 𝐜 ∙ 𝐝 = 𝐛 ∙ 𝐜 ∙ 𝐝
Derivative of a Rotating Vector
Let’s say that vector r is rotating around the
- rigin, maintaining a fixed distance
At any instant, it has an angular velocity of ω
r ω r dt d r ω
r ω
Derivative of Rotating Matrix
If matrix A is a rigid 3x3 matrix rotating with
angular velocity ω
This implies that the a, b, and c axes must be
rotating around ω
The derivatives of each axis are ωxa, ωxb, and
ωxc, and so the derivative of the entire matrix is:
A ω A ω A ˆ dt d
Product Rule
dt dc ab c dt db a bc dt da dt abc d dt db a b dt da dt ab d
The product rule defines the derivative of
products
Product Rule
It can be extended to vector and matrix products
as well
dt d dt d dt d dt d dt d dt d dt d dt d dt d B A B A B A b a b a b a b a b a b a
Eigenvalue Equation
Lets say we have a known matrix M and we want to know if there is any vector x and scalar s such that
𝐍𝐲 = 𝑡𝐲
This is known as an eigenvalue equation, and for a NxN matrix, there should be up to N eigenvectors 𝐲𝑗 and N eigenvalues 𝑡𝑗 that satisfy the equation
If M is a symmetric matrix (i.e., 𝐍𝑈 = 𝐍) then all of the eigenvalues will be real numbers and the eigenvectors will be real, orthonormal vectors (otherwise, some of the eigenvalues/eigenvectors will be complex)
Symmetric Matrix
If we have a symmetric matrix 𝐍, we can diagonalize it:
𝐍0 = 𝐁𝑈 ∙ 𝐍 ∙ 𝐁
Where 𝐍0 is a diagonal matrix and 𝐁 is an orthonormal (pure rotation) matrix
The columns of 𝐁 are the eigenvectors of 𝐍 and the diagonal elements in 𝐍0 are the corresponding eigenvalues
The symmetric Jacobi algorithm is a simple and effective matrix algorithm for computing this diagonalization
Symmetric Matrix Diagonalization
𝐍 = 𝑁𝑦𝑦 𝑁𝑦𝑧 𝑁𝑦𝑨 𝑁𝑦𝑧 𝑁𝑧𝑧 𝑁𝑧𝑨 𝑁𝑦𝑨 𝑁𝑧𝑨 𝑁𝑨𝑨 𝐍0 = 𝐁𝑈 ∙ 𝐍 ∙ 𝐁 𝑥ℎ𝑓𝑠𝑓 𝐍0 = 𝑁𝑦 𝑁𝑧 𝑁𝑨
Dynamics of Particles
Kinematics of a Particle
- n
accelerati ity veloc position
2 2
dt d dt d dt d x v a x v x
Mass, Momentum, and Force
force momentum mass a p f v p m dt d m m
Moment of Momentum
The moment of momentum is a vector Also known as angular momentum (the two terms mean
basically the same thing, but are used in slightly different situations)
Angular momentum has parallel properties with linear
momentum
In particular, like the linear momentum, angular
momentum is conserved in a mechanical system
It is typically represented with a capital L, which is
unfortunately inconsistent with our standard of using lowercase for vectors…
p r L
Moment of Momentum
p r L
p
1
r
2
r
3
r
p p
L is the same for all three of these particles
Moment of Momentum
p r L
p
1
r
2
r
3
r
p p
L is different for all of these particles
Moment of Force (Torque)
The moment of force (or torque) about a
point is the rate of change of the moment
- f momentum about that point
dt dL τ
Moment of Force (Torque)
f r τ f r v v τ f r p v τ p r p r L τ p r L m dt d dt d dt d
Rotational Inertia
L=rxp is a general expression for the
moment of momentum of a particle
In a case where we have a particle
rotating around the origin while keeping a fixed distance, we can re-express the moment of momentum in terms of it’s angular velocity ω
Rotational Inertia
r r I ω I L ω r r L ω r r r ω r L v r v r L p r L ˆ ˆ ˆ ˆ m m m m m m
Rotational Inertia
2 2 2 2 2 2
ˆ ˆ
y x z y z x z y z x y x z x y x z y x y x z y z x y x z y z
r r r r r r r r r r r r r r r r r r m r r r r r r r r r r r r m m I I r r I
Rotational Inertia
ω I L I
2 2 2 2 2 2 y x z y z x z y z x y x z x y x z y
r r m r mr r mr r mr r r m r mr r mr r mr r r m
Rotational Inertia
The rotational inertia matrix I is a 3x3 matrix that
is essentially the rotational equivalent of mass
It relates the angular momentum of a system to
its angular velocity by the equation
This is similar to how mass relates linear
momentum to linear velocity, but rotation adds additional complexity
ω I L
v p m
Systems of Particles
Systems of Particles
momentum tal to mass
- f
center
- f
position particles all
- f
mass l tota
1
i i i cm i i i cm n i i total
m m m m m v p p x x
Velocity of Center of Mass
cm total cm total cm cm i i i i i i cm i i i cm cm
m m m m m dt d m m m dt d dt d v p p v v x v x x v
Force on a Particle
The change in momentum of the center of mass
is equal to the sum of all of the forces on the individual particles
This means that the resulting change in the total
momentum is independent of the location of the applied force
i i i cm i cm
dt d dt d dt d
f p p p p p
Systems of Particles
i cm i cm i i cm
p x x L p r L
The total moment of momentum around
the center of mass is:
Torque in a System of Particles
i i cm i i cm i i cm cm i i cm
dt d dt d dt d f r τ p r τ p r L τ p r L
Systems of Particles
We can see that a system of particles behaves a lot like
a particle itself
It has a mass, position (center of mass), momentum,
velocity, acceleration, and it responds to forces
We can also define it’s angular momentum and relate a
change in system angular momentum to a force applied to an individual particle
i i cm
f r τ
i cm
f f
Internal Forces
If forces are generated within the particle system
(say from gravity, or springs connecting particles) they must obey Newton’s Third Law (every action has an equal and opposite reaction)
This means that internal forces will balance out
and have no net effect on the total momentum of the system
As those opposite forces act along the same line
- f action, the torques on the center of mass
cancel out as well
Dynamics of Rigid Bodies
Kinematics of a Rigid Body
For the position of the center of mass of the rigid
body:
2 2
dt d dt d dt d
cm cm cm cm cm cm
x v a x v x
Kinematics of a Rigid Body
For the orientation of the rigid body:
𝐁 3x3 orientation matrix 𝛛 angular velocity 𝛛 =
𝑒𝛛 𝑒𝑢
angular acceleration
Rigid Bodies
We treat a rigid body as a system of particles, where the
distance between any two particles is fixed
We will assume that internal forces are generated to
hold the relative positions fixed. These internal forces are all balanced out with Newton’s third law, so that they all cancel out and have no effect on the total momentum
- r angular momentum
The rigid body can actually have an infinite number of
particles, spread out over a finite volume
Instead of mass being concentrated at discrete points,
we will consider the density as being variable over the volume
Rigid Body Mass
With a system of particles, we defined the total
mass as:
For a rigid body, we will define it as the integral
- f the density ρ over some volumetric domain Ω
d m
n i i
m m
1
Rigid Body Center of Mass
The center of mass is:
d d
cm
x x
Rotational Inertia of a Particle
Recall that the rotational inertia for a single
particle of mass m as position r is: 𝐉 = 𝑛 𝑠
𝑧2 + 𝑠 𝑨2
−𝑛𝑠
𝑦𝑠 𝑧
−𝑛𝑠
𝑦𝑠 𝑨
−𝑛𝑠
𝑦𝑠 𝑧
𝑛 𝑠
𝑦2 + 𝑠 𝑨2
−𝑛𝑠
𝑧𝑠 𝑨
−𝑛𝑠
𝑦𝑠 𝑨
−𝑛𝑠
𝑧𝑠 𝑨
𝑛 𝑠
𝑦2 + 𝑠 𝑧2
Rigid Body Rotational Inertia
zz yz xz yz yy xy xz xy xx y x z y z x z y z x y x z x y x z y
I I I I I I I I I d r r d r r d r r d r r d r r d r r d r r d r r d r r I I
2 2 2 2 2 2
Rigid Body Rotational Inertia
The rigid body rotational inertia is a 3x3 symmetric matrix that encodes the distribution of mass around the center of mass
It is calculated by calculating the integrals on the previous slide by integrating over the volume of the rigid body where r indicates the vector from the center of mass to the position of the volume integration element and ρ represents the density at that location
These integrals can be calculated with analytical formulas for simple shapes like spheres, cylinders, and boxes
There also exists an analytical technique for computing them on triangle meshes as well (Mirtich-Eberly algorithm)
Rotational Inertia Diagonalization
As the rotational inertia matrix is symmetric, we can diagonalize it and find the orthonormal matrix A: 𝐉0 = 𝐁𝑈 ∙ 𝐉 ∙ 𝐁
We are essentially finding the orientation for the rigid body such that its rotational inertia matrix is diagonal
When it is rotated into this coordinate system, the x, y, and z axes define the principal axes
Typically, we like to model the rigid body such that it is oriented this way (i.e., in local space, the center of mass is at the origin and the principal axes line up with x, y, and z)
That way, its rotational inertia properties can be represented with three numbers (𝐽𝑦, 𝐽𝑧, and 𝐽𝑨) and the matrix A is the matrix that orients the rigid body into world space
Diagonalization or Rotational Inertia
𝐉 = 𝐽𝑦𝑦 𝐽𝑦𝑧 𝐽𝑦𝑨 𝐽𝑦𝑧 𝐽𝑧𝑧 𝐽𝑧𝑨 𝐽𝑦𝑨 𝐽𝑧𝑨 𝐽𝑨𝑨 𝐉0 = 𝐁𝑈 ∙ 𝐉 ∙ 𝐁 𝑥ℎ𝑓𝑠𝑓 𝐉0 = 𝐽𝑦 𝐽𝑧 𝐽𝑨
Rotational Inertia of a Box
Fox a box of mass m and dimensions a x b x c:
𝐽𝑦 = 𝑛 12 𝑐2 + 𝑑2 𝐽𝑧 = 𝑛 12 𝑏2 + 𝑑2 𝐽𝑨 = 𝑛 12 𝑏2 + 𝑐2
Rotational Inertia of a Sphere
For a solid sphere of mass m and radius r:
𝐽𝑦 = 𝐽𝑧 = 𝐽𝑨 = 2𝑛𝑠2 5
Rotational Inertia
If we have modeled the rigid body such that it
the origin is at the center of mass and the principal axes line up with x, y, and z, then the values of m, 𝐽𝑦, 𝐽𝑧, and 𝐽𝑨 tell us everything we need to know about the mass and its distribution that we need to know
When we orient our rigid body in space with a
matrix A, the rotational inertia matrix 𝐉 in world space is: 𝐉 = 𝐁 ∙ 𝐉0 ∙ 𝐁𝑈
Derivative of Rotational Inertial
ω I I ω I ω I I ω ω A I A I ω I A ω I A I ω I A ω I A A I A ω I A I A A I A A I A I ˆ ˆ ˆ ˆ dt d dt d dt d dt d dt d dt d dt d dt d
T T T T T T T T T
Derivative of Angular Momentum
ω I ω I ω τ ω I ω ω I ω I ω τ ω I ω ω I I ω τ ω I ω I L τ ω I L ˆ ˆ dt d dt d dt d
Newton-Euler Equations
ω I ω I ω τ a f m
Applied Forces & Torques
ω I ω τ I ω f a f r τ f f
1
1 m
i i cg i cg
Properties of Rigid Bodies
a f v p a v x m m m
ω I ω I ω f r τ ω I L ω ω A I
Rigid Body Simulation
RigidBody { void Update(float time); void ApplyForce(Vector3 &f,Vector3 &pos); private: // constants float Mass; Vector3 RotInertia; // Ix, Iy, & Iz from diagonal inertia // variables Matrix34 Mtx; // contains position & orientation Vector3 Momentum,AngMomentum; // accumulators Vector3 Force,Torque; };
Rigid Body Simulation
RigidBody::ApplyForce(Vector3 &f,Vector3 &pos) { Force += f; Torque += (pos-Mtx.d) x f }
Rigid Body Simulation
RigidBody::Update(float time) { // Update position Momentum += Force * time; Mtx.d += (Momentum/Mass) * time; // Mtx.d = position // Update orientation AngMomentum += Torque * time; Matrix33 I = Mtx·I0·MtxT // A·I0·AT Vector3 ω = I-1·L float angle = |ω| * time; // magnitude of ω Vector3 axis = ω; axis.Normalize(); Mtx.RotateUnitAxis(axis,angle); }