Download presentation
Presentation is loading. Please wait.
Published byCurtis Allison Modified over 8 years ago
1
Fundamentals of Computer Animation Rigid Body Simulation (1)
2
Rigid Body Simulation Realistic-looking motion Physically based reaction of rigid bodies to forces such as gravity, viscosity, friction, and collisions. Equations of Motion Animation System Automatic calculation of reactions
3
Rigid Body Simulation
4
Collision Detection
5
Collision Response
9
Rigid Body Simulation: forces due to: Relative positioning of objects –Gravity –Collisions, … Object velocity –Viscosity, … Absolute positions of objects in user- specified vector-fields –Wind, …
10
Forces applied to objects = Linear accelerations based on the mass of object Angular accelerations based on mass distribution of the object
11
Rigid body simulation update cycle Forces Linear and angular accelerations (time derivative of velocities) Integrated over a delta time step Changes in object velocities (linear and angular) Changes in object positions and orientations Integrated over a delta time step Time Step
12
Rigid Body Simulation Update Cycle
13
Equations of Motion Current State Position and velocity Accelerations Forces Velocities Equations of Motion Integrate
14
Using Equations of Motion Standard Physics –Analyzing for times at which significant events happen (i.e. objects hitting the ground) Computer Animation –Modeling the motion of objects at discrete time steps –The significant events and their aftermath –Discrete time sampling numerical issues!
15
Bodies in Free Fall Basics Example Numeric Approximation Equations of Motion Orientation and Rotational Movement Center of Mass Forces Momentum Inertia Tensor Equations
16
Bodies in Free Fall : Basics
17
Bodies in Free Fall Basics Example Numeric Approximation Equations of Motion Orientation and Rotational Movement Center of Mass Forces Momentum Inertia Tensor Equations
18
Time Step #1 Time Step #2 Time Step #3
19
Time Step #1 Time Step #2 Time Step #3
20
Time Step #1 Time Step #2 Time Step #3
21
Bodies in Free Fall : Example
25
Bodies in Free Fall Basics Example Numeric Approximation Equations of Motion Orientation and Rotational Movement Center of Mass Forces Momentum Inertia Tensor Equations
26
Numeric Approximation Euler Integration
27
Numeric Approximation Physically Based Modeling: Principles and Practice (SIGGRAPH '97 Course notes) ©1997 Andrew Witkin and David Baraff
28
A Canonical Differential Equation
36
Midpoint Method A.k.a. 2nd order Runga Kutta F (t i ) F ’ (t i+0.5 ) F (t i+1 ) = F (t i ) + F ‘ (t i+0.5 )*Dt F ‘ (t i ) F (t i+0.5 ) Magnitude of the error term
38
4th Order Runga Kutta F (t i ) F (t i+1 ) = k 1 /6 + k 2 /3 + k 3 /3 + k 4 /6
41
Since x may be vectors, the solver must know their length, to allocate storage, perform vector arithmetic ops, etc.
42
The solver must be able to install new values at the end of a step. In addition, a multi-step method must set x and t to intermediate values in the course of performing derivative evaluations.
43
Evaluate f at the current x and t.
45
Bodies in Free Fall Basics Example Numeric Approximation Equations of Motion Orientation and Rotational Movement Center of Mass Forces Momentum Inertia Tensor Equations
46
Equations of Motion Linear force Angular force: torque Linear momentum Angular momentum Resistance to linear force: mass Resistance to angular force: inertia tensor.
47
Bodies in Free Fall Basics Example Numeric Approximation Equations of Motion Orientation and Rotational Movement Center of Mass Forces Momentum Inertia Tensor Equations
48
Orientation and Rotational Movement Linear attributes: –position, –velocity, –Acceleration 3D objects: –orientation, –angular velocity, –angular acceleration Object orientation rotation matrix R(t)
49
Position and Orientation A rigid body occupies a volume of space and has a particular shape. Because a rigid body can undergo only rotation and translation, we define the shape of a rigid body in terms of a fixed and unchanging space called body space. Given a geometric description of the body in body space, we use x(t) and R(t) to transform the body-space description into world space
50
The center of mass is transformed to the point x(t) in world space, at time t. Center of mass point in the rigid body that lies at the geometric center of the body. Objects are defined in body space and transformed by the position and orientation into world space
51
At time t, the columns of R(t) are the world-space directions that the body-space x, y, and z axes transform to. Physical interpretation of the orientation matrix R(t).
52
Linear Velocity For simplicity, we’ll call x(t) and R(t) the position and orientation of the body at time t. How the position and orientation change over time? If we imagine that the orientation of the body is fixed, then the only movement the body can undergo is a pure translation. The quantity v(t) gives the velocity of this translation. Velocity of the center of mass in world space.
53
Linear Velocity The change of the center of mass over time For a pure translation ( constant), all points move with velocity
54
Angular Velocity In addition to translating, a rigid body can also spin. Imagine however that we freeze the position of the center of mass in space. Any movement of the points of the body must therefore be due to the body spinning about some axis that passes through the center of mass. (Otherwise the center of mass would itself be moving).
55
Angular Velocity : Rate at which the object is rotating irrespective to its linear velocity Direction orientation of the axis about which the object is rotating Magnitude speed of the rotation in revolutions per unit of time
56
For a given number of rotations per unit of time, the angular velocity is the same whether the axis of rotation is near or far away.
57
At time t, the columns of R(t) are the world-space directions that the body-space x, y, and z axes transform to. Physical interpretation of the orientation matrix R(t).
58
Angular Velocity The change in orientation over time Encodes both the axis and speed of the rotation direction encodes the axis magnitude encodes the speed (rad/s) But, how are and related?
59
Let’s examine how the change of an arbitrary vector in a rigid body is related to the angular velocity Let’s remind ourselves of the physical meaning of R(t) The directions of the transformed x, y and z body axes at time t. Describe the velocity with which the x, y, and z axes are being transformed.
60
First in 2D Linear Velocity from Angular Velocity Vector from the origin of our body O (i.e. center of mass) to point B The velocity of a point (V) on a rotating body (B) is calculated by scaling the perpendicular vector from the origin to the point (r OB ) by the angular velocity (omega). Perpendicular vector to r The velocity vector’s direction must be perpendicular to the radius vector. Intuitively: a point rotating around another fixed point can only move perpendicularly to the vector between the points at any instant; it can’t move closer or farther away, or the movement wouldn’t be a simple rotation.
61
Angular Velocity For a given vector The columns of represent the transformed axes
62
Now in 3D The rate of change of a rotating vector. The rate of change of a vector At time t, we know that the direction of the x axis of the rigid body in world space is the first column of R(t) At time t, the derivative of the first column of R(t) is just the rate of change of this vector: using the cross product rule we just discovered, this change is
63
Let’s simplify things: If a and b are 3-vectors, then a X b is the vector Given the vector a, let us define a* to be the matrix This means that we can write
64
This construct can be derived by considering what’s known as infinitesimal rotations. Refer to chapter 4.8 of Herbert Goldstein. Classical Mechanics. Addison Wesley, Reading, MA, 1950. for a more complete derivation of the a* matrix. Using the * notation, we can rewrite Then
65
Mass of a Body We’ll need to (conceptually) perform some integrations over the volume of our rigid body. Let’s imagine that a rigid body is made up of a large number of small particles (indexed from 1 to N). The mass of the ith particle is m i Each particle has a (constant) location r 0i in body space. The location of the ith particle in world space at time t:
66
Since a point can be represented at any time by Velocity of a Point (or Particle) Total velocity can then be expressed as Which can be rewritten as
67
The velocity of the ith point (particle) of a rigid body in world space Angular termLinear term
68
Bodies in Free Fall Basics Example Numeric Approximation Equations of Motion Orientation and Rotational Movement Center of Mass Forces Momentum Inertia Tensor Equations
69
Mass distribution: Typical approach a mass value to each of the object’s vertices
70
Center of mass coordinate system body space x(t) = location of the center of mass at time t
71
Rigid Body Simulation UpdateRigidBody(float time) { Force=ComputeTotalForce(); Torque=ComputeTotalTorque(); Momentum=Momentum+Force*time; Velocity=Momentum/Mass; Position=Position+Velocity*time; AngMomentum=AngMomentum+Torque*time; Matrix34 I=Matrix*RotInertia*Matrix.Inverse(); AngVelocity=I.Inverse()*AngMomentum; Matrix.Rotate(AngVelocity*time); }
72
Rigid Body Simulation UpdateRigidBody(float time) { Force=ComputeTotalForce(); Torque=ComputeTotalTorque(); Momentum=Momentum+Force*time; Velocity=Momentum/Mass; Position=Position+Velocity*time; AngMomentum=AngMomentum+Torque*time; Matrix34 I=Matrix*RotInertia*Matrix.Inverse(); AngVelocity=I.Inverse()*AngMomentum; Matrix.Rotate(AngVelocity*time); }
73
Bodies in Free Fall Basics Example Numeric Approximation Equations of Motion Orientation and Rotational Movement Center of Mass Forces Momentum Inertia Tensor Equations
74
We can apply forces to the object at any point Force Total force on an object is simply No information about where the forces are applied
75
Force acting on a rigid body due to some external influence (e.g. gravity, wind, contact forces) Acceleration due to the earth's gravity can be approximated by a constant acceleration, g, that is 32 f/sec/sec. Given an object's initial position (i.e., height) and the assumption that it was at rest at time t=0, then for any point in the future time we can plug the time into the equations above to get its acceleration, velocity and distance that it's fallen.
76
Gravity between two objects is a known force. Given two objects with comparable masses, M1 and M2, the force of gravity between two masses is given by: f = G*M1*M2/D where G = 6.67x10-11, a universal constant D = distance between centers of mass
77
object 1 mass: 1.0x10**13 radius: 60 initial position: 0 0 0 initial velocity: 0 0 0 object 2 mass: 1.0x10**11 radius: 30 initial position: 400 -200 0 initial velocity: -1.5 -0.125 0 500 time slices were computed with every tenth time slice displayed (i.e., ten samples per frame). The motion was produced by, for each time slice for both objects, updating the force, computing acceleration, calculating average velocity, updating position, and then updating velocity. Gravity Animation This animation shows motion produced by setting initial positions and velocities of two bodies and then letting gravity do the rest.
78
Simulation Loop
79
Check course’s website for more details, including other simulation codes…
80
Rigid Body Simulation UpdateRigidBody(float time) { Force=ComputeTotalForce(); Torque=ComputeTotalTorque(); Momentum=Momentum+Force*time; Velocity=Momentum/Mass; Position=Position+Velocity*time; AngMomentum=AngMomentum+Torque*time; Matrix34 I=Matrix*RotInertia*Matrix.Inverse(); AngVelocity=I.Inverse()*AngMomentum; Matrix.Rotate(AngVelocity*time); }
81
Torque describes the “rotational force” Torque Total torque on an object is simply Tells us about the force distribution over the object
82
Forces & Torques τ=dL/dt A torque is a change in angular momentum (similar to a force which is a change in linear momentum)
83
Offset Forces Torque resulting from offset force: τ=r×f Total force: Total torque:
84
Rigid Body Simulation UpdateRigidBody(float time) { Force=ComputeTotalForce(); Torque=ComputeTotalTorque(); Momentum=Momentum+Force*time; Velocity=Momentum/Mass; Position=Position+Velocity*time; AngMomentum=AngMomentum+Torque*time; Matrix34 I=Matrix*RotInertia*Matrix.Inverse(); AngVelocity=I.Inverse()*AngMomentum; Matrix.Rotate(AngVelocity*time); }
85
Bodies in Free Fall Basics Example Numeric Approximation Equations of Motion Orientation and Rotational Movement Center of Mass Forces Momentum Inertia Tensor Equations
86
Linear momentum of a particle is Linear Momentum Linear momentum of a rigid body is then density integration over the body
87
Linear momentum can be simplified as follows Linear Momentum Assuming constant mass gives
88
Angular momentum of a rigid body Angular Momentum Taking the time derivative inertia tensor Angular momentum is conserved for no torque
89
Angular Momentum L=Iω = AI 0 A -1 ω L=angular momentum I=rotational inertia ω=angular velocity A=3x3 orientation matrix
90
Rigid Body Simulation UpdateRigidBody(float time) { Force=ComputeTotalForce(); Torque=ComputeTotalTorque(); Momentum=Momentum+Force*time; Velocity=Momentum/Mass; Position=Position+Velocity*time; AngMomentum=AngMomentum+Torque*time; Matrix34 I=Matrix*RotInertia*Matrix.Inverse(); AngVelocity=I.Inverse()*AngMomentum; Matrix.Rotate(AngVelocity*time); }
91
Bodies in Free Fall Basics Example Numeric Approximation Equations of Motion Orientation and Rotational Movement Center of Mass Forces Momentum Inertia Tensor Equations
92
Describes how mass is distributed in the body Inertia Tensor Analogous to mass in linear velocity Measures the preferred axis of rotation Expensive to compute this at every time step
93
Rotational Inertia
94
Bodies in Free Fall Basics Example Numeric Approximation Equations of Motion Orientation and Rotational Movement Center of Mass Forces Momentum Inertia Tensor Equations
95
Position Orientation Linear Momentum Angular Momentum Rigid Body Equations of Motion State of the Object (change over time)
96
Rigid Body Equations of Motion Other Attributes (do not change over time) Mass Inertia Tensor Time-varying Inertia Tensor Angular Velocity Linear Velocity
97
Combining the equations Rigid Body Equations of Motion Discretize these continuous equations and integrate Time Derivative of the Object’s State Vector
98
Use quaternions to represent orientation Using Quaternions The update rule is then
99
Using quaternions gives Rigid Body Equations of Motion Discretize these continuous equations and integrate
100
Algorithm with collisions and contact Simulation Algorithm compute new statedetect collisions and backtrack compute and apply impulses compute and apply constraint forces current state next state collision state post-collision state
101
Simulation Loop
102
Check course’s website for more details, including other simulation codes…
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.