ICT Role in 21st Century Education & its Challenges.pptx
Physics for Game: Part1 - Basics
1. Part 1 - Physics Simulation Basics
Physically-based
Modeling
Young-Min Kang
Tongmyong University
Basic Concepts
1. Mass, Force, and Time
2. Kinematics based Simulation
3. Dynamics and Simple Numerical Integration
3. Mass
❖ Mass
❖ Resistance to being accelerated by force
❖ accumulated density (kg/m3)
❖ integration of density
m =
Z
⇢dV
4. Centre of Mass
❖ theory
❖ computation
xc =
R
x0dm
m
yc =
R
y0dm
m
zc =
R
z0dm
m
xc =
P
ximi
P
mi
yc =
P
yimi
P
mi
zc =
P
zimi
P
mi
cg =
P
(cgimi)
m
V dm at (x0,y0,z0)
5. Moment of Inertia
❖ angular mass
❖ rotation axis is important
❖ resistance to angular acceleration along the axis
I =
Z
m
r2
dm
rotation axis
r dm
7. Newton’s 2nd
law of motion
❖ force = mass x acceleration
❖ total force
❖ sum of all the exerted forces
❖ acceleration is determined by the total force
f = ma
X
fx = max
X
fy = may
X
fz = maz
fnet
fnet =
X
fi
a =
fnet
m
8. Linear Momentum and its Derivative
❖ Linear Momentum: G
❖ mass x velocity
❖ G = mv
❖ Derivative of Linear Momentum with respect to time
❖ therefore,
dG
dt
=
dmv
dt
= m
dv
dt
= ma
dG
dt
=
X
f
9. Rotational Motion
❖ Torque:
❖ “force” in rotation
❖ angular momentum
❖ sum of moments of momentum of all particles
⌧
⌧ = r ⇥ f
f
r
!
ri
vi
H =
X
ri ⇥ mivi vi = ! ⇥ ri
angular velocity
H =
X
ri ⇥ mi(! ⇥ ri)
10. Angular Momentum = A. Mass x A. Velocity
❖ Linar Momentum: G
❖ G = mv
❖ Angular Momentum
H =
X
ri ⇥ mi(! ⇥ ri)
H =
Z
!r2
dm
= !
Z
r2
dm
= !I = I!
Inertia Tensor
(Angular Mass)
Angular Velocity
11. Derivative of Angular Momentum
❖ dG/dt = total force
❖ dH/dt = total torque
dH
dt
=
dI!
dt
= I
d!
dt
= I↵
X
⌧ = I↵ ↵ = I 1
X
⌧
12. Tensor
❖ Tensor
❖ mathematical expression that has magnitude and direction
❖ its magnitude may not be unique depending on the direction
❖ typically used to represent properties of materials where these properties have different
magnitudes in different directions.
❖ Isotropic vs. Anisotropic
❖ isotropic: properties are the same in all direction
❖ anisotropic: properties vary depending on direction
❖ Moment of Inertia
❖ inertia tensor (in 3D)
❖ nine components to fully describe it for any arbitrary rotation. (3x3 matrix)
❖ property of the body that varies with the axis of rotation.
13. Time
❖ Classic Physics
❖ Time is “constant”
❖ Modern Physics
❖ Time is “variable”
❖ “Speed of Light” is constant: c
❖ c = 299,792,458 m/s
14. Relativistic Time - Just for fun
c = 2L/ t
mirrors are travelling in a spaceship
in the spaceship
on earth
if c is constant
time should be DIFFERENT
c = 2H/ te
c = 2L/ ts
We are not likely to use this relativistic time for this course…
15. Time Dilation
❖ Simple geometry
❖ time dilation
✓
c te
2
◆2
= L2
+
✓
v te
2
◆2
4L2
= c2
t2
e v2
t2
e
4L2
= (c2
v2
) t2
e
4L2
c2
= (1
v2
c2
) t2
e
2L
c
=
r
1
v2
c2
te
t =
r
1
v2
c2
te
te =
1
q
1 v2
c2
t
H2
= L2
+
✓
v te
2
◆2
16. Time and Animation
❖ Animation
❖ change over time
❖ Computer Animation
❖ computing the physical state in accordance with “time”
❖ We must measure the time
❖ Stop watch is needed
❖ Let’s make our own stop watch for animation
21. Kinematics
❖ Kinematics vs. Dynamics
❖ kinematics
❖ force is not considered
❖ location, velocity, and acceleration are considered as
❖ functions of time
❖ x(t), v(t), a(t)
❖ dynamics
❖ force plays the most essential role
❖ compute f(t)
❖ a(t) = f(t)/m
❖ v(t+dt) += a(t)dt
❖ x(t+dt) += v(t+dt)dt
f=ma
22. Statics, Kinetics, Kinematics and Dynamics
❖ Statics
❖ the study of equilibrium and its relation to forces
❖ Kinetics
❖ the study of motion and its relation to forces
❖ Kinematics
❖ the study of observed motions without regard for circumstances causing them
❖ Dynamics
❖ Statics + Kinetics
classical mechanics
23. Particle and Rigid Body
❖ Particle
❖ very very tiny object with mass
❖ volume can be ignored
❖ rocket trajectory analysis
❖ the volume of the rocket can be ignored
❖ rocket can be regarded a particle
❖ Rigid body (= idealised solid body)
❖ object with mass and volume
❖ the shape does not change in any condition
❖ valid animation of rigid body = rotation and translation
24. Velocity
❖ velocity
❖ a vector
❖ speed: the magnitude of velocity
❖ velocity = (speed + direction)
❖ direction of velocity
❖ moving direction
❖ magnitude of velocity
❖ ratio of moving distance to time
v =
s
t
ratio of displacement to time interval
25. Instantaneous Velocity
❖ Reduce the time interval
❖ the more precise velocity at the moment
❖ if the time interval approaches to 0
❖ instantaneous velocity
v = lim
t!0
s
t
=
ds
dt
26. displacement
❖ integration of velocity
❖ integration from t1 to t2
❖ equivalent to the displacement
❖ If we know the velocity
❖ we can predict where the particle will be located in the future
v = lim
t!0
s
t
=
ds
dt
vdt = ds
Z
vdt =
Z
ds
Z t2
t1
vdt =
Z s(t2)
s(t1)
ds
Z t2
t1
vdt = s(t2) s(t1) = s
27. Acceleration
❖ Average acceleration
❖ ratio of velocity change to the time interval
❖ Instantaneous acceleration
❖ Integration of acceleration
❖ velocity change
a = v/ t
a = lim
t!0
v/ t = dv/dt
adt = dv
Z t2
t1
adt =
Z v(t2)
v(t1)
dv = v
28. Constant Acceleration
❖ Simple problem for Kinematics
❖ example of constant acceleration: gravity
❖ gravitational acceleration
❖ magnitude: 9.81 m/s2
❖ direction: downwards (0,-1,0)
❖ We can easily “integrate the acceleration” to compute
❖ velocity change at every time
❖ this makes it possible to know the velocity at every time: v(t)
29. Gravitational Acceleration
❖ gravitational acceleration: g
❖ velocity change and the integration of acceleration
❖ If we know every thing at time t1
❖ We can easily predict the velocity at time t2
❖ if t1
=0 (t2
=t)
Z v(t2)
v(t1)
dv =
Z t2
t1
gdt
v2 v1 = g(t2 t1)
v2 = gt2 gt1 + v1
v2 = v1 + gt
30. Velocity as f(Displacement)
❖ Another differential equation
❖ Integration
❖ Relation between velocity and displacement
v
dv
dt
=
ds
dt
a
vdv = ads
Z v2
v1
vdv =
Z s2
s1
ads
1
2
v2
|v2
v1
= as|s2
s1
= gs|s2
s1
1
2
(v2
2
v1
2
) = g(s2 s1)
v2
2
= 2g(s2 s1) + v1
2
31. Location
❖ Velocity and displacement
❖ Integration
❖ Location at time t
vdt = ds
(v1 + gt)dt = ds
Z t
0
(v1 + gt)dt =
Z s2
s1
ds
v1t +
1
2
gt2
= s2 s1
s2 = v1t +
1
2
gt2
+ s1
38. Integration of Equations of Motion
❖ Newton’s 2nd law of motion
❖ f = ma
❖ In other words,
❖ dv = ?
f = m
dv
dt
fdt
m
= dv
if force is constant
f
m
(t2 t1) = v2 v1
f
m
t = v
Z t2
t1
fdt
m
=
Z v2
v1
dv
39. Initial Condition Problem
❖ Initial conditions
❖ x(t), v(t)
❖ location and velocity at current time t
❖ Problem
❖ predict x(t+dt) and v(t+dt)
❖ predict the location and velocity after a small time step dt
❖ Repeat with Initial conditions = x(t+dt), v(t+dt)
40. Velocity update
❖ Initial condition of velocity
❖ v1 = v(t)
❖ Velocity to be found
❖ v2 = v(t+dt)
❖ Velocity at the next frame
❖ or
f
m
(t2 t1) = v2 v1
f
m
t = v
v(t + t) = v(t) +
f(t)
m
t
v(t + t) = v(t) + a(t) t
41. Position Update
❖ Velocity and Position
❖ Numerical Integration
❖ If force (or acceleration) is known at time t
❖ We can “approximately” predict velocity and location at
time t+dt
v = ds/dt vdt = ds
v(t + t) t = s
42. Realtime Simulation
❖ compute force: f
❖ compute acceleration: a = f/m
❖ predict the velocity after time step
❖ Euler integration
❖ predict the location after time step
❖ Euler integration
v(t + t) = a t
x(t + t) = v(t + t) t
43. Simulation Code - main.cpp
void keyboardFunction(unsigned char key, int x, int y) {
if (key == 27) exit(0);
switch (key) {
case 's':
if(!myWatch.bRunning()) { Simulator->start(); myWatch.start(); }
else { myWatch.stop(); Simulator->stop(); }
break;
case 'p':
myWatch.pause(); Simulator->pause();
break;
case 'r':
myWatch.resume(); Simulator->resume();
default:
break;
}
}
void displayFunction(void) {
…
// check DT (in microsecond) from StopWatch and store it to "deltaTime" (in seconds)
deltaTime = myWatch.checkAndComputeDT() / 1000000.0;
currentTime = myWatch.getTotalElapsedTime() / 1000000.0;
Simulator->actions(deltaTime, currentTime);
glutSwapBuffers();
}
49. Concepts
❖ Force field : example - gravitational force
❖ Friction: a contact force that resists motion
❖ Fluid dynamic drag: resistance to objects moving in fluid
❖ Pressure: force per area
❖ Buoyancy: force pushing objects “upwards” when immersed in
a fluid
❖ Springs and dampers: elastically ties objects
❖ Force applies torque to an object, and make it “rotate.”
50. Force field
❖ Force field
❖ a vector field indicating the force exerted by on object
on another
❖ Very good example
❖ gravitational force field
❖ electromagnetic force field
51. Gravitational force field
❖ universal gravitational force
❖ G: gravitation constance
❖ r: distance between masses
❖ m_{1,2}: mass of each objects
❖ gravity on Earth
❖ mass of Earth:
❖ radius of Earth:
❖ gravitational acceleration
|fu| = Gm1m2/r2
6.673 ⇥ 10 11
(N · m2
)/kg2
5.98 ⇥ 1024
kg
6.38 ⇥ 106
m
Gmearth
r2
' (
6.673 ⇥ 5.98
6.382
) ⇥ 10m/s2
' 9.8034m/s2
52. friction
❖ resistance force due to the contacting surfaces
❖ contact force
❖ normal force: N is important
❖ two friction
❖ static friction: maximum friction
❖ kinetic friction
|fmax| = µsN
|fk| = µkN
54. Fluid dynamic drag
❖ similar to friction
❖ friction is also important component of drag
❖ but, it’s not the only one
❖ viscous drag for “slow-moving” objects (laminar)
❖ f = -C v
❖ for “fast-moving” objects (turbulence)
❖ f = -C v2
55. Pressure
❖ Pressure is not force
❖ pressure = force per unit area
❖ F = PA (force = pressure x area )
❖ P = F/A
❖ Pressure is important in simulating
❖ boats, hovercrafts,…
56. Buoyancy
❖ Different pressure in fluid
❖ Horizontal net force = 0
❖ Vertical net force = bottom force - top force
❖ F = PA
❖ Pressures: function(density, gravity)
❖ on top surface
❖ on bottom surface
Pt = ⇢ght
Pb = ⇢ghb
58. Spring force
❖ Hooke’s law
❖ force needed to extend or compress a spring by a distance x is proportional to
that distance
❖ f = -k x
❖ k: spring constant
❖ rest length of spring:
❖ current length of spring:
❖ force magnitude:
❖ force direction: obj1 and obj2 are linked and located at x1 and x2.
❖ and
|f| = ks(L r)
x1 x2
|x1 x2|
x1 x2
|x1 x2|
59. Damper
❖ Springs do not oscillate forever
❖ energy dissipation
❖ simple model
❖ damping force
fd = kd(v1 v2)
61. Force and Torque
❖ Force
❖ causes linear acceleration
❖ Torque
❖ causes angular acceleration
❖ Torque:
❖ a vector
❖ magnitude
❖ how quickly the angular velocity is changed
❖ |r x f |
❖ direction
❖ rotational axis = ( r x f ) / |r x f|
⌧
⌧ = r ⇥ f
f
r