Rigid body simulation

Rigid body simulation Once we consider an object with spacial extent, particle system simulation is no longer sufficient

Problems Problems

Unconstrained system

rotational

and angular Performance is important! Constrained system

collision detection

contact points and Problems Particle simulation

x(t) Y(t) = in phase ! v(t) "

v(t) Y˙ (t) = in phase space ! f(t)/m " Control is everything!

Rigid body concepts Position and

Translation of the body x   x(t) = y Position Orientation  z  Linear velocity tensor tensor Rotation of the body Linear momentum rxx ryx rzx   R(t) = rxy ryy rzy  rxz ryz rzz 

x(t) and R ( t ) are called spacial variables of a rigid body Body space Position and orientation

Body space Body space World space

y0 A fixed and unchanged space

where the shape of a rigid body is r0i y0 y0 R(t) defined

r0i r0i z0 x0 The geometric center of the rigid y x t x0 body lies at the origin of the x0 ( ) body space z z 0 0 z x

Position and orientation Position and orientation

Given a geometric description of the World space Let’s assume the rigid body has uniform density, what is body in body space, we can use x(t) the physical meaning of x(t)? and R(t) to transform the body space y0 description into world space

R(t) r0i How do we compute the world coordinate of an arbitrary z0 x0 r0i on the body? y x t ( ) What is the physical meaning of R(t)? ri(t) = x(t) + R(t)r0i

z x Position and Orientation Position and orientation

Consider the x-axis in body space, (1, 0, 0), what is the direction of this vector in world space at t?

So x(t) and R(t) define the position and the 1 rxx     R(t) 0 = rxy orientation of the body a time t  0   rxz  Next we need to define how the position and which is the first column of R(t) orientation change over time

R(t) represents the directions of x, y, and z axes of the rigid body in world space at time t

Linear velocity Angular velocity

Since x ( t ) is the position of the in world space, x˙ ( t ) is the velocity of the center of mass in world space Imagine that we freeze the position of the COM in space, then any movement is due to the body v(t) = x˙ (t) spinning about some axis that passes through the COM

Otherwise, the COM would itself be moving Angular velocity Angular velocity

We describe that spin as a vector ω(t) How are R ( t ) and ω ( t ) related?

Direction of ω(t) Hint: Consider a vector r ( t ) at time t specified in world space, how Magnitude of |ω(t)| do we represent r˙ ( t ) in terms of ω(t)

d ω(t) v t x t |r˙(t)| = |b||ω(t)| = |ω(t) × b| Linear velocity and position are related by ( ) = dt ( ) b r˙(t)? r˙(t) = ω(t) × b = ω(t) × b + ω(t) × a a How are R ( t ) and ω ( t ) related? r(t) r˙(t) = ω(t) × r(t) x(t)

Angular velocity Angular velocity

Given the physical meaning of R ( t ) , what does each rxx ryx rzx column of R ˙ ( t ) mean?         R˙ (t) = ω(t) × rxy ω(t) × ryy ω(t) × rzy   rxz   ryz   rzz   At time t, the direction of x-axis of the rigid body in world space is the first column of R(t)

rxx   rxy This is the relation between angular velocity and the r  xz  orientation, but it is too cumbersome At time t, what is the of the first column of R ( t )? (using the rule we just discovered) We can use a trick to simply this expression Angular velocity Angular velocity

Consider two 3 by 1 vectors: a and b, the cross product of rxrxxx ryxryx rzx rzx ˙  ∗×rr  ∗ × r r   ∗ ×r r   them is R(t) = ω(t) xyxy ωω(t()t) yy yy ω(tω)(t) zy zy aybz − byaz rr r r r r     xzxz  yz yz   zz zz   a × b = −axbz + bxaz a b − b a ∗  x y x y  = ω(t) R(t)

Given a, lets define a* to be the matrix

0 −az ay  a 0 −a  z x Vector relation: r˙(t) = ω(t) × r(t)  −ay ax 0  R˙ ω t ∗R t 0 −az ay bx Matrix relation: = ( ) ( ) a∗b =  a 0 −a   b  = a × b then z x y  −ay ax 0   bz 

Perspective of particles Velocity of a particle

Imagine a rigid body is composed of a large number d ∗ r˙(t) = r(t) = ω R(t)r0i + v(t) of small particles dt ∗ = ω (R(t)r0i + x(t) − x(t)) + v(t) the particles are indexed from 1 to N ∗ = ω (ri(t) − x(t)) + v(t) each particle has a constant location r0i in body space

the location of ith particle in world space at time t is

r˙ i(t) = ω × (ri(t) − x(t)) + v(t) ri(t) = x(t) + R(t)r0i angular component linear component Velocity of a particle Mass

The mass of the ith particle is mi r˙ i(t) = ω × (ri(t) − x(t)) + v(t) N M = mi y0 ω(t) Mass ! i=1 ω(t) × (ri(t) − x(t)) r (t) i v(t) x(t) ! miri(t) r˙ i(t) Center of mass in world space M y x z0 v(t) 0

z x What about center of mass in body space?

Center of mass Inertia tensor

Proof that the center of mass at time t in word space is x(t) Inertia tensor describes how the mass of a rigid body is distributed relative to the center of mass ! miri(t) = m r!2 r!2 −m r! r! −m r! r! M i( iy + iz) i ix iy i ix iz  ! !  I −m r! r! r 2 r 2 −m r! r! = i iy ix ( ix + iz) i iy iz ! ! ! i  −m r! r! −m r! r! m r 2 r 2   i iz ix i iz iy i( iy + iz) 

