Uploaded by gm.ebrahimi

09-rigid-body-contact-final

advertisement
CSC417 Physics-Based Animation
Crysis | Crytek
Last Video: Jointed Rigid Body Systems
Weidner et al | RedMax
This Video: Rigid Body Simulation with Contact
Rigid Body Contact
Rigid Body
Rigid Body Contact
Rigid Body
COLLISION!
Collisions in Simulation
Two phases detection and response
Detection: Did I hit anything ?
Response: I hit something ! What do I do ?
Rigid Body Contact
Rigid Body
COLLISION!
Rigid Body Contact
Contact Normals
Contact Points
n
x
Check if
v
||x
2
c||2
center
r
2
radius
If colliding …
↵=
min 0, nT v
vfiltered = v + ↵n
Rigid Body Contact
R
p
Contact Points
Three Rules of Contact Mechanics
Rigid Body
Contact Point
No interpenetration at contact point
Three Rules of Contact Mechanics
Rigid Body
No interpenetration at contact point
Aside: The Signed Distance
Rigid Body
yA = yB
d
yA = yB
distance
Aside: The Signed Distance
Rigid Body
yA = yB
d
negative distance
yA = yB
Three Rules of Contact Mechanics
Rigid Body
yA = yB
No interpenetration at contact point
Three Rules of Contact Mechanics
Rigid Body
yA = yB
d (yA , yB ) < 0
Three Rules of Contact Mechanics
Rigid Body
yA = yB
d (yA , yB ) 0
No interpenetration at contact point
Three Rules of Contact Mechanics
Rigid Body
fcontact
Contact forces “push” objects apart
Three Rules of Contact Mechanics
Rigid Body
fcontact = ↵n
fcontact
↵2R
↵
Contact forces “push” objects apart
0
Three Rules of Contact Mechanics
Rigid Body
Contact forces can only be applied when objects are in contact
Three Rules of Contact Mechanics
Rigid Body
fcontact = ↵n
fcontact
If d
= 0 then ↵
Contact forces can only be applied when objects are in contact
0
Three Rules of Contact Mechanics
Rigid Body
fcontact = ↵n
If d
= 0 then ↵
0
OR
If d > 0 then
Contact forces can only be applied when objects are in contact
↵=0
Signorini Conditions
fcontact = ↵n ↵ >= 0 ↵ 2 R
d (yA , yB )
If d
0
= 0 then ↵ > 0
OR
If d > 0 then
Rigid Body
Complementarity
↵=0
fcontact
yA = yB
Signorini Conditions
fcontact = ↵n ↵ >= 0 ↵ 2 R
d (yA , yB )
0
d (yA , yB ) ? ↵
Complementarity
Rigid Body
fcontact
yA = yB
Newton-Euler Equations
Conservation of Angular Momentum
RI R
T
!˙ = ! ⇥
RI R
T
! + ⌧ext
external torque
quadratic velocity vector
mI
p̈
=
f
ext
T
T
R I R !˙Conservation
= ! ⇥of LinearRMomentum
I R ! + ⌧ext
angular acceleration
mI p̈ = fext
acceleration external force
Two-Body Contact Example
Rigid Body A
Rigid Body B
Two-Body Contact Example
Rigid Body A
yA = yBn
yA = yB
the jth contact point
Rigid Body B
The Rigid Body Mapping
x (X, t) = R (t)
x (X,
X̄ +
t)p=(t)
R (t) X̄ + p (t)
Y
y
X
Z
x
Reference (Undeformed) Space
z
World (Deformed) Space
Two-Body Contact Example
yA = RA X̄A + pA
Rigid Body A
Rigid Body B
yB = RB X̄B + pB
yA = yB
the jth contact point
Two-Body Contact Example
Rigid Body A
fA =
↵n
fB = ↵
n
the jth contact point
Rigid Body B
The Whole Picture
For each rigid body
T
RI
T
T
RI
!˙R= !!˙⇥= !R⇥I R
mIfext
p̈ = fext
mI p̈ =
R
T
!R + ⌧!ext+ ⌧ext
For each contact point
fA = ↵n
fB = ↵n
↵ >= 0
d (yA , yB ) 0
d (yA , yB ) ? ↵
Rigid Body A
yA = yBn
yA = yB Rigid Body B
the jth contact point
Discrete Equations of Motion
RI R
T
t+1
!
t+1
= RI R
t
T
t
! +
mṗ
= mṗ + tfext
t+1
t
R
= exp ([!] t) R
t+1
t
t
p
= p + tṗ
t
t! ⇥
RI R
T
!
t
+
t
t ⌧ext
For each contact point
fA = ↵n
fB = ↵n
↵ >= 0
d (yA , yB ) 0
d (yA , yB ) ? ↵
Rigid Body A
yA = yBn
yA = yB Rigid Body B
the jth contact point
Discrete Equations of Motion
Mq̇t+1 = Mq̇t + tf t
✓
◆
✓
✓
◆
R I RT
0
!⇥
!˙
q̇ =
f
=
ṗ
0
mI
R I RT ! + ⌧ext
fext
For each contact point
fA = ↵n
fB = ↵n
↵ >= 0
d (yA , yB ) 0
d (yA , yB ) ? ↵
Rigid Body A
yA = yBn
yA = yB Rigid Body B
the jth contact point
◆
External Torques and Forces
✓
⌧ext
fext
◆
= J X̄
T
f X̄
f (x)
Y
y
X
Z
f X̄
J X̄
x
z
World (Deformed) Space
Reference (Undeformed) Space
The Rigid Body Jacobian
Y
⇣
Jv (X,
X̄ t) = RJ [X]
X̄
X
Z
T
I
⌘✓
Jacobian
J2R
Reference (Undeformed) Space
◆
✓
◆
!
RT 0
ṗ
0 RTI
3⇥6
q̇ 2 R
6
Discrete Equations of Motion
Mq̇
t+1
t
= Mq̇ +
t
tf + t
nX
c 1
T
↵j J (yj ) n̂j
j=0
n̂ =
⇢
n
n
If Object A
If Object B
For each contact point
fA = ↵n
fB = ↵n
↵ >= 0
d (yA , yB ) 0
d (yA , yB ) ? ↵
Rigid Body A
yA = yBn
yA = yB Rigid Body B
the jth contact point
Discrete Equations of Motion
Mq̇
t+1
t
= Mq̇ +
t
tf +
nX
c 1
T
↵j J (yj ) n̂j
j=0
t+1
t
R
= exp ([!] t) R
t+1
t
t
p
= p + tṗ
For each contact point
↵ >= 0
d (yA , yB ) 0
d (yA , yB ) ? ↵
Rigid Body A
yA = yBn
yA = yB Rigid Body B
the jth contact point
Discrete Equations of Motion
Mq̇
t+1
t
= Mq̇ +
t
tf + t
nX
c 1
T
↵j J (yj ) n̂j
j=0
t+1
t
R
= exp ([!] t) R
t+1
t
t
p
= p + tṗ
For each contact point
↵ >= 0 ize ?
t
e
r
c
s , yB ) 0
DiA
d (y
d (yA , yB ) ? ↵
Rigid Body A
yA = yBn
yA = yB Rigid Body B
the jth contact point
Discrete Equations of Motion
Mq̇
t+1
t
= Mq̇ +
t
tf + t
nX
c 1
T
↵j J (yj ) n̂j
j=0
t+1
t
R
= exp ([!] t) R
t+1
t
t
p
= p + tṗ
For each contact point
↵ >= 0
rL
a
t+1inet+1
l
dd
y
(y
n
A
o
N A ,,yyBB ) 0
d
t+1
t+1
dy(y
A A,,yyBB )
?↵
Rigid Body A
yA = yBn
yA = yB Rigid Body B
the jth contact point
Discrete Equations of Motion
Mq̇
t+1
t
t
tf + t
= Mq̇ +
nX
c 1
T
↵j J (yj ) n̂j
j=0
t+1
t
R
= exp ([!] t) R
t+1
t
t
p
= p + tṗ
For each contact point
↵ >= 0
t
d yA
+
t
d yA
+
Rigid Body A
t+1
t+1
t
e
tẏA
,ayrB
+
t
ẏ
idz (yA , yBB )
e
Ltẏin
t+1
, yt
A
0
t+1
+
t
ẏ
d
(y
,
y
B
A BB ) ? ↵
yA = yBn
yA = yB Rigid Body B
the jth contact point
Two-Body Contact Example
Rigid Body A
n
Rigid Body B
the jth contact point
Two-Body Contact Example Zoomed In
Rigid Body A
n
Rigid Body B
Two-Body Contact Example Zoomed In
yt
Rigid Body A
n
Proje
ct
A
+
Lengt
h?
tẏ t+
A 1
t
yA
+
t+1
tẏA
n
Rigid Body B
Two-Body Contact Example Zoomed In
nTyt
Rigid Body A
A
tn T ẏ t+1
A
n
Rigid Body B
Two-Body Contact Example Zoomed In
Rigid Body A
n
Rigid Body B
Two-Body Contact Example Zoomed In
nTyt
B
+
tn T ẏ t+1
B
Rigid Body A
n
Rigid Body B
Two-Body Contact Example Zoomed In
Rigid Body A
n
Rigid Body B
Two-Body Contact Example Zoomed In
nT
yBt
Rigid Body A
yAt
+
tn T
ẏ t+1
B
ẏ t+1
A
Rigid Body B
Discrete Equations of Motion
Mq̇
t+1
t
= Mq̇ +
t
tf + t
nX
c 1
T
↵j J (yj ) n̂j
j=0
t+1
t
R
= exp ([!] t) R
t+1
t
t
p
= p + tṗ
For each contact point
Rigid Body A
↵ >= 0
t
d yA
+
t+1
t+1
t
tẏA
, yB
+
t
ẏ
d (yA , yBB )
t
d yA
+
t+1
t+1
t
tẏA
, yB
d+
(yAt,ẏyB
B) ? ↵
0
yA = yBn
yA = yB Rigid Body B
the jth contact point
Discrete Equations of Motion
Mq̇
t+1
t
= Mq̇ +
t
tf + t
nX
c 1
T
↵j J (yj ) n̂j
j=0
t+1
t
R
= exp ([!] t) R
t+1
t
t
p
= p + tṗ
For each contact point
↵ >= 0
t+1
T
n ẏB
t+1
nT ẏB
Rigid Body A
t+1
ẏA
t+1
ẏA
yA = yBn
yA = yB Rigid Body B
0
?↵
the jth contact point
A More Complicated Example
A More Complicated Example
Detect Collisions
A More Complicated Example
For ith contact
Object A ID
Object B ID
Contact Normal i
Contact Point yi
n
Solving the Contact Problem
Dynamics Equations
t+1
MA q̇A
MB q̇t+1
B
=
=
t
MA q̇A
MB q̇tB
t
tfA
+
tfBt
+
+
+
t
t
nX
c 1
j=0
nX
c 1
T
↵j JA (yj ) n̂j
T
↵j JB (yj ) n̂j
j=0
For each contact point
↵i
↵ >= 0
n
T
nT
t+1
ẏB
t+1
ẏB
t+1
ẏA
t+1
ẏA
0
?↵
0
Solving the Contact Problem Iteratively
Dynamics Equations
t+1
MA q̇A
MB q̇t+1
B
=
=
t
MA q̇A
MB q̇tB
t
tfA
+
tfBt
+
+
+
t
t
nX
c 1
j=0
nX
c 1
T
↵j JA (yj ) n̂j
T
↵j JB (yj ) n̂j
j=0
Constraints
↵i 0
t+1
T
ni ẏB
nTi
t+1
ẏB
Look Here !
t+1
ẏA
t+1
ẏA
0
? ↵i
↵i
0
Solving the Contact Problem Iteratively
nX
c 1
T
t+1
t
t
MA q̇A = MA q̇A + tfA + t
↵j JA (yj ) n̂j
j=0
t+1
MA q̇A
= MA q̇tA +
tfAt +
0
A
gj
nX
c 1
t@
j6=i
1
↵j gjA A + ↵i tgiA
All other contacts
t+1
MA q̇A
=
t
MA q̇A
+
t
tfA
+
A
tfi
+ ↵i
A
tgi
Forces from all other contacts
Current contact
Solving the Contact Problem Iteratively
t+1
MA q̇A
=
t
MA q̇A
+
t
tfA
+
A
tfi
+ ↵i
A
tgi
Forces from all other contacts
t+1
q̇A
=
q̇tA
+
1 t
tMA fA
+
⇤
Unconstrained velocity q̇A
1 A
tMA fi
+ ↵i
1 A
tMA gi
Change due to contact
Solving the Contact Problem Iteratively
Dynamics Equations
t+1
MA q̇A
MB q̇t+1
B
=
=
t
MA q̇A
MB q̇tB
t
tfA
+
tfBt
+
+
+
t
t
nX
c 1
j=0
nX
c 1
T
↵j JA (yj ) n̂j
T
↵j JB (yj ) n̂j
j=0
Constraints
↵i 0
t+1
T
ni ẏB
nTi
t+1
ẏB
Look Here !
t+1
ẏA
t+1
ẏA
0
? ↵i
↵i
0
Solving the Contact Problem Iteratively
Dynamics Equations
t+1
q̇A
t+1
q̇B
=
⇤
q̇A
=
⇤
q̇B
+
1 A
tMA fi
+
1 B
tMB fi
Constraints
↵i 0
t+1
T
ni ẏB
nTi
t+1
ẏB
+ ↵i
1 A
tMA gi
+ ↵i
1 B
tMB gi
Look Here !
t+1
ẏA
t+1
ẏA
0
? ↵i
↵i
0
The Rigid Body Jacobian
Y
⇣
Jv (X,
X̄ t) = RJ [X]
X̄
X
Z
T
I
⌘✓
Jacobian
J2R
Reference (Undeformed) Space
◆
✓
◆
!
RT 0
ṗ
0 RTI
3⇥6
q̇ 2 R
6
Solving the Contact Problem Iteratively
Dynamics Equations
t+1
q̇A
t+1
q̇B
=
⇤
q̇A
=
⇤
q̇B
+
1 A
tMA fi
+
1 B
tMB fi
Constraints
↵i 0
t+1
T
ni ẏB
nTi
t+1
ẏB
+ ↵i
1 A
tMA gi
+ ↵i
1 B
tMB gi
Look Here !
t+1
ẏA
t+1
ẏA
0
? ↵i
↵i
0
Solving the Contact Problem Iteratively
Dynamics Equations
t+1
q̇A
t+1
q̇B
=
⇤
q̇A
=
⇤
q̇B
Constraints
↵i
0
+
1 A
tMA fi
+
1 B
tMB fi
+ ↵i
1 A
tMA gi
+ ↵i
1 B
tMB gi
Look Here !
nTi JB (y) q̇t+1
B
JA (y) q̇t+1
A
nTi JB (y) q̇t+1
B
JA (y) q̇t+1
? ↵i
A
0
↵i
0
Solving the Contact Problem Iteratively
t+1
q̇A
t+1
q̇B
=
⇤
q̇A
=
⇤
q̇B
+
1 A
tMA fi
+
1 B
tMB fi
+ ↵i
1 A
tMA gi
+ ↵i
1 B
tMB gi
nTi JB (y) q̇t+1
B
B T
gi
t
h
B T
gi
MB1 giB
+
i
A T
gi
t+1
q̇B
MA1 giA
i
↵i +
+
JA (y) q̇t+1
A
A T
gi
B T
gi
q̇⇤B
+
t+1
q̇A
tMB1 fiB
0
+
i
A T
gi
q̇⇤A +
tMA1 fiA
Solving the Contact Problem Iteratively
Dynamics Equations
t+1
q̇A
t+1
q̇B
=
⇤
q̇A
=
⇤
q̇B
Constraints
↵i
0
+
1 A
tMA fi
+
1 B
tMB fi
+ ↵i
1 A
tMA gi
+ ↵i
1 B
tMB gi
Look Here !
nTi JB (y) q̇t+1
B
JA (y) q̇t+1
A
nTi JB (y) q̇t+1
B
JA (y) q̇t+1
? ↵i
A
0
↵i
0
Solving the Contact Problem Iteratively
Dynamics Equations
t+1
q̇A
t+1
q̇B
=
⇤
q̇A
=
⇤
q̇B
+
1 A
tMA fi
+
1 B
tMB fi
Constraints
↵i
i ↵i
+ ↵i
1 B
tMB gi
Look Here !
0
+
i ↵i +
+ ↵i
1 A
tMA gi
i
0
? ↵i
↵i
0
Solving the Single Point Contact Problem
Dynamics Equations
t+1
q̇A
t+1
q̇B
=
⇤
q̇A
=
⇤
q̇B
+
1 A
tMA fi
+
1 B
tMB fi
Constraints
↵i
i ↵i
+ ↵i
1 B
tMB gi
Look Here !
0
+
i ↵i +
+ ↵i
1 A
tMA gi
i
i
0
? ↵i
Solving the Single Point Contact Problem
Constraints
↵i
Look Here !
0
i ↵i
+
i ↵i +
i
i
0
? ↵i
Yes
Assume
i ↵i
+
i
=0
↵i =
i
i
↵i
i ↵i
+
i ↵i +
i
i ↵i
i
i
=0
? ↵i
0
No
↵i =
0
+
i ↵i +
i
0?
? ↵i
Solving the Single Point Contact Problem
Constraints
↵i
0
i ↵i
+
i ↵i +
If
Look Here !
↵i =
So if we set
i
i
i
0
? ↵i
< 0 then
i
>0
i
↵i = 0 then
i ↵i
+
i
=
i
>0
Solving the Single Point Contact Problem
Constraints
↵i
Look Here !
0
i ↵i
+
i ↵i +
i
i
0
? ↵i
Yes
Assume
i ↵i
+
i
=0
↵i =
i
i
↵i
i ↵i
+
i ↵i +
i
i ↵i
i
i
=0
? ↵i
0
No
↵i =
0
+
i ↵i +
i
0?
? ↵i
Solving the Single Point Contact Problem
Constraints
↵i
Look Here !
0
i ↵i
+
i ↵i +
i
i
Solution
↵i = max
0
? ↵i
✓
i
◆
i
,0
Solving the Contact Problem Iteratively
Solving the Contact Problem Iteratively
⇤
Compute q̇ for all rigid bodies in the scene
0 1
k = 0 ↵0
B ↵1 C
↵=0
B C
B
C still violated or maximum iterations not reached
↵
2
While
constraints
↵=B C
B .. C
@
k =. kA+ 1
↵m
i = 1 to number of contacts
For
Compute i and i using ↵
◆te
a
p
i d
U
ce , 0
↵i =-P
max
a
l
In
i
Done
✓
Done
t+1
q̇
Compute
for all rigid bodies in the scene
Update positions for all rigid bodies in the scene
Projected Gauss-Seidel
⇤
Compute q̇ for all rigid bodies in the scene
k=0
↵=0
While constraints still violated or maximum iterations not reached
k =k+1
For i = 1 to number of contacts
Compute i and i using ↵
✓
◆
i
↵i = max
,0
Done
i
Done
t+1
q̇
Compute
for all rigid bodies in the scene
Update positions for all rigid bodies in the scene
Next Video: Fluid Simulation
Goldade et al | A Practical Method for High-Resolution Embedded Liquid Surfaces
Download