Date post: | 20-Dec-2015 |
Category: |
Documents |
View: | 213 times |
Download: | 0 times |
1cs533d-winter-2005
NotesNotes
Assignment 2 going okay?• Make sure you understand what needs to be
done before the weekend Read Guendelman et al, “Nonconvex rigid
bodies with stacking”, SIGGRAPH’03 Mistake last class:
(forgot a transposein calculating torque)
€
ST Fext = δX *T − x i
*T ⎛ ⎝ ⎜
⎞ ⎠ ⎟ f i
i
∑
=f ii
∑x i − X( )
i∑ × f i
⎛
⎝ ⎜ ⎜
⎞
⎠ ⎟ ⎟
= Fτ ⎛ ⎝ ⎜ ⎞
⎠ ⎟
2cs533d-winter-2005
Inertia Tensor SimplifiedInertia Tensor Simplified
Reduce expense of calculating I(t):
• Now use xi-X=Rpi and use RTR=
€
I(t) = mi x i − X( )∗T
x i − X( )∗
i∑
= mi x i − X( )T
x i − X( )δ − x i − X( ) x i − X( )T
[ ]i∑
€
I(t) = mi piT RT Rpiδ − Rpi pi
T RT[ ]
i∑
= R mi piT piδ − pi pi
T( )
i∑( )
Ibody
1 2 4 4 4 3 4 4 4 RT
3cs533d-winter-2005
Inertia Tensor Simplified 2Inertia Tensor Simplified 2
So just compute inertia tensor once, for object space configuration
Then I(t)=RIbodyRT
And I(t)-1=R(Ibody)-1RT
• So precompute inverse too In fact, since I is symmetric, know we have an
orthogonal eigenbasis Q Rotate object-space orientation by Q
• Then Ibody is just diagonal!
4cs533d-winter-2005
Degenerate Inertia Degenerate Inertia TensorsTensors
Inertia tensor can always be inverted unless all the points of the object line up (object is a rod)• Or there’s only one point
We don’t care though, since we can’t track rotation around that axis anyways• So diagonalize I, and only invert nonzero elements
5cs533d-winter-2005
Taking the limitTaking the limit
Letting our decomposition of the object into point masses go to infinity:• Instead of sum over particles,
integral over object volume• Instead of particle mass,
density at that point in space
€
mi foo(x i) → ρ(x)x
∫∫∫i
∑ foo(x)dx
6cs533d-winter-2005
Computing Inertia TensorsComputing Inertia Tensors
Do the integrals: Lots of “fun” You may just want to look them up instead
• E.g. Eric Weisstein’s World of Science on the web If not…. align axis perpendicular to planes of
symmetry (of ) in object space• Guarantees some off-diagonal zeros
Example: sphere, uniform density, radius R
€
Ibody = ρ pT pδ − ppT( )dp
p
∫∫∫
€
25 MR2 0 0
0 25 MR2 0
0 0 25 MR2
⎛
⎝
⎜ ⎜ ⎜
⎞
⎠
⎟ ⎟ ⎟
7cs533d-winter-2005
Approximating Inertia Approximating Inertia TensorsTensors
For complicated geometry, don’t really need exact answer
Could just take the inertia tensor from a simpler geometric figure (will anyone notice?)
Or numerically approximate integral• If we can afford to spend a lot of time precomputing,
life is simple• Grid approach: sample density…• Monte Carlo approach: random samples
8cs533d-winter-2005
Combining ObjectsCombining Objects
What if object is union of two simpler objects? Integrals are additive
• But DO NOT USE I1(t)+I2(t): World-space formulas (x-X) use the X for the object: X1 and
X2 may be different Simplified Ibody formula based on having centre of mass at
origin
• Let’s work it out from the integral of I(t) Combined mass: M=M1+M2
Centre of mass of combined object:
€
X =ρx
Ω1∪Ω 2∫
ρΩ1∪Ω 2
∫=
M1X1 + M2X2
M
9cs533d-winter-2005
Combined Inertia TensorCombined Inertia Tensor
€
I(t) = ρ x − X( )∗T
x − X( )∗
Ω1∪Ω 2∫
= ρ x − X1 + X1 − X( )∗T
x − X1 + X1 − X( )∗
Ω1∫ + L
Ω 2∫
= ρ x − X1( )∗T
x − X1( )∗
Ω1∫ + ρ X1 − X( )
∗Tx − X1( )
∗
Ω1∫
+ ρ x − X1( )∗T
X1 − X( )∗
Ω1∫ + ρ X1 − X( )
∗TX1 − X( )
∗+ L
Ω 2∫
Ω1∫
= I1(t) + X1 − X( )∗T
ρ x − X1( )∗
Ω1∫
01 2 4 4 3 4 4
+ ρ x − X1( )∗T
Ω1∫
01 2 4 4 3 4 4
X1 − X( )∗
+ M1 X1 − X( )∗T
X1 − X( )∗
+ LΩ 2
∫= I1(t) + M1 X1 − X( )
∗TX1 − X( )
∗+ I2(t) + M2 X2 − X( )
∗TX2 − X( )
∗
10cs533d-winter-2005
Numerical IntegrationNumerical Integration
Recall equations of motion
X and V is just like particle motion Angular components trickier:
R must remain orthogonal, but standard integration will cause it to drift• Can use Gram-Schmidt, but expensive and biased€
ddt V = F
Mddt L = Τ
ddt X = V ω = I(t)−1L
ddt R = ω∗R
11cs533d-winter-2005
Improving on RImproving on R
Instead of 9 numbers for 3 DOF, use a less redundant representation
Euler angles: 3 numbers• But updating with angular velocity is painful
Quaternions: 4 numbers
12cs533d-winter-2005
What are quaternions?What are quaternions?
Instead of R, use q=(s,x,y,z) with |q|=1• Can think of q as a “super complex number”
s+xi+yj+zk• i2=j2=k2=-1, ij=-ji=k, jk=-kj=i, ki=-ik=j
• Quaternions don’t commute! q1q2≠q2q1 in general Represents “half” a rotation:
• s=cos(/2)• |x,y,z|2=sin2(/2)• Axis of rotation is (x,y,z)
Conjugate (inverse for unit norm) is
€
q = (s,−x,−y,−z)
13cs533d-winter-2005
Rotating with quaternionsRotating with quaternions
Instead of Rp, calculate Composing a rotation of ∆t to advance a time step:
For small ∆t approximate:
From this get the differential equation:
€
q(0, p)q
€
qn +1 = cosΔtω
2, sinΔt
ω
2
ω
ω
⎛
⎝ ⎜
⎞
⎠ ⎟qn
€
qn +1 = 1, Δtω
2
⎛
⎝ ⎜
⎞
⎠ ⎟qn = qn + Δt
(0,ω)
2qn
€
˙ q = 12 (0,ω)q
14cs533d-winter-2005
Integrating RotationIntegrating Rotation
Can update like Symplectic Euler, but need to renormalize q after each step
For reasonable accuracy, limit time step according to rate of rotation• Don’t try for more than a quarter turn per time
step, say• Stability is not an issue due to renormalization
For more accurate methods, see S. R. Buss, “Accurate and efficient simulation of rigid body rotations”, JCP 2000
15cs533d-winter-2005
Converting q to RConverting q to R
Clearly superior to use quaternions for storing and updating orientation
But, slightly faster to transform points with rotation matrix
If you need to transform a lot of points (collision detection…) may want to convert q into R
Basic idea: columns of R are rotated axes R(1,0,0)T, R(0,1,0)T, and R(0,0,1)T
Do the rotation with q instead.• Can simplify and optimize for the zeros - look it up
16cs533d-winter-2005
GravityGravity
Force on a point is mig Net force:
Net torque:
€
F = mig = Mgi
∑
€
τ = x i − X( ) × migi
∑
= mix i
i
∑ ⎛
⎝ ⎜
⎞
⎠ ⎟− MX
⎛
⎝ ⎜ ⎜
⎞
⎠ ⎟ ⎟× g
= 0
17cs533d-winter-2005
Collision ImpulsesCollision Impulses
Can use same collision detection as deformable objects• Since geometry is fixed, may be cheaper• E.g. can use level set approximation to geometry
But applying collision impulses is more complicated than for simple particles• Need to take into account angular motion too
Use same principle though for the colliding points• What is the impulse that causes their relative velocity
to change as desired?
18cs533d-winter-2005
Frictionless impulseFrictionless impulse
Object velocities at point:• vi=i(x-Xi)+Vi
Relative velocity v=v1-v2
• Normal component vn=v•n Want post-collision relative normal velocity to be
vnafter=-vn
Apply an impulse j=jnn in the normal direction to achieve this
€
Viafter = Vi + M i
−1 ji
Liafter = Li + x − X i( ) × ji
ωiafter = ωi + Ii(t)
−1 x − X i( ) × ji
ji = (−1)i+1 jnn
19cs533d-winter-2005
Computing frictionless Computing frictionless impulseimpulse
€
K i =1
M i
δ + x − X i( )∗T
Ii−1 x − X i( )
∗
€
j =− 1+ ε( )vn
nT K1 + K2( )nn
20cs533d-winter-2005
Computing frictionComputing friction
Static friction valid only in “friction cone”
Approach:• Calculate static friction impulse (whatever it
takes to make relative velocity zero)• Check if it’s in the friction cone• If so, we’re done• If not, try again with sliding
€
jT ≤ μ jn
21cs533d-winter-2005
Computing static frictionComputing static friction
€
v after = −εvnn
€
j = K1 + K2( )−1
−v −εvnn( )
22cs533d-winter-2005
Sliding frictionSliding friction
If computed static friction impulse fails friction cone test
We’ll assume sliding direction stays constant during impact: tangential impulse just in the initial relative velocity direction• Not true in some situations…
23cs533d-winter-2005
Computing sliding frictionComputing sliding friction
€
T =v − vnn
v − vnn
€
j = jnn − μjnT
€
jn =− 1+ ε( )vn
nT K1 + K2( )(n − μT)
24cs533d-winter-2005
Rigid Collision AlgorithmsRigid Collision Algorithms
Use the same collision response algorithm as with particles• Identify colliding points as perhaps the deepest
penetrating points, or the first points to collide• Make sure they are colliding, not separating!
Problem: multiple contact points• Fixing one at a time can cause rattling.• Can fix by being more gentle in resolving contacts -
negative coefficient of restitution Problem: multiple collisions (stacks)
• Fixing one penetration causes others• Solve either by resolving simultaneously
or enforcing order of resolution