! ri = ri(t) − x(t)

I(t) depends on the orientation of a body, but not the translation

For an actual implementation, we replace the finite sum with = x(t) the integrals over a body’s volume in world space Inertia tensor Force and torque

By using body-space coordinates we can cheaply compute the inertia Fi(t) denotes the total force from external forces acting tensor for any orientation by precomputing integrals in body space on the ith particle at time t m r!2 m r! r! m r! r! 1 0 0 i ix i ix iy i ix iz y0 τ t r t − x t × F t I t m r!T r!   −  m r! r! m r!2 m r! r!  ( ) = ( i( ) ( )) i( ) ( ) = i t 0 1 0 i iy ix i iy i iy iz ! ! ! ! ! !2  0 0 1   mir r mir r mir  iz ix iz iy iz F(t) = ! Fi(t) ri (t) I r!T r! 1 − r! r!T i x(t) (t) = ! mi( i i) i i ) Fi(t)

T T mi R t r0i R t r0i 1 − R t r0i R t r0i τ(t) = (ri(t) − x(t)) × Fi(t) = ! (( ( ) ) ( ( ) ) ( ( ) )( ( ) ) ) ! z0 x0 i T T − T T = ! mi(R(t)(r0ir0i)R(t) 1 R(t)r0ir0iR(t) )

T T T = R(t) mi((r r0i)1 − r0ir ) R(t) y !" 0i 0i #

z x I t R t I R t T I m rT r 1 − r rT ( ) = ( ) body ( ) body = ! i(( 0i 0i) 0i 0i) i

Force and torque Linear momentum

P(t) = ! mir˙i(t) Torque differs from force in that the torque on a particle i depends on the location of the particle relative to the center of m v t ω t × m r t − x t mass = ! i ( ) + ( ) ! i( i( ) ( )) i i F(t) conveys no information about where the various forces = Mv(t) acted on the body, while !(t) contains the information about the distribution of the forces over the body Total linear of the rigid body is the same as if the body was simply a particle with mass M and velocity v(t) Angular momentum Derivative of momentum

Similar to linear momentum, angular momentum is Change in linear momentum is equivalent to the total defined as forces acting on the rigid body

P˙ (t) = Mv˙ (t) = F(t) L(t) = I(t) × ω(t)

The relation between angular momentum and the total L(t) is independent of any translational effects, while P(t) torque is analogous to the linear case is independent of any rotational effects L˙ (t) = τ(t)

Derivative of momentum momentum vs. velocity

L˙ r! × F Proof (t) = τ(t) = ! i i

m r − F m v − r!∗ω − r!∗ω − F 0 i ¨i i = i( ˙ ˙ i i ˙ ) i = Why do we use momentum in the phase space !∗ − !∗ − !∗ − !∗ ! ri mi(v˙ r˙ i ω ri ω˙ ) ! ri Fi = 0 instead of velocity?

!∗ !∗ !∗ !∗ − mir r˙ ω − mir r ω˙ = τ !" i i # !" i i # Because the angular momentum is conserved when there is no external forces acting on the object − r!∗r!∗ r!T r! 1 − r! r!T I ! mi i i = ! mi(( i i) i i ) = (t) We could let linear velocity v(t) be a state variable, but !∗ !∗ − mir r˙ ω + I(t)ω˙ = τ !" i i # using linear momentum P(t) is more consistent with the d way we deal with angular velocity and I˙ t −m r!∗r!∗ −m r!∗r!∗ − m r!∗r!∗ ( ) = dt ! i i i = ! i i ˙ i i ˙ i i d I˙ t ω I t ω I t ω L˙ t τ ( ) + ( ) ˙ = dt( ( ) ) = ( ) = Equation of motion Example:

x(t) position v(t) 1. compute the Ibody in body space  R t  d  ω t ∗R t  Y t ( ) orientation Y t ( ) ( ) ( ) = P t dt ( ) = F t  ( )  linear momentum  ( )  y x0 y0 z0 2 2     , , − y0 + z0 0 0 L t angular momentum τ t ! 2 2 2 " M  2 2   ( )   ( )  Ibody = 0 x0 + z0 0 12 2 2  0 0 x0 + y0 

Constants: M and Ibody x P(t) v(t) = −x0 −y0 z0 M ! 2 , 2 , 2 " z T I(t) = R(t)IbodyR(t)

−1 ω(t) = I(t) L(t)

Example: Example:

1. compute the Ibody in body space 1. compute the Ibody in body space

y 2. rotation free movement y 2. rotation free movement

3. translation free movement

(−3, 0, 2) (−3, 0, 2) (3, 0, 2) x (3, 0, 2) x

F z F z F F Force vs. torque puzzle Notes on implementation

10 sec later Suppose a force F acts on the block at the F F center of mass for 10 seconds. Since there is no torque acting on the block, the body will only acquire linear velocity v after 10 seconds. The 1 MvT v kinetic will be 2 1 Using instead of transformation matrix MvT v energy = 0 energy = 2 more compact representation

Now, consider the same force acting off-center to the body for 10 less numerical drift seconds. Since it is the same force, the velocity of the center of mass after 10 seconds is the same v. However, the block will also pick up 1 1 MvT v + ωT Iω some angular velocity ". The will be 2 2 F If identical forces push the block in both cases, how can the energy energy = 0 of the block be different?