Upload
others
View
1
Download
0
Embed Size (px)
Citation preview
1
Dynamics I
Dynamics Simulation
Welcome back
Lots of logistics to take care of: Readings Grad Report Assignments Projects
Readings
All readings up to week 3 graded Comments/grades on mycourses
Remember to place this weeks in thedropbox.
Grad Report
Topic due tonight. Please place short description in dropbox.
Projects
Proposals Proposal due before break (please get
yours in if not submitted) Feedback on proposals -- mycourses Web sites please.
15 projects (3-4 more expected)
Projects Presentations:
Dates: Week 9: Wed, Feb 14 Week 10: Mon, Feb 19 Finals Week: TBD
15 minutes / presentation Schedule now on Web Please send me choice of time/day
2
Assignments Assignment 1 -- Framework
Most graded -- feedback on mycourses Regaining points
C#, Eclipse, other toolkits -- not yet
Please include project files / README Write platform in mycourse comments
Technical comments to come.
Assignments
Assignment 2 -- Keyframing Due Friday, Jan 12. Questions?
Assignment 3 -- Billiards To be given Wednesday.
Plan Physics 101 for rigid body animation
Today: translation and rotational dynamics Wed: Forces, impacts, and collisions Next Monday: Numerical integration.
But first…
Notes on Assignment #1 Time is on my side…
At each frame, object motion is usually based on“clock time” or time of simulation.
In real time systems… System controls the frame update.
At update…must know “clock time” of simulation. Time must be accurate to milliseconds. Motion Control Algorithms usually need the time or time
since last update as parameter.
Notes on Assignment #1 Getting time:
Don’t use time().
Do use: ftime(), clock()
GetSystemTime() -- Windows gettimeofday() -- UNIX.
Questions?
Motivational Films
Educational animations by Jim Blinn
JPL
Cal Tech
Now at Microsoft
3
Motivational Film
Mathematica: The Theorem ofPythagoras (1988)
Motivational Film
The Mechanical Universe (1984)
Let’s get started Physics for Rigid Body Dynamics
Today -- first half: Linear Motion Today -- second half: Rotational Motion Wednesday: Forces / Collisions Next Monday: Numerical Integration / Constraints
Good Notes
1997 SIGGRAPH Course Notes -- David Baraff(CMU) http://www.cs.cmu.edu/~baraff/sigcourse
Gamasutra Article http://www.gamasutra.com/features/19980703/quaternions
_01.htm
Let’s get started
an·i·ma·tion (n)a motion picture made from a series ofdrawings simulating motion by means ofslight progressive changes in the drawings
Rendering Pipelinecamera(captureslight)
syntheticimage
cameramodel
(focusessimulatedlighting)
processing
photoprocessing
tonereproduction
realscene
3Dmodels
Photography:
ComputerGraphics:
Photographicprint
4
An animation framework Create world Populate the world Initialize clock while not done do
Move / animate all objects Render all objects Generate frame Update clock
Object oriented approach
WorldmoveAllObjects ()renderAllObjects()
AniObjectgeometrymove ()render()
AniControl move ()
inhabits
Keyframe
Physics Simulation
Particle System InverseKinematics
Modeling Motion Three approaches
Hueristics Rules of thumb, guidelines, cheap hacks Keyframing, traditional cel animation
Simulation Use of physics Dynamics
Sampling Use of measured data MoCap
Kinematics vs. Dynamics Kinematic control
Refers to motion of object irrespective of theforces involved
E.g. Keyframing
Dynamic control Concerned with computing the underlying
forces which are then used to produce motion.
Using Physics in Animation To achieve physically accurate motion,
go to the source! Keyframing accurate physical motion is
tedious. Use dynamics
Use physics to calculate motion Removes control from animator!! Motion is physically realistic.
The Source: Sir Isaac Newton 1643-1727 Discovered
(amongst otherthings) Calculus Physics of Light Physics of Motion
Busy Man
5
Laws of Motion Law I
Every object in a state of uniform motion tends toremain in that state of motion unless an externalforce is applied to it. (Inertia)
Law II: The acceleration of a body is proportional to the
resulting force acting on the body, and thisacceleration is in the same direction as the force.
Law III: For every action there is an equal and opposite
reaction.
Terms For Linear Physical Motion
Mass Measure of the amount of matter in a body From Law II: Measure of the a body’s resistance to
motion
Velocity Change of motion with respect to time
Acceleration Change of velocity with respect to time
Force In short, force is what makes objects accelerate
Terms
Linear Physical Motion Momentum
Defined as mass x velocity Another way of stating Law I
Momentum is conserved Cannot change unless force is acted upon it
Terms
Mathematically defined Velocity Acceleration Force
Momentum
dtdsv /=
dtsddtdva //2
==
maF =
!
M = mv
Terms Said another way:
If we have force and mass, we can calculatemotion.
m
tFta
)()( =
!= dttatv )()(
!= dttvts )()( !!=2)()( dttats
!
M(t) = F(t)dt"
Physical units
You want physical motion, you need touse physical units
Newtonkg• m / sec2
pound (lb)s • ft / sec2
Force
m / sec2ft / sec2Acceleration
m / secft / secVelocity
Meter (m)foot (ft)Distance
kilogram (kg)slug (s)Mass
SI (Metric)EnglishQuantity
6
Physical units Is weight == mass?
Depends upon who you talk to
Our convention (used in Bourg book) Mass = amount of matter in a body Weight = Force resulting in acceleration due to
gravity. g = 9.8 m / sec2 or 32 ft / sec2
Unambiguous in SI units English units: slug = mass, pound = force
Vectors
Note that all quantities mentioned(except for mass) are vector quantities We are, after all, dealing in 3D motion
Center of Mass
Definition the location where all of the mass of the
system could be considered to be located. For homogenous solid bodies that have a
symmetrical shape, the center of mass is atthe center of body's symmetry, itsgeometrical center.
Initial value problems In order to animate an object, we need to
find s(t), for various values of t, given Initial position of object Initial velocity of object Initial acceleration of object Forces applied to object
All of the above are vector quantities
Projectile motion
Shoot a projectile out of a cannon Cannon is positioned at a given angle No further acceleration except for
gravity.
Projectile motion
analysis
-g
acceleration
7
Recall
m
tFta
)()( =
!= dttatv )()(
!= dttvts )()(
!!=2)()( dttats
Solving differential equations
Means: Analytically Numerically
Analytic solution For constant acceleration problem
Acceleration
Velocity
Position
0=xa ga
y!=
!cos0vv
x= gtvdtavv yy !=+= " ## sinsin
00
! +=+= tvxdtvxxx
)cos( 000 " 2
0002
1)sin( gttvydtvyy y !+=+= " #
Analytic solution We now have equations of motion:
tvxtx )cos()( 00 !+=
2
002
1)sin()( gttvyty !+= "
Given any time t, we can determine position
Analytic solution
Let’s see this in action Link
Dynamics
Parameters: Initial conditions (position, velocity,
accelleration) Forces applied (can be time varying)
Output: Position / Orientation at time t.
8
Numerical Integration Remember, integration required
We won’t always be fortunate enough to be ableto perform the integration using calculus
Must code different equations for differentmotions.
In animation, numerical integration is usuallyused Full discussion of Numerical Integration
techniques next week.
Quick and dirty hack Euler Integration
Leonard Euler 1707-1783 Studied:
Number theory Differential Equations Newtonian Physics Rotational Motion
A busy man
Numerical IntegrationObject properties
Position, orientationLinear and angular velocityLinear and angular momentummass
Forces at time t
Calculate accelerationsUsing mass, momenta
Update object properties
Euler Integration
aka Method of Finite Differences Approximates a curve with a series of
straight lines corresponding to curveduring a given Δt
Uses tangent on the curve at a givenpoint to guide the curve to the nextpoint.
Euler Integration
F (ti)
F ’ (ti)
F (ti+1) = F (ti) + F ‘ (ti)*Δt
Euler Integration
Equations x (t + Δt) = x(t) + (v(t) Δt) v (t + Δt) = v(t) + (a(t) Δt) M(t + Δt) = M(t) + (F(t) Δt)
Approximating x, v, and M at time t + Δtby using tangents at time t.
9
Euler Integration
Euler Integration is fast, intuitive, andeasy to code however, It is also a very crude approximation to the
integral The smaller the Δt, the better the solution.
Also, the more work that is required.
Putting it all together…so far Step 1
Calculate Forces, F(t)
Step 2 update position (integrate velocity)
s(t +Δt) = s(t) + v(t)Δt update Momentum (integrate force/acceleration)
M(t +Δt) = M(t) + F(t) Δt
Step 3 Calculate velocities
v(t +Δt) = M(t +Δt)/m
Go to step 1
break
Putting it all togetherObject properties
Position, orientationLinear and angular velocityLinear and angular momentummass
Forces at time t
Calculate accelerationsUsing mass, momenta
Update object properties
Let’s Talk About Rotation
Figures taken from Watt & Policarpo, “3D Games: RealTime
Rendering and Software Technology”
Let’s talk about rotation Two coordinate systems to consider
World space Coordinate system of space where object resides Known as inertial frame We’ll need everything w.r.t this for rendering.
Object space Local coordinate system of the object Origin is the center of mass of the object Known as body frame
Let’s talk about rotation
10
Transformation matrix
{ {objecttiontransforma
44434241
34333231
24232221
14131211
world
11!!!!
"
#
$$$$
%
&
'
!!!!
"
#
$$$$
%
&
=
!!!!
"
#
$$$$
%
&
o
o
o
w
w
w
z
y
x
mmmm
mmmm
mmmm
mmmm
z
y
x
4444 34444 21
Translation s(t)
Rotation = R(t)
Rotation Matrix Reinterpreting the rotation matrix
Each column gives the world coordinates of an axis in thelocal coordinate system
!!!
"
#
$$$
%
&
=
zzyzxz
zyyyxy
zxyxxx
rrr
rrr
rrr
tR )(
x y z
Rotation Matrix Factoids about the rotation matrix
R is orthogonal Each column vector is of unit length Determinant = 1 Inverse is equal to it’s transpose
R-1 = RT
Al the above must hold
Real reason why interpolation of this matrix directly does notwork!
Calculating position Taking into account rotation, the position (in world
space) of a point rbody (in object space)
Which is a different way of sayingbodyrtRtstr )()()( +=
{ {objecttiontransforma
44434241
34333231
24232221
14131211
world
11!!!!
"
#
$$$$
%
&
'
!!!!
"
#
$$$$
%
&
=
!!!!
"
#
$$$$
%
&
o
o
o
w
w
w
z
y
x
mmmm
mmmm
mmmm
mmmm
z
y
x
4444 34444 21
Angular velocity Amount of rotation with respect to time
Measured w.r.t. the body frame Given by a 3D vector ω(t)
Direction of ω gives the axis of rotation Magnitude of ω, | ω | gives the amount of rotation
Angular velocity
11
Angular velocity To obtain velocity at a point rbody with respect to
point in object space
Note that this is independent of linear velocity
Link
bodybody rttr != )()( "&
Angular Velocity
Apply to each axis in object space Recall
!!!
"
#
$$$
%
&
=
zzyzxz
zyyyxy
zxyxxx
rrr
rrr
rrr
tR )(
x y z
Angular Velocity
Apply to each axis in object space
)()()()()()( tRt
r
r
r
t
r
r
r
t
r
r
r
ttR
zz
zy
zx
yz
yy
yx
xz
xy
xx
!=
"""
#
$
%%%
&
'
"""
#
$
%%%
&
'
(
"""
#
$
%%%
&
'
(
"""
#
$
%%%
&
'
(= ))))&
Complete velocity equation
For a point rbody in object space Position
Velocity
bodyrtRtstr )()()( +=
bodyrtRtstr )()()( &&& +=
bodyrtRttvtr )()()()( !+= "&
translation
rotation
Putting it all togetherObject properties
Position, orientationLinear and angular velocityLinear and angular momentummass
Calculate forces
Calculate accelerationsUsing mass, momenta
Update object properties
Putting it all together Step 1
Calculate Forces, F(t) angular acceleration ω(t)
Step 2 Integrate position/rotation
s(t +Δt) = s(t) + v(t)Δt R(t +Δt) = R(t) + (ω(t)*R(t)) Δt /* CAREFUL HERE */ r(t +Δt) = s(t +Δt) + rbodyR(t +Δt)
Update Momentum M(t +Δt) = M(t) + F(t) Δt
Step 3 Calculate velocities
v(t +Δt) = M(t +Δt)/m
12
Note about angular velocity Step 1
Calculate Forces F(t) angular acceleration ω(t)
Step 2 Integrate position/rotation
s(t +Δt) = s(t) + v(t)Δt R(t +Δt) = R(t) + (ω(t)*R(t)) Δt /* CAREFUL HERE */ r(t +Δt) = s(t +Δt) + rbodyR(t +Δt)
Update Momentum M(t +Δt) = M(t) + F(t) Δt
Step 3 Calculate velocities
v(t +Δt) = M(t +Δt)/m
Note about angular velocity Precipitated the use of quaternions Can use quaternions directly If q(t) represents rotation as a quaternion
then
where
!
˙ q (t) =1
2"(t)q(t)
!
"(t) = 0,"[ ]
Note about angular velocity Step 1
Calculate Forces, F(t) angular acceleration ω(t)
Step 2 Integrate position/rotation
s(t +Δt) = s(t) + v(t)Δt q(t +Δt) = q(t) + 0.5 (ω(t)q(t)) Δt /* normalize to avoid problems */ R(t +Δt) = quatToRot (q(t +Δt) ) r(t +Δt) = s(t +Δt) + rbodyR(t +Δt)
Update Momentum M(t +Δt) = M(t) + F(t) Δt
Step 3 Calculate velocities
v(t +Δt) = M(t +Δt)/m
Note about angular velocity
Note that rotat ion m atricies can st ill beused effect ively w ith a better num ericalinteg rat ion technique.
Putting it all together
What is missing? How about rotational force / acceleration This is known a Torque
Rotational acceleration
Consider
Apply force
Will result inrotation
13
Rotational acceleration
Observations Rotation occurs around the center of mass
(COM) of an object Force applied to point at a distance from
COM will cause a rotation
Torque Force applied to an object that results in rotational
acceleration. Dependent upon the distance from the center of mass
Where τ = Torque x = center of mass r = point where force is applied F = force applied
Fxr !"= )(#
Torque Now force can be seen as two separate
components: Force (Linear) Torque (Rotational)
Torque
More about mass When considering rotation, we need to know 3 things
about the mass of an object Magnitude Center of mass Description of how the mass is distributed in the object
This final item is given by the Inertia Tensor
Inertia tensor
Symmetric 3x3 matrix
!!!
"
#
$$$
%
&
=
zzyzxz
yzyyxy
xzxyxx
body
III
III
III
I
14
Inertia tensor
Each element of the tensor is calculatedby integrating the density of the objectat points q=(x,y,z)! += dmzyI xx )( 22
! += dmzxI yy )( 22
! += dmyxI zz )( 22
!"= xydmIxy
!"= xzdmIxz
!"= yzdmI yz
Inertia Tensor
Like in the linear case, The inertia tensor can be interpreted as
the resistance to accelerationmaF =
m
Fa =
!" &I=
!"# 1$== I&
Formulas for Inertia Tensor
For symmetrical bodies, I contains onlynon-zero components on the diagonal
!!!
"
#
$$$
%
&
=
zz
yy
xx
body
I
I
I
I
00
00
00
Formulas for Inertia Tensor
For common symmetric objects: Sphere with radius r and mass m
Cylinder with radius r, height h, where zaxis is coincident with the long axis ofcylinder
2
5
2mrIII zzyyxx ===
)3
1(
4
1 22 hrmII yyxx +==2
2
1mrI
zz=
Formulas for Inertia Tensor
For common symmetric objects: Rectangular box of sides a, b, c coinciding
to x, y, and z axes respectively
)(3
1 22cbmI
xx+=
)(3
1 22camI yy +=
)(3
1 22bamI
zz+=
Inertia Tensor
Important: With respect to time, in object space, I is
constant
To convert to world space:
Furthermore
T
body tRItRtI )()()( =
Tbody tRItRtI )()()( 11 !!
=
15
Let’s recap
For linear motion Velocity Acceleration Momentum Force
)(tsv &=
)()( tstva &&& ==
MvmmaF && ===
mvM =
Let’s Recap
For rotational motion Angular Velocity Angular Acceleration Angular Momentum Torque
)(tr&=!
)(t!" &=
)()()()()( tLttIttI && === !"#
)()( ttIL !=
Putting it all togetherObject properties
Position, orientationLinear and angular velocityLinear and angular momentummass
Calculate forces
Calculate accelerationsUsing mass, momenta
Update object properties
Putting it all together State of object at any given time position
rotation (in world coords)
momentum
angular momentum!!!!
"
#
$$$$
%
&
=
)(
)(
)(
)(
)(
tL
tM
tR
ts
tS
Putting it all together
Derivative of object state
!!!!
"
#
$$$$
%
&
'=
!!!!
"
#
$$$$
%
&
=
)(
)(
)()(
)(
)(
)(
)(
)(
)(
t
tF
tRt
tv
tL
tM
tR
ts
tS
(
)
&
&
&
&
&
Putting it all together Step 1
Calculate Forces, F(t), τ(t)
Step 2 Integrate position/rotation
s(t +Δt) = s(t) + v(t)Δt R(t +Δt) = R(t) + (ω(t)*R(t)) Δt /* CAREFUL HERE */ r(t +Δt) = s(t +Δt) + rbodyR(t +Δt)
Update Momentum (integrate accelleration) M(t +Δt) = M(t) + F(t) Δt L(t +Δt) = L(t) + τ(t) Δt
16
Putting it all together Step 1
Calculate Forces, F(t), τ(t) Step 2
Integrate position/rotation s(t +Δt) = s(t) + v(t)Δt q(t +Δt) = q(t) + 0.5 (ω(t)q(t)) Δt /* normalize to avoid problems */ R(t +Δt) = quatToRot (q(t +Δt) ) r(t +Δt) = s(t +Δt) + rbodyR(t +Δt)
Update Momentum (integrate accelleration) M(t +Δt) = M(t) + F(t) Δt L(t +Δt) = L(t) + τ(t) Δt
Putting It all together Step 3
Calculate velocities (for next step) v(t +Δt) = M(t +Δt)/m I-1(t +Δt) = R(t +Δt)I-1
body R(t +Δt)T
ω(t +Δt) = + I-1(t +Δt)L(t +Δt)
Go to step 1
Questions?
Next Time
Forces / Collisions / Impulses