33
Advanced Computer Graphics Rigid Body Simulation Spring 2002 Professor Brogan

Advanced Computer Graphics Rigid Body Simulation Spring 2002 Professor Brogan

Embed Size (px)

Citation preview

Page 1: Advanced Computer Graphics Rigid Body Simulation Spring 2002 Professor Brogan

Advanced Computer GraphicsRigid Body Simulation

Spring 2002

Professor Brogan

Page 2: Advanced Computer Graphics Rigid Body Simulation Spring 2002 Professor Brogan

Upcoming Assignments

• Who wants a midterm instead of an assignment?

• Final will be take home

• Cloth/water/parallel particle sim presentations– Volunteers?– Papers selected by Thursday

Page 3: Advanced Computer Graphics Rigid Body Simulation Spring 2002 Professor Brogan

Physical Simulation

• References– Text book (4.3 and Appendix B)– Physics for Game Developers (Bourg)– Chris Hecker Game Developer articles

• http://www.d6.com/users/checker/dynamics.htm

Page 4: Advanced Computer Graphics Rigid Body Simulation Spring 2002 Professor Brogan

Equations of Motion

• The physics-based equations that define how objects move– Gravity– Turbulence– Contact forces with objects– Friction– Joint constraints

Page 5: Advanced Computer Graphics Rigid Body Simulation Spring 2002 Professor Brogan

Equations of Motion

Current State

Position and velocity

Accelerations

Forces

Velocities

Equations ofMotion

Integrate

Integrate

Integrate

Page 6: Advanced Computer Graphics Rigid Body Simulation Spring 2002 Professor Brogan

Equations of Motion

• Linear motions:

• Example:– Constant

acceleration of 5 m/s2

dttatv

