09 RigidBody
09 RigidBody
Forward Kinematics
Inverse Kinematics
Mller/Parent/Machiraju
Mller/Parent/Machiraju
Reading
Mller/Parent/Machiraju
Forces
Object properties
Position, orientation
Linear and angular velocity
Linear and angular momentum
mass
Calculate forces
Calculate accelerations
Using mass, momenta
Gravity
Wind
Springs
Collision avoidance
Soft constraints
Mller/Parent/Machiraju
Mller/Parent/Machiraju
Friction
Supporting object
Resting contact
Normal force
Static friction
Fs
F
Fs = usFN
Mller/Parent/Machiraju
Mller/Parent/Machiraju
Friction (2)
Supporting object
Resting contact
Normal force
Static friction
Kinetic friction
Gravity
Fgravity =
Fk
aobject =
F
FN
mobject
Gmearth
2
2
2 = 32 ft /s = 9.8m /s
rearth
Fs = usFN
Fk = uk FN
!
Gm1m2
r2
Mller/Parent/Machiraju
Mller/Parent/Machiraju
Viscosity
Fv = "k v nv
xrest
F
Mller/Parent/Machiraju
Spring Mesh
Damping
!
F = (x " x rest )k spring " vkdamping
Mller/Parent/Machiraju
Mller/Parent/Machiraju
Mass-Spring-Damper System
Define point masses
postion
velocity
mass
force
fixed?
Define springs
point 1
point 2
rest length
kspring
kdamper
Mller/Parent/Machiraju
Mass-Spring-Damper System
For each point
Initialize force with wind
For each spring
Calculate spring-damper force
spring.point1.force += force
spring.point2.force -= force
For each point
acc = gravity
acc += force/mass
newVel = velocity + acc*dt
position += dt*(velocity+newVelocity)/2
Velocity = newVelocity
Mller/Parent/Machiraju
Examples
1, 4, 16 time samples per frame
Examples (2)
Multiple connectivity; fixing a node adding
gravity and wind
Mller/Parent/Machiraju
Mller/Parent/Machiraju
Examples (3)
Randomize
Mller/Parent/Machiraju
Mller/Parent/Machiraju
Angular Springs
F
F
F
Fix to surface
Non-penetration
Mller/Parent/Machiraju
Mller/Parent/Machiraju
Forces
Gravity
Wind
Springs
Collision avoidance
Soft constraints
Given: a(t)
Point: x(t)
v(t)
Mller/Parent/Machiraju
Euler Integration
g"(t i )
!
g(t i )
!
!
Mller/Parent/Machiraju
Mller/Parent/Machiraju
Numeric Approximation
Euler method
Mller/Parent/Machiraju
Euler method
Euler method
Mller/Parent/Machiraju
Mller/Parent/Machiraju
Midpoint Method
Numeric Approximation
g(t
i+
h
2
g"(t
g"(t i )
!
i+
i+
h
2
)#t
g(t!i )
!
Mller/Parent/Machiraju
h
2
Midpoint method
Mller/Parent/Machiraju
k1
g(ti+1)
k4
g (ti)
g(t i+1 ) =
Equations of Motion
Linear force
Angular force: torque
Linear momentum
Conserved in a
closed system
Angular momentum
Resistance to linear force: mass
Resistance to angular force: inertia tensor.
k1 k 2 k 3 k 4
+ + +
6 3 3 6
Mller/Parent/Machiraju
Mller/Parent/Machiraju
Rotational Movement
!(t)
a = b + r(t)
r (t)
"
b
Mller/Parent/Machiraju
Mller/Parent/Machiraju
R (t) = [" (t) # R1 (t) " (t) # R2 (t) " (t) # R3 (t)]
!
' Az
0
Ax
Ay # & Bx #
!
' Ax ! $$ B y !! = A* B
0 !" $% Bz !"
Mller/Parent/Machiraju
Center of Mass
F = ma
a = F /m
F(t) = " f i (t)
M = " mi
m q (t)
"
x(t) =
i i
Mller/Parent/Machiraju
Mller/Parent/Machiraju
Linear Momentum
Angular Momentum
p = mv
P(t) = Mv(t)
P (t) = Mv(t) = F(t)
Mller/Parent/Machiraju
Mller/Parent/Machiraju
Inertia Tensor
Iobject
Ixx =
!
!
"Ixx
$
= $Ixy
$#Ixz
Ixz %
'
Iyz '
Izz '&
Ixy
Iyy
Iyz
2
### "(q)(q
Mller/Parent/Machiraju
+ qz )dxdydz
Ixy = " mi x i y i
Ixz = " mi x i zi
Iyz = " mi y i zi
Ixx = " mi (y i + zi )
Iyy = " mi (x i + zi )
Izz = " mi (x i + y i )
2
y
Mller/Parent/Machiraju
Iobject
" M (b 2 + c 2 )
%
0
0
$
'
1
2
2
= $
0
M (a + c )
0
'
12 $
0
0
M ( a 2 + b 2 )'&
#
"1 0 0%
2MR $
'
=
0
1
0
'
5 $
$#0 0 1'&
2
Iobject
!
Mller/Parent/Machiraju
Mller/Parent/Machiraju
S (t) =
x (t)
R (t)
P (t)
L (t)
v(t) = P(t) / M
Mller/Parent/Machiraju
Mller/Parent/Machiraju
Update Orientation
! (t) * R(t) and renormalize
Extract axis-angle from ! (t) and rotate
columns of R(t)
Use quaternions
Mller/Parent/Machiraju
Mller/Parent/Machiraju
Collisions
Collision Detection
Collision Avoidance
force fields, steer to avoid, etc.
as in flocking
Collision Detection
calculating when objects overlap
during a time interval
Collision Response
Collisions
t collision = t i + "t
d2
Mller/Parent/Machiraju
d1
d1 + d2
Penalty method
Kinematic Response
Detect Collision - Point-Plane
Every time step, see if point is one wrong
side of plane
Detect collision by planar equation
E ( p) = ax + by + cz + d < 0
Impulse forces
Usually used when time is backed up
Mller/Parent/Machiraju
Mller/Parent/Machiraju
(v " N)N
The role of k:
K=0.8 get bounces
Not physically based, but reasonable visual
response
Mller/Parent/Machiraju
Penalty Method
d
Mller/Parent/Machiraju
Mller/Parent/Machiraju
Swept Volumes
Mller/Parent/Machiraju
Mller/Parent/Machiraju
Calculating impulse
Duration of impulse is no time
Actually a small amount of time
Other forces ignored during this period
No friction too !
Mller/Parent/Machiraju
Mller/Parent/Machiraju
Time of Impact
2D Collisions
Mller/Parent/Machiraju
Mller/Parent/Machiraju
More Remarks
Edge/edge collisions are modeled as
point/point in this system
Only two colliding bodies at a time
3D is harder because of variety of collision
types
!
!
Mller/Parent/Machiraju
Mller/Parent/Machiraju
Calculating an impulse
Relative Velocity
rA ( t ) = pA " x A (t )
p A ( t ) = v A (t ) + " A ( t ) # rA ( t )
rB ( t ) = pB " x B (t )
p B ( t ) = v B (t ) + " B ( t ) # rB ( t )
v rel = p A (t ) " p B ( t )
!
!
!
Mller/Parent/Machiraju
Mller/Parent/Machiraju
jN
MA
jN
v B+ = v "B "
MB
v A+ = v "A +
AxB
A
Mller/Parent/Machiraju
Mller/Parent/Machiraju
Coefficient of restitution
Computing Impulse
1st: Assume objects cannot rotate
Coefficient of resitution
q A+ = v A+ = v "A +
jN
MA
q B+ = v B+ = v "B "
jN
MB
(v
+
A
j
j
v "A # N +
N # N " v "B # N +
N # N = "$(v "A " v "B ) # N
MA
MB
!
% 1
1 (
"
j'
+
* = "(1+ $)v rel # N
Mller/Parent/Machiraju
& MA MB )
Mller/Parent/Machiraju
Computing impulse
Things to note:
Mller/Parent/Machiraju
j=
"(1+ #) N $ (q " q
"
A
"
B
1
1
+
+ N $ IA"1 (t)(rA % N) % rA + N $ IB"1 (t)(rB % N) % rB
MA MB
jN
jN
v B+ = v "B "
MA
MB
+
"
"1
+
"
"1
# A = # A + IA (t)(rA $ jN) # B = # B " IB (t)(rB $ jN)
v A+ = v "A +
Mller/Parent/Machiraju
// actually colliding
LA += rA x J
LB -= rB x J
Mller/Parent/Machiraju
Mller/Parent/Machiraju