physics simulation cse 191a: seminar on video game programming lecture 4: physics simulation ucsd,...
Post on 21-Dec-2015
222 views
TRANSCRIPT
![Page 1: Physics Simulation CSE 191A: Seminar on Video Game Programming Lecture 4: Physics Simulation UCSD, Spring, 2003 Instructor: Steve Rotenberg](https://reader035.vdocuments.us/reader035/viewer/2022062516/56649d6b5503460f94a49f24/html5/thumbnails/1.jpg)
Physics Simulation
CSE 191A: Seminar on Video Game Programming
Lecture 4: Physics Simulation
UCSD, Spring, 2003
Instructor: Steve Rotenberg
![Page 2: Physics Simulation CSE 191A: Seminar on Video Game Programming Lecture 4: Physics Simulation UCSD, Spring, 2003 Instructor: Steve Rotenberg](https://reader035.vdocuments.us/reader035/viewer/2022062516/56649d6b5503460f94a49f24/html5/thumbnails/2.jpg)
Physics Simulation
Particles
Rigid bodies
Deformable bodies
Fluid dynamics
Vehicle dynamics
Characters
![Page 3: Physics Simulation CSE 191A: Seminar on Video Game Programming Lecture 4: Physics Simulation UCSD, Spring, 2003 Instructor: Steve Rotenberg](https://reader035.vdocuments.us/reader035/viewer/2022062516/56649d6b5503460f94a49f24/html5/thumbnails/3.jpg)
DefinitionsKinematics: The study of motion without consideration of the underlying forces
Dynamics: Study of physical motion (or more abstractly, the study of change in physical systems)
Forward Dynamics: Computing motion resulting from applied forces
Inverse Dynamics: Computing forces required to generate desired motion
Mechanics, Statics, Kinetics
![Page 4: Physics Simulation CSE 191A: Seminar on Video Game Programming Lecture 4: Physics Simulation UCSD, Spring, 2003 Instructor: Steve Rotenberg](https://reader035.vdocuments.us/reader035/viewer/2022062516/56649d6b5503460f94a49f24/html5/thumbnails/4.jpg)
Particles
![Page 5: Physics Simulation CSE 191A: Seminar on Video Game Programming Lecture 4: Physics Simulation UCSD, Spring, 2003 Instructor: Steve Rotenberg](https://reader035.vdocuments.us/reader035/viewer/2022062516/56649d6b5503460f94a49f24/html5/thumbnails/5.jpg)
Kinematics of Particles
Position x
Velocity v = dx/dt
Acceleration a = dv/dt = d2x/dt2
![Page 6: Physics Simulation CSE 191A: Seminar on Video Game Programming Lecture 4: Physics Simulation UCSD, Spring, 2003 Instructor: Steve Rotenberg](https://reader035.vdocuments.us/reader035/viewer/2022062516/56649d6b5503460f94a49f24/html5/thumbnails/6.jpg)
Motion Under Uniform Acceleration
Accelerationa=a0
Velocity
Position 002
0
00
xva2
1vx
vaav
ttdt
tdt
![Page 7: Physics Simulation CSE 191A: Seminar on Video Game Programming Lecture 4: Physics Simulation UCSD, Spring, 2003 Instructor: Steve Rotenberg](https://reader035.vdocuments.us/reader035/viewer/2022062516/56649d6b5503460f94a49f24/html5/thumbnails/7.jpg)
Mass & Momentum
Mass m
Momentum p = mv
Force f = dp/dt = m(dv/dt) = ma
![Page 8: Physics Simulation CSE 191A: Seminar on Video Game Programming Lecture 4: Physics Simulation UCSD, Spring, 2003 Instructor: Steve Rotenberg](https://reader035.vdocuments.us/reader035/viewer/2022062516/56649d6b5503460f94a49f24/html5/thumbnails/8.jpg)
Forces
Forces cause change in momentum (accelerations)
Multiple forces can add up to a single total force:
itotal ff
![Page 9: Physics Simulation CSE 191A: Seminar on Video Game Programming Lecture 4: Physics Simulation UCSD, Spring, 2003 Instructor: Steve Rotenberg](https://reader035.vdocuments.us/reader035/viewer/2022062516/56649d6b5503460f94a49f24/html5/thumbnails/9.jpg)
Newton’s Laws
1. A body at rest tends to stay at rest, and a body in motion tends to stay in motion, unless acted upon by some force.
2. Forces lead to changes in momentum and therefore accelerations:
f=ma
3. Every action has an equal and opposite reaction.
fij=-fji
![Page 10: Physics Simulation CSE 191A: Seminar on Video Game Programming Lecture 4: Physics Simulation UCSD, Spring, 2003 Instructor: Steve Rotenberg](https://reader035.vdocuments.us/reader035/viewer/2022062516/56649d6b5503460f94a49f24/html5/thumbnails/10.jpg)
Gravity
Gravity near Earth’s surface is constant:
f=mg (g = -9.8 m/s2)
Gravity for distant objects:
f=Gm1m2/r2 (G=6.673×10-11 m3/kg·s2)
![Page 11: Physics Simulation CSE 191A: Seminar on Video Game Programming Lecture 4: Physics Simulation UCSD, Spring, 2003 Instructor: Steve Rotenberg](https://reader035.vdocuments.us/reader035/viewer/2022062516/56649d6b5503460f94a49f24/html5/thumbnails/11.jpg)
Particle Simulation
UpdateParticle(float time) {Force=ComputeTotalForce();
Momentum=Momentum+Force*time;
Velocity=Momentum/Mass;
Position=Position+Velocity*time;
}
![Page 12: Physics Simulation CSE 191A: Seminar on Video Game Programming Lecture 4: Physics Simulation UCSD, Spring, 2003 Instructor: Steve Rotenberg](https://reader035.vdocuments.us/reader035/viewer/2022062516/56649d6b5503460f94a49f24/html5/thumbnails/12.jpg)
IntegrationExplicit Euler method:
v=v0+aΔt
x=x0+vΔtMany other methods:
Implicit EulerRunge-KuttaAdams, Adams-Moulton, Adams-BashforthCrank-NicholsonMultipointLeapfrogDuFort-Frankel
![Page 13: Physics Simulation CSE 191A: Seminar on Video Game Programming Lecture 4: Physics Simulation UCSD, Spring, 2003 Instructor: Steve Rotenberg](https://reader035.vdocuments.us/reader035/viewer/2022062516/56649d6b5503460f94a49f24/html5/thumbnails/13.jpg)
Simulation Issues
Stability
Accuracy
Convergence
Performance
![Page 14: Physics Simulation CSE 191A: Seminar on Video Game Programming Lecture 4: Physics Simulation UCSD, Spring, 2003 Instructor: Steve Rotenberg](https://reader035.vdocuments.us/reader035/viewer/2022062516/56649d6b5503460f94a49f24/html5/thumbnails/14.jpg)
Forces
![Page 15: Physics Simulation CSE 191A: Seminar on Video Game Programming Lecture 4: Physics Simulation UCSD, Spring, 2003 Instructor: Steve Rotenberg](https://reader035.vdocuments.us/reader035/viewer/2022062516/56649d6b5503460f94a49f24/html5/thumbnails/15.jpg)
Spring-Damper
Spring-damper: f=-kx-cv
k=spring constant
x=distance from rest state
c=damping factor
v=velocity along spring axis
![Page 16: Physics Simulation CSE 191A: Seminar on Video Game Programming Lecture 4: Physics Simulation UCSD, Spring, 2003 Instructor: Steve Rotenberg](https://reader035.vdocuments.us/reader035/viewer/2022062516/56649d6b5503460f94a49f24/html5/thumbnails/16.jpg)
Aerodynamic Drag
Drag force: f=(1/2)ρaccdv2
ρ=fluid density
ac=cross sectional area
cd=coefficient of drag (geometric constant based on shape of object, usually between 0 and 1, but can be higher)
v=velocity of the object relative to velocity of the fluid
Note: for simple cases, (1/2)ρaccd is constant
![Page 17: Physics Simulation CSE 191A: Seminar on Video Game Programming Lecture 4: Physics Simulation UCSD, Spring, 2003 Instructor: Steve Rotenberg](https://reader035.vdocuments.us/reader035/viewer/2022062516/56649d6b5503460f94a49f24/html5/thumbnails/17.jpg)
Friction
Static friction: f ≤ fnμs
Dynamic friction: f = fnμd
fn=normal force
μs=coefficient of static friction
μd=coefficient of dynamic friction
![Page 18: Physics Simulation CSE 191A: Seminar on Video Game Programming Lecture 4: Physics Simulation UCSD, Spring, 2003 Instructor: Steve Rotenberg](https://reader035.vdocuments.us/reader035/viewer/2022062516/56649d6b5503460f94a49f24/html5/thumbnails/18.jpg)
Force Fields
Generic force fields can be created that use arbitrary rules to define a force at some location: f=f(x)
Examples: vortex, attractors, turbulence, torus…
![Page 19: Physics Simulation CSE 191A: Seminar on Video Game Programming Lecture 4: Physics Simulation UCSD, Spring, 2003 Instructor: Steve Rotenberg](https://reader035.vdocuments.us/reader035/viewer/2022062516/56649d6b5503460f94a49f24/html5/thumbnails/19.jpg)
Collisions: Impulse
Impulse: J=Δp
An impulse is a finite change in momentum
Impulses are essentially large forces acting over a small time
Modified momentum update:
p=p0+fΔt+J
![Page 20: Physics Simulation CSE 191A: Seminar on Video Game Programming Lecture 4: Physics Simulation UCSD, Spring, 2003 Instructor: Steve Rotenberg](https://reader035.vdocuments.us/reader035/viewer/2022062516/56649d6b5503460f94a49f24/html5/thumbnails/20.jpg)
Rigid Bodies
![Page 21: Physics Simulation CSE 191A: Seminar on Video Game Programming Lecture 4: Physics Simulation UCSD, Spring, 2003 Instructor: Steve Rotenberg](https://reader035.vdocuments.us/reader035/viewer/2022062516/56649d6b5503460f94a49f24/html5/thumbnails/21.jpg)
Rotational Inertia
zzzyzx
yzyyyx
xzxyxx
III
III
III
I
dmxy
dmzy
xy
xx
)(I
)(I 22
![Page 22: Physics Simulation CSE 191A: Seminar on Video Game Programming Lecture 4: Physics Simulation UCSD, Spring, 2003 Instructor: Steve Rotenberg](https://reader035.vdocuments.us/reader035/viewer/2022062516/56649d6b5503460f94a49f24/html5/thumbnails/22.jpg)
Principle Axes
zz
yy
xx
I00
0I0
00I
I0
10AAII
![Page 23: Physics Simulation CSE 191A: Seminar on Video Game Programming Lecture 4: Physics Simulation UCSD, Spring, 2003 Instructor: Steve Rotenberg](https://reader035.vdocuments.us/reader035/viewer/2022062516/56649d6b5503460f94a49f24/html5/thumbnails/23.jpg)
Angular Momentum
L=Iω = AI0A-1ω
L=angular momentum
I=rotational inertia
ω=angular velocity
A=3x3 orientation matrix
![Page 24: Physics Simulation CSE 191A: Seminar on Video Game Programming Lecture 4: Physics Simulation UCSD, Spring, 2003 Instructor: Steve Rotenberg](https://reader035.vdocuments.us/reader035/viewer/2022062516/56649d6b5503460f94a49f24/html5/thumbnails/24.jpg)
Forces & Torques
τ=dL/dt
A torque is a change in angular momentum (similar to a force which is a change in linear momentum)
![Page 25: Physics Simulation CSE 191A: Seminar on Video Game Programming Lecture 4: Physics Simulation UCSD, Spring, 2003 Instructor: Steve Rotenberg](https://reader035.vdocuments.us/reader035/viewer/2022062516/56649d6b5503460f94a49f24/html5/thumbnails/25.jpg)
Offset Forces
Torque resulting from offset force: τ=r×f
Total force:
Total torque:
iffcg
)f(r iicg
![Page 26: Physics Simulation CSE 191A: Seminar on Video Game Programming Lecture 4: Physics Simulation UCSD, Spring, 2003 Instructor: Steve Rotenberg](https://reader035.vdocuments.us/reader035/viewer/2022062516/56649d6b5503460f94a49f24/html5/thumbnails/26.jpg)
Rigid Body SimulationUpdateRigidBody(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);
}
![Page 27: Physics Simulation CSE 191A: Seminar on Video Game Programming Lecture 4: Physics Simulation UCSD, Spring, 2003 Instructor: Steve Rotenberg](https://reader035.vdocuments.us/reader035/viewer/2022062516/56649d6b5503460f94a49f24/html5/thumbnails/27.jpg)
Rigid Body Collisions
![Page 28: Physics Simulation CSE 191A: Seminar on Video Game Programming Lecture 4: Physics Simulation UCSD, Spring, 2003 Instructor: Steve Rotenberg](https://reader035.vdocuments.us/reader035/viewer/2022062516/56649d6b5503460f94a49f24/html5/thumbnails/28.jpg)
Advanced Topics
Contact: resting, sliding, rolling, stacking
Articulated bodies
Deformable bodies
Cloth
Fracture
Fluid dynamics
Vehicle dynamics
![Page 29: Physics Simulation CSE 191A: Seminar on Video Game Programming Lecture 4: Physics Simulation UCSD, Spring, 2003 Instructor: Steve Rotenberg](https://reader035.vdocuments.us/reader035/viewer/2022062516/56649d6b5503460f94a49f24/html5/thumbnails/29.jpg)
Using Physics in Games
Use physics for the things it is good at
Cheating
Clamping
![Page 30: Physics Simulation CSE 191A: Seminar on Video Game Programming Lecture 4: Physics Simulation UCSD, Spring, 2003 Instructor: Steve Rotenberg](https://reader035.vdocuments.us/reader035/viewer/2022062516/56649d6b5503460f94a49f24/html5/thumbnails/30.jpg)
Conclusion
![Page 31: Physics Simulation CSE 191A: Seminar on Video Game Programming Lecture 4: Physics Simulation UCSD, Spring, 2003 Instructor: Steve Rotenberg](https://reader035.vdocuments.us/reader035/viewer/2022062516/56649d6b5503460f94a49f24/html5/thumbnails/31.jpg)
Preview of Next Week
Character animation
Skeletons
Skin
Inverse kinematics
Animation
Locomotion
![Page 32: Physics Simulation CSE 191A: Seminar on Video Game Programming Lecture 4: Physics Simulation UCSD, Spring, 2003 Instructor: Steve Rotenberg](https://reader035.vdocuments.us/reader035/viewer/2022062516/56649d6b5503460f94a49f24/html5/thumbnails/32.jpg)
Physics References
Coutinho, “Dynamic Simulation of Multibody Systems”
Bourg, “Physics for Game Developers”