dttvtr

)()(

)()(

002

0

0

0

2

55)()(

5)(

)0(5)0(

55)(

rtvtdtvtdttvtr

vttv

Cv

Cv

Ctdtdtatv

Page 7: Advanced Computer Graphics Rigid Body Simulation Spring 2002 Professor Brogan

Linear Momentum

• Mass times velocity = linear momentum, p

• Newton’s Second Law

amvmdt

vmd

dt

pdpF

)(

vmp

Ceasing to identify vectors…

Page 8: Advanced Computer Graphics Rigid Body Simulation Spring 2002 Professor Brogan

Rigid Bodies

• Imagine a rigid body as a set of point masses• Total momentum, pT, is sum of momentums of

all points:

• Center of Mass (CM) is asingle point. Vector to CMis linear combination ofvectors to all points in rigidbody weighted by their masses,divided by total mass of body

i

iiT vmp

M

rmr i

ii

CM

Page 9: Advanced Computer Graphics Rigid Body Simulation Spring 2002 Professor Brogan

Total Momentum

• Rewrite total momentum in terms of CM

• Total linear momentum equals total mass times the velocity of the center of mass

(For continuous rigid bodies, all summations turn into integrals over the body, but CM still exists)

• We can treat all bodies as single point mass and velocity

dt

Mrd

dt

rmdvmp

CM

i

ii

i

iiT )()(

Page 10: Advanced Computer Graphics Rigid Body Simulation Spring 2002 Professor Brogan

Total Force

• Total force is derivative of the total momemtum– Again, CM simplifies total force equation of a rigid

body

– We can represent all forces acting on a body as if their vector sum were acting on a point at the center of mass with the mass of the entire body

CMCMTT MavMpF

Page 11: Advanced Computer Graphics Rigid Body Simulation Spring 2002 Professor Brogan

Intermediate Results

• Divide a force by M to find acceleration of the center of mass

• Integrate acceleration over time to get the velocity and position of body

• Note we’ve ignored where the forces are applied to the body

• In linear momentum, we don’t keep track of the angular terms and all forces are applied to the CM.

Page 12: Advanced Computer Graphics Rigid Body Simulation Spring 2002 Professor Brogan

Ordinary Differential Equations

• A DifEq is an equation with– Derivatives of the dependent variable– Dependent variable– Independent variable

• Ex:

• v’s derivative is a function of its current value• Ordinary refers to ordinary derivatives

– As opposed to partial derivatives

m

v

dt

dva

Page 13: Advanced Computer Graphics Rigid Body Simulation Spring 2002 Professor Brogan

Integrating ODEs

• Analytically solving ODEs is complicated

• Numerically integrating ODEs is much easier (in general)– Euler’s Method– Runge-Kutta

Page 14: Advanced Computer Graphics Rigid Body Simulation Spring 2002 Professor Brogan

Euler’s Method

• Based on calculus definition of first derivative = slope

Page 15: Advanced Computer Graphics Rigid Body Simulation Spring 2002 Professor Brogan

Euler’s Method

• Use derivative at time n to integrate h units forward

dx

dyhyy n

nn 1

Page 16: Advanced Computer Graphics Rigid Body Simulation Spring 2002 Professor Brogan

Euler Errors

• Depending on ‘time step’ h, errors will accumulate

SIGGRAPH Course Notes

Page 17: Advanced Computer Graphics Rigid Body Simulation Spring 2002 Professor Brogan

Accumulating Errors

SIGGRAPH Course Notes

Page 18: Advanced Computer Graphics Rigid Body Simulation Spring 2002 Professor Brogan

Recap

Page 19: Advanced Computer Graphics Rigid Body Simulation Spring 2002 Professor Brogan

Angular Effects

• Let’s remain in 2-D plane for now• In addition to kinematic variables

– x, y positions

• Add another kinematic variable – angle– CCW rotation of object

axes relative to world axes

Page 20: Advanced Computer Graphics Rigid Body Simulation Spring 2002 Professor Brogan

Angular Velocity

• is the angular velocity

• is the angular acceleration

dt

d

dt

d2

2

Page 21: Advanced Computer Graphics Rigid Body Simulation Spring 2002 Professor Brogan

Computing Velocities

• How do we combine linear and angular quantities?

• Consider velocity of a point, B, of a rigid body rotating about its CM

• r_perp is perpendicular to r vector from O to B• Velocity is -scaled perpendicular vector from

origin to point on body

OBB rv

Page 22: Advanced Computer Graphics Rigid Body Simulation Spring 2002 Professor Brogan

More Details

• Point B travels radians• Point B travels C units• Radius of circle is r• C= r

– By definition of radians,where circumference = 2r

• B’s speed (magnitude of velocity vector)– Differentiate C= r w.r.t. time

rrdt

d

dt

rd

)(

Page 23: Advanced Computer Graphics Rigid Body Simulation Spring 2002 Professor Brogan

More Details

• The direction of velocity is tangent to circle == perpendicular to radius

• Therefore, linearvelocity is angularvelocity multiplied by tangent vector

Page 24: Advanced Computer Graphics Rigid Body Simulation Spring 2002 Professor Brogan

Chasles’ Theorem

• Any movement is decomposed into:– Movement of a single point on body– Rotation of body about that point

• Linear and Angular Components

OBOB rvv

Page 25: Advanced Computer Graphics Rigid Body Simulation Spring 2002 Professor Brogan

Angular Momentum

• The angular momentum of point B about point A (we always measure angular terms about some point)

• It’s a measure of how much of point B’s linear momentum is rotating around A

BABAB prL

Page 26: Advanced Computer Graphics Rigid Body Simulation Spring 2002 Professor Brogan

Angular Momentum

• Check: If linear momentum, pB, is perpendicular to r_perp, then dot product of two will cause angular momentum will be zero

Page 27: Advanced Computer Graphics Rigid Body Simulation Spring 2002 Professor Brogan

Torque

• Derivative of Angular Momentum– Remember force was derivative of linear

momentum

– This measures how much of a force applied at point B is used to rotate about point A, the torque

BBBAB

BABAB

Frmar

dt

prd

dt

dL

A

)(

Page 28: Advanced Computer Graphics Rigid Body Simulation Spring 2002 Professor Brogan

Total Angular Momentum

• Total angular momentum about point A is denoted LAT

• But computation can be expensive to sample all points

• Sampling of a surface would require surface integration

i

iiAi

i

iAiAT

vmr

prL

Page 29: Advanced Computer Graphics Rigid Body Simulation Spring 2002 Professor Brogan

Moment of Inertia

• Remember– An alternate way of representing the

velocity of a point in terms of angular velocity

• If A is like the origini is like B, then substitute

OBB rv

i

iiAi

i

iAiAT

vmr

prL

A

i

Aii

i

AiAii

i

AiiAiAT

I

rm

rrm

rmrL

2)(

Page 30: Advanced Computer Graphics Rigid Body Simulation Spring 2002 Professor Brogan

Moment of Inertia, IA

• The sum of squared distances from point A to each other point in the body, and each squared distance is scaled by the mass of each point

• This term characterizes how hard it is to rotate something– Ipencil_center will be much less than Ipencil_tip

A

i

Aii Irm 2)(

Page 31: Advanced Computer Graphics Rigid Body Simulation Spring 2002 Professor Brogan

Total Torque

• Differentiate totalangular momentumto get total torque

• This relates total torque and the body’s angular acceleration through the scalar moment of inertia

AA

AAT

AT

II

Iddt

dL

)(

Page 32: Advanced Computer Graphics Rigid Body Simulation Spring 2002 Professor Brogan

Planar Dynamics

• Calculate COM and MOI of rigid body• Set initial position and linear/angular velocities• Figure out all forces and their points of application• Sum all forces and divide by mass to find COM’s linear

acceleration• For each force, compute perp-dot-product from COM to point of

force application and add value into total torque of COM• Divide total torque by the MOI at the COM to find angular

acceleration• Numerically integrate linear/angular accelerations to update the

position/orientation and linear/angular velocities• Draw body in new position and repeat

Page 33: Advanced Computer Graphics Rigid Body Simulation Spring 2002 Professor Brogan

Upcoming Topics

• Collisions

• 3-dimensional rigid bodies (inertia tensors)

• Forces (centripetal, centrifugal, viscosity, friction, contact)

• Constrained dynamics (linked bodies)