SlideShare a Scribd company logo
1 of 90
Download to read offline
Game Programming
Physics
Nick PrΓΌhs
Objectives
β€’ To understand the basics of kinematics and dynamics in games
β€’ To get an overview of a simple numeric integration approach for
phyics
β€’ To learn how to resolve rigid body collisions
2 / 83
Motivation
β€’ Next thing to make your game feel right, besides graphics and
sound
β€’ Can be integral part of your gameplay
β€’ Usually just a close approximation to real physics will be enough
β€œSpeedy thing goes in, speedy thing comes out.”
- GLaDOS
3 / 83
Kinematics vs. Dynamics
β€’ Kinematics is the study of movement over time.
β–ͺ Doesn’t matter why things are where there are now
β–ͺ Doesn’t matter what causes the movement
β–ͺ Just deals with the actual movement itself
β€’ Dynamics is the study of forces and masses that cause kinematic
quantities to change over time.
4 / 83
Kinematics – Velocity
Velocity is the rate of change of position over time.
5 / 83
𝒗 =
𝒅𝒙
𝒅𝒕
Kinematics – Acceleration
Acceleration is the rate of change of velocity over time.
6 / 83
𝒂 =
𝒅𝒗
𝒅𝒕
Change of velocity
Solving for v and integrating yields the velocity after a given time t,
aside from some unknown constant C:
7 / 83
𝐚 =
𝐝𝐯
𝐝𝐭
𝒅𝒗 = 𝒂 𝒅𝒕
𝒗(𝒕) = ΰΆ± 𝒂 𝒅𝒕
𝒗(𝒕) = 𝒂𝒕 + π‘ͺ
Change of velocity
We can find the unknown constant to be the initial velocity by
computing the initial velocity:
8 / 83
𝒗 = 𝒂𝒕 + π‘ͺ
𝒗 𝟎 = πŸŽπ’‚ + π‘ͺ
𝒗 𝟎 = π‘ͺ
Change of velocity
Thus, given the acceleration a and initial velocity v0, the velocity after
any given time t is
9 / 83
𝒗(𝒕) = 𝒂𝒕 + 𝒗 𝟎
Change of position
The position after any given time t can be found the same way:
10 / 83
𝐯 =
𝐝𝐱
𝐝𝐭
𝒅𝒙 = 𝒗 𝒅𝒕
𝒅𝒙 = 𝒂𝒕 + 𝒗 𝟎 𝒅𝒕
𝒙(𝒕) = ΰΆ± 𝒂𝒕 + 𝒗 𝟎 𝒅𝒕
𝒙(𝒕) =
𝟏
𝟐
𝒂𝒕 𝟐
+ 𝒗 𝟎 𝒕 + 𝒙 𝟎
Kinematics – Momentum
Momentum is the product of the mass and velocity of an object.
11 / 83
𝒑 = π’Žπ’—
Dynamics – Force
Force is the rate of change of momentum over time (Newton’s Second
Law).
12 / 83
𝑭 =
𝒅𝒑
𝒅𝒕
Change of acceleration
For constant mass, force and acceleration are related as follows:
13 / 83
𝐹 = 𝐝𝐩
𝐝𝐭
definition force
= 𝒅 π’Žπ’—
𝒅𝒕
definition
momentum
=
π’Ž
𝒅𝒗
𝒅𝒕
constant mass
= π’Žπ’‚ definition
acceleration
Numerical Integration
β€’ Start at a certain initial position and velocity
β€’ Take a small step forward in time to find the velocity and position at
the next time value
β€’ Do this repeatedly to go forward in time in small increments, each
time taking the results of the previous integration as the starting
point for the next
14 / 83
Explicit Euler Integration
C#
15 / 83
// Fixed time step and constant force.
const float dt = 1;
const float force = 10.0f;
// Create new body without initial velocity.
var body = new Body
{
Mass = 1.0f,
Position = 0.0f,
Velocity = 0.0f
};
// Simulate ten steps.
for (float t = 1; t <= 10; t++)
{
body.Position += body.Velocity * dt;
var acceleration = force / body.Mass;
body.Velocity += acceleration * dt;
}
Explicit Euler Integration
t position velocity
1 0 10
2 10 20
3 30 30
4 60 40
5 100 50
6 150 60
7 210 70
8 280 80
9 360 90
10 450 100
16 / 83
Explicit Euler integration with dt = 1
Inaccuracy
𝒙 = 𝟎. πŸ“π’‚π’• 𝟐
+ 𝒗𝒕 + 𝒙 𝟎 with 𝒂 = 𝟏𝟎, 𝒕 = 𝟏𝟎, 𝒗 = 𝟎, 𝒙 𝟎 =
𝟎
= 0.5 Γ— 10 Γ— 102
+ 0𝑑
+ 0
= 0.5 Γ— 10 Γ— 100
= 500
17 / 83
Exact physical position at t = 10 is:
This implies an error of (500 – 450) / 500 = 10% after only ten seconds for dt = 1!
Explicit Euler Integration
t position velocity
1 4.5 10
2 19 20
3 43.5 30
4 78 40
5 122.5 50
6 177 60
7 241.5 70
8 316 80
9 400.5 90
10 495 100
18 / 83
Explicit Euler integration with dt = 0.1
Variable vs. fixed time steps
Usually, we’re working with variable time steps in game simulations:
However, this approach has major drawbacks in when simulating
physics.
19 / 83
public void Update(float deltaTime)
{
// Do something awesome here...
}
Variable time steps in physics
β€’ Physics will β€œfeel” slightly different depending on your framerate
β€’ Fast objects won’t collide as expected
β€’ Spring simulation will explode to infinity
20 / 83
Fixed time steps in physics
β€’ In order to ensure a fixed time step that feels right, we need to have
the physics simulation …
β–ͺ Don’t update too often if frames are rendered very fast
β–ͺ Catch up if frames are rendered very slowly
β€’ This is achieved by accumulating deltas across frames, updating
several times per frame if necessary.
21 / 83
Fixed time steps in physics
C#
22 / 83
var random = new Random();
// Fixed time step and constant force.
const float fixedDt = 1f / 60f;
const float force = 10.0f;
float totalTime = 0.0f;
float accumulatedDt = 0.0f;
// Create new body without initial velocity.
var body = new Body { Mass = 1.0f, Position = 0.0f, Velocity = 0.0f };
// Simulate ten steps.
for (int t = 0; t <= 10; t++)
{
// Random delta.
float dt = (float)random.NextDouble() / 45;
totalTime += dt;
accumulatedDt += dt;
while (accumulatedDt > fixedDt)
{
var acceleration = force / body.Mass;
body.Velocity += acceleration * fixedDt;
body.Position += body.Velocity * fixedDt;
accumulatedDt -= fixedDt;
}
}
Fixed time steps in physics
t dt accumulatedTime position velocity
0 0.022 0.022 0 0
0 0.022 0.005 0.003 0.167
1 0.020 0.026 0.003 0.167
1 0.020 0.009 0.008 0.333
2 0.005 0.014 0.008 0.333
3 0.003 0.017 0.008 0.333
3 0.003 0 0.017 0.500
4 0.011 0.011 0.017 0.500
5 0.019 0.030 0.017 0.500
5 0.019 0.013 0.028 0.667
23 / 83
Fixed time steps with dt = 1 / 60 = 0.016
Gotcha!
Accumulated time steps can cause an
infinite loop if your physics simulation
takes more time than your fixed time
step!
Clamp at a maximum number of
simulation steps per frame to avoid this.
24 / 83
Rigid bodies
β€’ All of the above assumes a constant mass concentrated in a single
point
β€’ However, in games we have to deal with bodies having their mass
distributed over their area (or volume)
β€’ Rigid bodies are shapes that don’t change or deform during physics
simulation
β€’ We’ll focus on these for the time being
25 / 83
Rigid bodies
β€’ For the time being, we’ll model our rigid body as a set of point
masses
β€’ The total momentum of the rigid body equals the sum of all
momentums of all points that make up that body
𝑝 π‘…π‘–π‘”π‘–π‘‘π‘π‘œπ‘‘π‘¦ = ෍
𝑖
π‘šπ‘– 𝑣𝑖
26 / 83
Center of mass
We define the center of mass of a rigid body as the linear combination
of the position vectors of all points that make up that body, weighted by
their masses, divided by the total mass of the body.
π‘₯ πΆπ‘’π‘›π‘‘π‘’π‘Ÿπ‘‚π‘“π‘€π‘Žπ‘ π‘  =
σ𝑖 π‘₯𝑖 π‘šπ‘–
𝑀 π‘…π‘–π‘”π‘–π‘‘π‘π‘œπ‘‘π‘¦
27 / 83
Center of mass
Let’s modify this equation a bit:
28 / 12
π‘₯ πΆπ‘’π‘›π‘‘π‘’π‘Ÿπ‘‚π‘“π‘€π‘Žπ‘ π‘  = σ𝑖 π‘₯𝑖 π‘šπ‘–
𝑀 π‘…π‘–π‘”π‘–π‘‘π‘π‘œπ‘‘π‘¦
𝑀 π‘…π‘–π‘”π‘–π‘‘π‘π‘œπ‘‘π‘¦ π‘₯ πΆπ‘’π‘›π‘‘π‘’π‘Ÿπ‘‚π‘“π‘€π‘Žπ‘ π‘  =
෍
𝑖
π‘₯𝑖 π‘šπ‘–
multiplied with
𝑀 π‘…π‘–π‘”π‘–π‘‘π‘π‘œπ‘‘π‘¦
𝑑(𝑀 π‘…π‘–π‘”π‘–π‘‘π‘π‘œπ‘‘π‘¦ π‘₯ πΆπ‘’π‘›π‘‘π‘’π‘Ÿπ‘‚π‘“π‘€π‘Žπ‘ π‘ )
𝑑𝑑
=
෍
𝑖
𝑑(π‘₯𝑖 π‘šπ‘–)
𝑑𝑑
𝑑/𝑑𝑑
=
෍
𝑖
π‘šπ‘–
𝑑π‘₯𝑖
𝑑𝑑
constant mass
=
෍
𝑖
π‘šπ‘– 𝑣𝑖
definition velocity
= 𝑝 π‘…π‘–π‘”π‘–π‘‘π‘π‘œπ‘‘π‘¦ definition
momentum
Center of mass
Now, let’s take a look at the second part again:
29 / 83
𝑑(𝑀 π‘…π‘–π‘”π‘–π‘‘π‘π‘œπ‘‘π‘¦ π‘₯ πΆπ‘’π‘›π‘‘π‘’π‘Ÿπ‘‚π‘“π‘€π‘Žπ‘ π‘ )
𝑑𝑑
=
𝑀 π‘…π‘–π‘”π‘–π‘‘π‘π‘œπ‘‘π‘¦
𝑑π‘₯ πΆπ‘’π‘›π‘‘π‘’π‘Ÿπ‘‚π‘“π‘€π‘Žπ‘ π‘ 
𝑑𝑑
constant
mass
= 𝑀 π‘…π‘–π‘”π‘–π‘‘π‘π‘œπ‘‘π‘¦ 𝑣 πΆπ‘’π‘›π‘‘π‘’π‘Ÿπ‘‚π‘“π‘€π‘Žπ‘ π‘  definitio
n
velocity
Center of mass
Combining both results yields a stunning property
of the center of mass!
𝒑 π‘Ήπ’Šπ’ˆπ’Šπ’…π’ƒπ’π’…π’š = 𝑴 π‘Ήπ’Šπ’ˆπ’Šπ’…π’ƒπ’π’…π’š 𝒗 π‘ͺ𝒆𝒏𝒕𝒆𝒓𝑢𝒇𝑴𝒂𝒔𝒔
30 / 83
Center of mass
Combining both results yields a stunning property
of the center of mass!
𝒑 π‘Ήπ’Šπ’ˆπ’Šπ’…π’ƒπ’π’…π’š = 𝑴 π‘Ήπ’Šπ’ˆπ’Šπ’…π’ƒπ’π’…π’š 𝒗 π‘ͺ𝒆𝒏𝒕𝒆𝒓𝑢𝒇𝑴𝒂𝒔𝒔
For finding the momentums of any rigid body, we
can treat that body as single point mass and
velocity.
31 / 83
Center of mass
This further applies to forces, as well:
32 / 83
πΉπ‘…π‘–π‘”π‘–π‘‘π‘π‘œπ‘‘π‘¦ = 𝑑𝑝 π‘…π‘–π‘”π‘–π‘‘π‘π‘œπ‘‘π‘¦
𝑑𝑑
= 𝑑(𝑀 π‘…π‘–π‘”π‘–π‘‘π‘π‘œπ‘‘π‘¦ 𝑣 πΆπ‘’π‘›π‘‘π‘’π‘Ÿπ‘‚π‘“π‘€π‘Žπ‘ π‘ )
𝑑𝑑
as we’ve just proven
=
𝑀 π‘…π‘–π‘”π‘–π‘‘π‘π‘œπ‘‘π‘¦
𝑑𝑣 πΆπ‘’π‘›π‘‘π‘’π‘Ÿπ‘‚π‘“π‘€π‘Žπ‘ π‘ 
𝑑𝑑
constant mass
= 𝑀 π‘…π‘–π‘”π‘–π‘‘π‘π‘œπ‘‘π‘¦ π‘Ž πΆπ‘’π‘›π‘‘π‘’π‘Ÿπ‘‚π‘“π‘€π‘Žπ‘ π‘  definition
acceleration
Center of mass
This further applies to forces, as well:
We can treat all forces acting our rigid body as if
their sum is acting on a point at the center of mass
with the mass of the entire body.
33 / 83
πΉπ‘…π‘–π‘”π‘–π‘‘π‘π‘œπ‘‘π‘¦ = 𝑑𝑝 π‘…π‘–π‘”π‘–π‘‘π‘π‘œπ‘‘π‘¦
𝑑𝑑
= 𝑑(𝑀 π‘…π‘–π‘”π‘–π‘‘π‘π‘œπ‘‘π‘¦ 𝑣 πΆπ‘’π‘›π‘‘π‘’π‘Ÿπ‘‚π‘“π‘€π‘Žπ‘ π‘ )
𝑑𝑑
as we’ve just proven
=
𝑀 π‘…π‘–π‘”π‘–π‘‘π‘π‘œπ‘‘π‘¦
𝑑𝑣 πΆπ‘’π‘›π‘‘π‘’π‘Ÿπ‘‚π‘“π‘€π‘Žπ‘ π‘ 
𝑑𝑑
constant mass
= 𝑀 π‘…π‘–π‘”π‘–π‘‘π‘π‘œπ‘‘π‘¦ π‘Ž πΆπ‘’π‘›π‘‘π‘’π‘Ÿπ‘‚π‘“π‘€π‘Žπ‘ π‘  definition
acceleration
Rotation
β€’ So far, we’ve been talking all about linear momentum and linear
acceleration.
β€’ Now, we want to figure out how forces applied to our rigid bodies
make them rotate.
β€’ Where these forces are applied to the body will play an important
role.
34 / 83
Kinematics – Orientation
The orientation Ω of an object is the angular difference between the
world coordinate system and a coordinate system fixed in that object, in
radians.
35 / 83
Kinematics – Angular Velocity
Angular Velocity is the rate of change of orientation over time.
36 / 83
𝝎 =
𝒅Ω
𝒅𝒕
Kinematics – Angular Acceleration
Angular Acceleration is the rate of change of angular velocity over time.
37 / 83
𝜢 =
𝒅 πœ”
𝒅𝒕
Linear Velocity from Angular Velocity
β€’ We often need to find the velocity of an arbitrary point on our object
β–ͺ i.e. velocity of colliding points to compute how hard they hit each
other
β€’ Without rotation, the velocity of any point in the body is the same
β–ͺ Velocity of the center of mass
β€’ With rotation, every point might have a different velocity
β–ͺ Obviously, we can’t keep track of the velocity of each of the
infinity of points
38 / 83
Linear Velocity from Angular Velocity
Claim:
The linear velocity of any point P inside an object that is rotating about
its origin O, but not translating, is given by the following equation:
39 / 83
𝒗 𝑷 = πŽπ‘Άπ‘·βŠ₯
Hint
In 2D, the perpendicular of a
vector (x, y) is (-y, x).
40 / 83
Linear Velocity from Angular Velocity - Proof
πŽπ‘Άπ‘·βŠ₯ has the correct magnitude, because
and Ω 𝑢𝑷 is the length P is moving when moving Ω
radians along the arc whose radius vector is 𝑢𝑷 , by
definition of radians. 41 / 83
πœ”π‘‚π‘ƒβŠ₯
= πœ” 𝑂𝑃βŠ₯
= πœ” 𝑂𝑃 perpendiculary
doesn’t change
length
= 𝑑Ω
𝑑𝑑
𝑂𝑃
definition πœ”
= 𝑑(Ω 𝑂𝑃 )
𝑑𝑑
𝑂𝑃 is constant
Linear Velocity from Angular Velocity - Proof
πŽπ‘Άπ‘·βŠ₯ has the correct direction, because a point
rotating around another fixed point can only move
perpendicularly to the vector between the points,
or the movement wouldn’t be a simple rotation.
πŽπ‘Άπ‘·βŠ₯ has the correct sign, because we’re
measuring Ω in the counterclockwise direction. Ο‰
is positive when the point is rotating
counterclockwise. The perpendicular operator
points in the counterclockwise direction relative to
the radius vector.
42 / 83
Linear Velocity from Angular Velocity
The linear velocity of any point P inside an object that is rotating about
its origin O, but not translating, is given by the following equation:
43 / 83
𝒗 𝑷 = πŽπ‘Άπ‘·βŠ₯
Linear Velocity from Angular Velocity
The linear velocity of any point P inside an object that is rotating about
its origin O, and is translating, is given by the following equation:
44 / 83
?
Chasles’ Theorem
β€’ Chasles’ Theorem breaks up motion into linear and angular
components.
β€’ We consider any movement of our rigid body as
β–ͺ translating a single point in the body
β–ͺ rotating the rest of the body around that point
45 / 83
Chasles’ Theorem
The linear velocity of any point P inside a moving object that is rotating
about its origin O is given by the following equation:
(without proof)
46 / 83
𝒗 𝑷 = 𝒗 𝑢 + πŽπ‘Άπ‘·βŠ₯
Kinematics – Angular Momentum
The Angular Momentum of a point P tells us how much of the linear
momentum pP of P is rotating around the origin.
47 / 83
𝑳 𝑢𝑷 = 𝑢𝑷βŠ₯ Γ— 𝒑 𝑷
Kinematics – Angular Momentum
The Angular Momentum of a point P tells us how much of the linear
momentum pP of P is rotating around the origin.
Note how angular momentum of a point P needs a reference (here: O),
in contrast to linear momentum.
48 / 83
𝑳 𝑢𝑷 = 𝑢𝑷βŠ₯ Γ— 𝒑 𝑷
Dynamics – Torque
Torque is the rate of change of angular momentum over time.
49 / 83
𝝉 𝑢𝑷 =
𝒅 𝑳 𝑢𝑷
𝒅𝒕
Dynamics – Torque
We can use the torque to determine how much of the force applied at
point P is causing the object to rotate:
50 / 83
𝜏 𝑂𝑃 = dLOP
dt
definition torque
= d(OPβŠ₯Γ— pP)
dt
definition
angular momentum
=
OPβŠ₯ Γ—
dpp
dt
+
dOPβŠ₯
dt
Γ— pp
product rule
= (OPβŠ₯ Γ— 𝐹𝑃) + (vP Γ— 𝑝P) def. linear force,
def. linear velocity
= OPβŠ₯ Γ— 𝐹𝑃
velocity and momentum of
P are parallel
Calculating Angular Momentum
Again, just like change in velocity can be numerically integrated using
acceleration, change in angular momentum can be integrated using
torque, from an applied force and position of application:
𝐿 𝑂𝑃 𝑑 = ΰΆ± 𝜏 𝑂𝑃 𝑑𝑑 = ΰΆ± OPβŠ₯ Γ— 𝐹𝑃 𝑑𝑑
51 / 83
Moment of Inertia
β€’ The moment of inertia I of an object is a measure of how hard it is to
rotate the object about its center of mass.
β€’ It is the sum of the squared distances from the center of mass to
each other point in the body, scaling each squared distance by the
mass of the respective point.
𝐼 = ෍
𝑖
π‘šπ‘–OiβŠ₯
2
52 / 83
Moment of Inertia
The moment of inertia can be used to derive the total angular
momentum:
𝐿 =
෍
𝑖
OiβŠ₯ Γ— pi
definition
angular momentum
=
෍
𝑖
OiβŠ₯ Γ— (π‘šπ‘– 𝑣𝑖)
Definition linear momentum
=
෍
𝑖
OiβŠ₯ Γ— (π‘šπ‘– πœ”π‘‚π‘–βŠ₯)
Linear velocity from angular
velocity
=
πœ” ෍
𝑖
OiβŠ₯ Γ— (π‘šπ‘– 𝑂𝑖βŠ₯)
Angular velocity same for all
points i
=
πœ” ෍
𝑖
π‘šπ‘–OiβŠ₯
2
= πœ”πΌ definition moment of intertia
Hint
As the moment of inertia is
based on the mass and relative
position of all points of a rigid
body, only, it is constant and has
to be computed only once!
54 / 83
Dynamics – Torque
Integration shows how torque and angular acceleration are related:
𝜏 = 𝑑𝐿
𝑑𝑑
definition torque
= π‘‘πœ”πΌ
𝑑𝑑
as we’ve just proven
=
𝐼
π‘‘πœ”
𝑑𝑑
moment of inertia constant
= 𝐼𝛼 Definition
angular acceleration
55 / 83
Dynamics – Torque
Thus, knowing the torque on our body, we can compute angular
acceleration, and then find angular velocity and orientation by numeric
integration.
𝝉 = π‘°πœΆ
56 / 83
Full Physics Simulation – Setup
For each rigid body:
1. Calculate center of mass and moment of inertia at the center of
mass.
2. Set initial position, orientation, linear velocity and angular velocity.
57 / 83
Full Physics Simulation – Loop
For each rigid body:
1. Collect all forces on the body, including their points of application.
2. Sum all forces and compute linear acceleration.
3. Compute the torque caused by each force.
4. Sum all torque and compute angular acceleration.
5. Numerically integrate linear acceleration and angular acceleration to
update linear velocity and angular velocity, and position and
orientation.
58 / 83
Hint
Usually, games will treat both
mass and moment of inertia as
properties of the rigid body.
59 / 83
Collision Response
β€’ Given we know that there is a collision, the task is to find out how to
handle that collision.
β€’ We need to decide where the colliding objects move, and if and how
they start spinning.
β€’ By now, velocities never changes instantly, but by means forces
applied over time, only.
60 / 83
Impulse
β€’ An impulse changes the momentum (and thus, the velocity) of a
rigid body instantly, without the need of integration over time.
β€’ We’re going to use Newton’s Law of Restitution for Instantaneous
Collisions with No Friction to find the impulses to apply in case of a
collision.
61 / 83
Newton’s Law of Restitution for Instantaneous Collisions with No
Friction
β€’ Instantaneous: in no time
β€’ Restitution: coefficient of restitution models the compression and
restitution of impacting bodies with a single scalar
β€’ No friction: impulse is entirely pointed in the direction of the collision
normal
62 / 83
Collision Data
β€’ Collision point P
β€’ Center of mass of both bodies A, B
β€’ Velocity of the collision point of both bodies 𝑣 𝐴, 𝑣 𝐡
β€’ Collision normal n
63 / 83
Derived Collision Data
Relative velocity
𝑣 𝐴𝐡 = 𝑣 𝐴 βˆ’ 𝑣 𝐡
Relative normal velocity
𝑣 𝐴𝐡 𝑛 = 𝑣 𝐴 βˆ’ 𝑣 𝐡 𝑛
64 / 83
Coefficient of Restitution
β€’ The Coefficient of Restitution πœ– tells us how much of the incoming
energy is dissipated during the collision.
β€’ πœ– = 1 yields a totally elastic collision (super ball)
β€’ πœ– = 0 yields a totally plastic collision (all energy absorbed)
𝑣 𝐴𝐡
β€²
𝑛 = βˆ’πœ–π‘£ 𝐴𝐡 𝑛
65 / 83
Collision Impulse
By understanding the collision impulse j as change of momentum, we
expect the resulting velocities 𝑣 𝐴
β€²
and 𝑣 𝐡
β€²
to yield the following:
𝑣 𝐴
β€²
= 𝑣 𝐴 +
𝑗
𝑀𝐴
𝑛
𝑣 𝐡
β€²
= 𝑣 𝐡 βˆ’
𝑗
𝑀 𝐡
𝑛
66 / 83
Finding the Collision Impulse
Now that we’ve got everything in place, we can finally compute the
collision impulse.
67 / 83
βˆ’πœ–π‘£ 𝐴𝐡 𝑛 = 𝑣 𝐴𝐡
β€²
𝑛 definition
coefficient of restitution
= (𝑣 𝐴
β€²
βˆ’ 𝑣 𝐡
β€²
)𝑛 definition
relative velocity
=
(𝑣 𝐴 +
𝑗
𝑀𝐴
𝑛 βˆ’ 𝑣 𝐡 +
𝑗
𝑀 𝐡
𝑛)𝑛
definition
collision impulse
=
𝑣 𝐴 𝑛 +
𝑗
𝑀𝐴
𝑛𝑛 βˆ’ 𝑣 𝐡 𝑛 +
𝑗
𝑀 𝐡
𝑛𝑛
distribution
=
𝑣 𝐴 𝑛 βˆ’ 𝑣 𝐡 𝑛 +
𝑗
𝑀𝐴
𝑛𝑛 +
𝑗
𝑀 𝐡
𝑛𝑛
commutative property
=
𝑣 𝐴𝐡 𝑛 +
𝑗
𝑀𝐴
𝑛𝑛 +
𝑗
𝑀 𝐡
𝑛𝑛
definition
relative velocity
Finding the Collision Impulse
Now that we’ve got everything in place, we can finally compute the
collision impulse.
68 / 83
𝑣 𝐴𝐡 𝑛 +
𝑗
𝑀𝐴
𝑛𝑛 +
𝑗
𝑀 𝐡
𝑛𝑛
= βˆ’πœ–π‘£ 𝐴𝐡 𝑛
𝑗
𝑀𝐴
𝑛𝑛 +
𝑗
𝑀 𝐡
𝑛𝑛
= βˆ’πœ–π‘£ 𝐴𝐡 𝑛 βˆ’ 𝑣 𝐴𝐡 𝑛
𝑗(
1
𝑀𝐴
𝑛𝑛 +
1
𝑀 𝐡
𝑛𝑛) = βˆ’πœ–π‘£ 𝐴𝐡 𝑛 βˆ’ 𝑣 𝐴𝐡 𝑛 distribution
𝑗 = βˆ’πœ–π‘£ 𝐴𝐡 𝑛 βˆ’ 𝑣 𝐴𝐡 𝑛
1
𝑀𝐴
𝑛𝑛 +
1
𝑀 𝐡
𝑛𝑛
Finding the Collision Impulse
Now that we’ve got everything in place, we can finally compute the
collision impulse.
69 / 83
𝑗 = βˆ’πœ–π‘£ 𝐴𝐡 𝑛 βˆ’ 𝑣 𝐴𝐡 𝑛
1
𝑀𝐴
𝑛𝑛 +
1
𝑀 𝐡
𝑛𝑛
= βˆ’π‘£ 𝐴𝐡 𝑛(1 + Ο΅)
1
𝑀𝐴
𝑛𝑛 +
1
𝑀 𝐡
𝑛𝑛
distribution
= βˆ’π‘£ 𝐴𝐡 𝑛(1 + Ο΅)
𝑛𝑛(
1
𝑀𝐴
+
1
𝑀 𝐡
)
distribution
Finding the Collision Impulse
Now that we’ve got everything in place, we can finally compute the
collision impulse.
70 / 83
𝑗 = βˆ’πœ–π‘£ 𝐴𝐡 𝑛 βˆ’ 𝑣 𝐴𝐡 𝑛
1
𝑀𝐴
𝑛𝑛 +
1
𝑀 𝐡
𝑛𝑛
= βˆ’π‘£ 𝐴𝐡 𝑛(1 + Ο΅)
1
𝑀𝐴
𝑛𝑛 +
1
𝑀 𝐡
𝑛𝑛
distribution
= βˆ’π‘£ 𝐴𝐡 𝑛(1 + Ο΅)
𝑛𝑛(
1
𝑀𝐴
+
1
𝑀 𝐡
)
distribution
Plugging in j back into our collision impulse equation yields the new velocities of A
and B!
Collision Impulse II
Finally, we need to understand how to have the collision impulse j
change the angular momentum:
πœ” 𝐴
β€²
= πœ” 𝐴 +
𝐴𝑃βŠ₯ 𝑗𝑛
𝐼𝐴
πœ” 𝐡
β€²
= πœ” 𝐡 βˆ’
𝐡𝑃βŠ₯ 𝑗𝑛
𝐼 𝐡
71 / 83
Finding the Collision Impulse
Let’s close by computing the collision impulse with spin:
72 / 12
βˆ’πœ–π‘£ 𝐴𝐡 𝑛 = 𝑣 𝐴𝐡
β€²
𝑛 definition
coefficient of restitution
= (𝑣 𝐴𝑃
β€²
βˆ’ 𝑣 𝐡𝑃
β€²
)𝑛 definition
relative velocity
= (𝑣 𝐴
β€²
+ πœ” 𝐴
β€²
𝐴𝑃βŠ₯ βˆ’ (𝑣 𝐡
β€²
+ πœ” 𝐡
β€²
𝐡𝑃βŠ₯))𝑛 Chasles’ Theorem
= (𝑣 𝐴
β€²
+ πœ” 𝐴
β€²
𝐴𝑃βŠ₯ βˆ’ 𝑣 𝐡
β€²
βˆ’ πœ” 𝐡
β€²
𝐡𝑃βŠ₯)𝑛
=
(𝑣 𝐴 +
𝑗
𝑀𝐴
𝑛 + (πœ” 𝐴 +
𝐴𝑃βŠ₯ 𝑗𝑛
𝐼𝐴
)𝐴𝑃βŠ₯ βˆ’ (𝑣 𝐡 βˆ’
𝑗
𝑀 𝐡
𝑛) βˆ’ (πœ” 𝐡 βˆ’
𝐡𝑃βŠ₯ 𝑗𝑛
𝐼 𝐡
)𝐡𝑃βŠ₯)𝑛
definition
collision impulse
=
(𝑣 𝐴 +
𝑗
𝑀𝐴
𝑛 + πœ” 𝐴 𝐴𝑃βŠ₯ +
𝐴𝑃βŠ₯
2
𝑗𝑛
𝐼𝐴
βˆ’ 𝑣 𝐡 +
𝑗
𝑀 𝐡
𝑛 βˆ’ πœ” 𝐡 𝐡𝑃βŠ₯ +
𝐡𝑃βŠ₯
2
𝑗𝑛
𝐼 𝐡
)𝑛
=
𝑣 𝐴 𝑛 +
𝑗
𝑀𝐴
𝑛𝑛 + πœ” 𝐴 𝐴𝑃βŠ₯ 𝑛 +
𝐴𝑃βŠ₯
2
𝑗𝑛𝑛
𝐼𝐴
βˆ’ 𝑣 𝐡 𝑛 +
𝑗
𝑀 𝐡
𝑛𝑛 βˆ’ πœ” 𝐡 𝐡𝑃βŠ₯ 𝑛
+
𝐡𝑃βŠ₯
2
𝑗𝑛𝑛
𝐼 𝐡
distribution
Finding the Collision Impulse
Let’s close by computing the collision impulse with spin:
73 / 12
𝑗
𝑀𝐴
𝑛𝑛 +
𝐴𝑃βŠ₯
2
𝑗𝑛𝑛
𝐼𝐴
+
𝑗
𝑀 𝐡
𝑛𝑛 +
𝐡𝑃βŠ₯
2
𝑗𝑛𝑛
𝐼 𝐡
= βˆ’π‘£ 𝐴 𝑛 βˆ’ πœ” 𝐴 𝐴𝑃βŠ₯ 𝑛 + 𝑣 𝐡 𝑛 + πœ” 𝐡 𝐡𝑃βŠ₯ 𝑛
βˆ’ πœ–π‘£ 𝐴𝐡 𝑛
j to left side,
non-j to right
side
𝑗𝑛𝑛(
1
𝑀𝐴
+
𝐴𝑃βŠ₯
2
𝐼𝐴
+
1
𝑀 𝐡
+
𝐡𝑃βŠ₯
2
𝐼 𝐡
)
= βˆ’π‘›(𝑣 𝐴 + πœ” 𝐴 𝐴𝑃βŠ₯ βˆ’ 𝑣 𝐡 βˆ’ πœ” 𝐡 𝐡𝑃βŠ₯ + πœ–π‘£ 𝐴𝐡) distribution
𝑗𝑛𝑛(
1
𝑀𝐴
+
𝐴𝑃βŠ₯
2
𝐼𝐴
+
1
𝑀 𝐡
+
𝐡𝑃βŠ₯
2
𝐼 𝐡
)
= βˆ’π‘›(𝑣 𝐴𝑃 βˆ’ 𝑣 𝐡𝑃 + πœ–π‘£ 𝐴𝐡) Chasles’
Theorem
𝑗𝑛𝑛(
1
𝑀𝐴
+
𝐴𝑃βŠ₯
2
𝐼𝐴
+
1
𝑀 𝐡
+
𝐡𝑃βŠ₯
2
𝐼 𝐡
)
= βˆ’π‘›(𝑣 𝐴𝐡 + πœ–π‘£ 𝐴𝐡) definition
relative velocity
𝑗𝑛𝑛(
1
𝑀𝐴
+
𝐴𝑃βŠ₯
2
𝐼𝐴
+
1
𝑀 𝐡
+
𝐡𝑃βŠ₯
2
𝐼 𝐡
)
= βˆ’π‘›π‘£ 𝐴𝐡(1 + πœ–) distribution
𝑗 = βˆ’π‘›π‘£ 𝐴𝐡(1 + πœ–)
𝑛𝑛(
1
𝑀𝐴
+
𝐴𝑃βŠ₯
2
𝐼𝐴
+
1
𝑀 𝐡
+
𝐡𝑃βŠ₯
2
𝐼 𝐡
)
Collision Detection
β€’ Now that we know how to handle collisions, all that’s left is to
understand how to detect them
β€’ As detecting intersections between arbitrary polygons is quite
expensive, they are usually wrapped by some kind of collision shape
β€’ With these shapes, typical test like shape-shape intersection and
ray-shape intersection become far cheaper
β€’ The quality of the collision detection depends on how good the
shapes fit the actual body
74 / 83
Collision Spheres
Detecting whether two spheres A and B intersect is as easy as
comparing their distance to the sum of their radii.
75 / 83
Collision Spheres
The potential collision point lies on the ray from sphere A to B at the
exact radius of A.
76 / 83
Collision Spheres
Detecting whether a ray intersects a sphere requires some tedious, but
basic math (see References)
77 / 83
Axis-Aligned Bounding Boxes
Detecting whether two axis-aligned bounding boxes 𝐴 π‘šπ‘–π‘›, 𝐴 π‘šπ‘Žπ‘₯ and
(𝐡 π‘šπ‘–π‘›, 𝐡 π‘šπ‘Žπ‘₯) intersect can be easily checked using the separating axis
theorem:
78 / 83
Axis-Aligned Bounding Boxes
Detecting whether two axis-aligned bounding boxes 𝐴 π‘šπ‘–π‘›, 𝐴 π‘šπ‘Žπ‘₯ and
(𝐡 π‘šπ‘–π‘›, 𝐡 π‘šπ‘Žπ‘₯) intersect can be easily checked using the separating axis
theorem:
𝐴 π‘šπ‘–π‘› π‘₯ > 𝐡 π‘šπ‘Žπ‘₯ π‘₯ or 𝐡 π‘šπ‘–π‘› π‘₯ > 𝐴 π‘šπ‘Žπ‘₯ π‘₯ or
𝐴 π‘šπ‘–π‘› 𝑦 > 𝐡 π‘šπ‘Žπ‘₯ 𝑦 or 𝐡 π‘šπ‘–π‘› 𝑦 > 𝐴 π‘šπ‘Žπ‘₯ 𝑦 or
𝐴 π‘šπ‘–π‘› 𝑧
> 𝐡 π‘šπ‘Žπ‘₯ 𝑧
or 𝐡 π‘šπ‘–π‘› 𝑧
> 𝐴 π‘šπ‘Žπ‘₯ 𝑧
79 / 83
Tunneling
β€’ If your objects move too fast, you run in danger of missing collisions
due to your numerical integration step size.
β€’ Imagine a sphere moving fast towards a thin wall.
80 / 83
Tunneling – Possible Solutions
β€’ Make the wall thicker.
β–ͺ Need to instruct all level designers.
β€’ Impose an upper bound on object speed.
β€’ Find the speculative contact through the bounding box of the
previous position of the moving object and the current one, and sub-
step from the contact point
β–ͺ Arbitrary convex polygons are a challenge (see Continuous
Collision by Erin Catto in References)
81 / 83
Octrees
β€’ Checking every pair of objects can be very expensive
β€’ The number of required checks can be reduced by subdividing the
space into smaller parts, and checking only pairs of objects who are
found within the same part
82 / 83
Image by Bill Jacobs
Octree Construction
β€’ Start with an empty root node covering the entire world
β€’ Whenever you add an object to the world, start at the root node and
traverse the tree, finding the node farthest from the root that fully
contains the object
β€’ If the node has reached its maximum capacity now, subdivide it into
children
83 / 83
Collision Detection using Octrees
β€’ Given an octree containing shapes, we only need to check all pairs
of shapes that are found within the same node
β€’ Shaped in non-leaf nodes need to be checked against all shapes of
all child nodes, and their children
84 / 83
Optimizing Octrees
β€’ If the average object size begins to exceed the node size, objects
will start to be put in parent nodes more often.
β€’ Limiting the depth of the octree helps avoiding this issue.
β€’ For the same reason, it might be necessary to merge nodes again if
objects have moved away.
85 / 83
Future Work
β€’ 3D (Matrices & Quaternions)
β€’ Joints
β€’ Non-rigid bodies
β€’ Detecting Arbitrary Collisions
86 / 83
References
β€’ Fiedler. Game Physics – Integration Basics. http://gafferongames.com/game-physics/integration-
basics/, 2006.
β€’ Fielder. Game Physics – Fix Your Timestep! http://gafferongames.com/game-physics/fix-your-
timestep/, 2006.
β€’ Hecker. Physics, The Next Frontier. Game Developer Magazine, October/November 1996.
β€’ Hecker. Physics, Part 2: Angular Effects. Game Developer Magazine, December 1996/January
1997.
β€’ Hecker. Physics, Part 3: Collision Response. Game Developer Magazine, March 1997.
β€’ Catto. Box2D User Manual. http://box2d.org/manual.pdf, 2007.
β€’ Catto. Physics for Game Programmers – Continuous Collision.
http://www.gdcvault.com/play/1018239/Physics-for-Game-Programmers-Continuous, 2013.
β€’ Baraff. Physically Based Modelling – Rigid Body Simulation.
http://www.pixar.com/companyinfo/research/pbm2001/pdf/notesg.pdf, 2001.
β€’ Jacobs. OpenGL Tutorial – Collision Detection.
http://www.videotutorialsrock.com/opengl_tutorial/collision_detection/text.php, 2014.
β€’ Su. Ray-Sphere Intersection. http://www.cs.tufts.edu/~sarasu/courses/comp175-
2009fa/pdf/comp175-15-ray-sphere.pdf, November 11, 2009.
87 / 83
Thank you!
http://www.npruehs.de
https://github.com/npruehs
@npruehs
nick.pruehs@daedalic.com
10 Minute Review Session
β€’ What’s the difference between kinematics and dynamics?
β€’ What is velocity?
β€’ What is acceleration?
β€’ What is momentum?
β€’ What is force?
β€’ In your own words: How does Explicit Euler Integration work?
β€’ Why are fixed time steps important in physics simulation?
β€’ What is a rigid body?
10 Minute Review Session
β€’ What is the center of mass?
β€’ In your own words: Explain Chasles’ Theorem!
β€’ What is torque?
β€’ What is moment of inertia?
β€’ What is an impulse?
β€’ Which data is required for resolving collisions?
β€’ Which collision shapes do you know?
β€’ How can you prevent tunneling?
β€’ How can you reduce the number of collisions to check for?

More Related Content

What's hot

Putting the AI Back Into Air: Navigating the Air Space of Horizon Zero Dawn
Putting the AI Back Into Air: Navigating the Air Space of Horizon Zero DawnPutting the AI Back Into Air: Navigating the Air Space of Horizon Zero Dawn
Putting the AI Back Into Air: Navigating the Air Space of Horizon Zero DawnGuerrilla
Β 
Horizon Zero Dawn: A Game Design Post-Mortem
Horizon Zero Dawn: A Game Design Post-MortemHorizon Zero Dawn: A Game Design Post-Mortem
Horizon Zero Dawn: A Game Design Post-MortemGuerrilla
Β 
ν˜Όμžμ„œ λ§Œλ“œλŠ” MMOκ²Œμž„ μ„œλ²„
ν˜Όμžμ„œ λ§Œλ“œλŠ” MMOκ²Œμž„ μ„œλ²„ν˜Όμžμ„œ λ§Œλ“œλŠ” MMOκ²Œμž„ μ„œλ²„
ν˜Όμžμ„œ λ§Œλ“œλŠ” MMOκ²Œμž„ μ„œλ²„iFunFactory Inc.
Β 
[IGC 2016] 컴투슀 김동쀀 - 기획 지망생은 무엇을 μ€€λΉ„ν•˜λ‚˜μš”?
[IGC 2016] 컴투슀 김동쀀 - 기획 지망생은 무엇을 μ€€λΉ„ν•˜λ‚˜μš”?[IGC 2016] 컴투슀 김동쀀 - 기획 지망생은 무엇을 μ€€λΉ„ν•˜λ‚˜μš”?
[IGC 2016] 컴투슀 김동쀀 - 기획 지망생은 무엇을 μ€€λΉ„ν•˜λ‚˜μš”?κ°• 민우
Β 
μ‹¬μ˜ˆλžŒ, <ν”„λ‘œμ νŠΈDH> AI λ‚΄λΉ„κ²Œμ΄μ…˜ μ‹œμŠ€ν…œ, NDC2018
μ‹¬μ˜ˆλžŒ, <ν”„λ‘œμ νŠΈDH> AI λ‚΄λΉ„κ²Œμ΄μ…˜ μ‹œμŠ€ν…œ, NDC2018μ‹¬μ˜ˆλžŒ, <ν”„λ‘œμ νŠΈDH> AI λ‚΄λΉ„κ²Œμ΄μ…˜ μ‹œμŠ€ν…œ, NDC2018
μ‹¬μ˜ˆλžŒ, <ν”„λ‘œμ νŠΈDH> AI λ‚΄λΉ„κ²Œμ΄μ…˜ μ‹œμŠ€ν…œ, NDC2018devCAT Studio, NEXON
Β 
The Technology of Uncharted: Drake’s Fortune
The Technology of Uncharted: Drake’s FortuneThe Technology of Uncharted: Drake’s Fortune
The Technology of Uncharted: Drake’s FortuneNaughty Dog
Β 
Game Development Step by Step
Game Development Step by StepGame Development Step by Step
Game Development Step by StepBayu Sembada
Β 
Mobile Game Development in Unity
Mobile Game Development in UnityMobile Game Development in Unity
Mobile Game Development in UnityHakan Saglam
Β 
Introduction to Unity3D Game Engine
Introduction to Unity3D Game EngineIntroduction to Unity3D Game Engine
Introduction to Unity3D Game EngineMohsen Mirhoseini
Β 
μœ„λŒ€ν•œ κ²Œμž„κ°œλ°œνŒ€μ˜ 곡톡점
μœ„λŒ€ν•œ κ²Œμž„κ°œλ°œνŒ€μ˜ κ³΅ν†΅μ μœ„λŒ€ν•œ κ²Œμž„κ°œλ°œνŒ€μ˜ 곡톡점
μœ„λŒ€ν•œ κ²Œμž„κ°œλ°œνŒ€μ˜ 곡톡점Ryan Park
Β 
λ ˆλ²¨λ””μžμΈ νŠΉκ°• μ΄λ™ν›ˆ
λ ˆλ²¨λ””μžμΈ νŠΉκ°• μ΄λ™ν›ˆλ ˆλ²¨λ””μžμΈ νŠΉκ°• μ΄λ™ν›ˆ
λ ˆλ²¨λ””μžμΈ νŠΉκ°• μ΄λ™ν›ˆDonghun Lee
Β 
Game Design - Lecture 1
Game Design - Lecture 1Game Design - Lecture 1
Game Design - Lecture 1Andrea Resmini
Β 
Kgc2012 온라인 κ²Œμž„μ„ μœ„ν•œ κ²Œμž„ 였브젝트 섀계
Kgc2012 온라인 κ²Œμž„μ„ μœ„ν•œ κ²Œμž„ 였브젝트 섀계Kgc2012 온라인 κ²Œμž„μ„ μœ„ν•œ κ²Œμž„ 였브젝트 섀계
Kgc2012 온라인 κ²Œμž„μ„ μœ„ν•œ κ²Œμž„ 였브젝트 섀계kgun86
Β 
NDC 2013, λ§ˆλΉ„λ…ΈκΈ° μ˜μ›…μ „ 개발 ν…Œν¬λ‹ˆμ»¬ 포슀트-λͺ¨ν…œ
NDC 2013, λ§ˆλΉ„λ…ΈκΈ° μ˜μ›…μ „ 개발 ν…Œν¬λ‹ˆμ»¬ 포슀트-λͺ¨ν…œNDC 2013, λ§ˆλΉ„λ…ΈκΈ° μ˜μ›…μ „ 개발 ν…Œν¬λ‹ˆμ»¬ 포슀트-λͺ¨ν…œ
NDC 2013, λ§ˆλΉ„λ…ΈκΈ° μ˜μ›…μ „ 개발 ν…Œν¬λ‹ˆμ»¬ 포슀트-λͺ¨ν…œtcaesvk
Β 
Building a turn-based game prototype using ECS - Unite Copenhagen 2019
Building a turn-based game prototype using ECS - Unite Copenhagen 2019Building a turn-based game prototype using ECS - Unite Copenhagen 2019
Building a turn-based game prototype using ECS - Unite Copenhagen 2019Unity Technologies
Β 
The Guerrilla Guide to Game Code
The Guerrilla Guide to Game CodeThe Guerrilla Guide to Game Code
The Guerrilla Guide to Game CodeGuerrilla
Β 
Look Ma, No Jutter! Optimizing Performance Across Oculus Mobile
Look Ma, No Jutter! Optimizing Performance Across Oculus MobileLook Ma, No Jutter! Optimizing Performance Across Oculus Mobile
Look Ma, No Jutter! Optimizing Performance Across Oculus MobileUnity Technologies
Β 
06. Game Architecture
06. Game Architecture06. Game Architecture
06. Game ArchitectureAmin Babadi
Β 
Game playing in artificial intelligent technique
Game playing in artificial intelligent technique Game playing in artificial intelligent technique
Game playing in artificial intelligent technique syeda zoya mehdi
Β 

What's hot (20)

Putting the AI Back Into Air: Navigating the Air Space of Horizon Zero Dawn
Putting the AI Back Into Air: Navigating the Air Space of Horizon Zero DawnPutting the AI Back Into Air: Navigating the Air Space of Horizon Zero Dawn
Putting the AI Back Into Air: Navigating the Air Space of Horizon Zero Dawn
Β 
Horizon Zero Dawn: A Game Design Post-Mortem
Horizon Zero Dawn: A Game Design Post-MortemHorizon Zero Dawn: A Game Design Post-Mortem
Horizon Zero Dawn: A Game Design Post-Mortem
Β 
ν˜Όμžμ„œ λ§Œλ“œλŠ” MMOκ²Œμž„ μ„œλ²„
ν˜Όμžμ„œ λ§Œλ“œλŠ” MMOκ²Œμž„ μ„œλ²„ν˜Όμžμ„œ λ§Œλ“œλŠ” MMOκ²Œμž„ μ„œλ²„
ν˜Όμžμ„œ λ§Œλ“œλŠ” MMOκ²Œμž„ μ„œλ²„
Β 
[IGC 2016] 컴투슀 김동쀀 - 기획 지망생은 무엇을 μ€€λΉ„ν•˜λ‚˜μš”?
[IGC 2016] 컴투슀 김동쀀 - 기획 지망생은 무엇을 μ€€λΉ„ν•˜λ‚˜μš”?[IGC 2016] 컴투슀 김동쀀 - 기획 지망생은 무엇을 μ€€λΉ„ν•˜λ‚˜μš”?
[IGC 2016] 컴투슀 김동쀀 - 기획 지망생은 무엇을 μ€€λΉ„ν•˜λ‚˜μš”?
Β 
First-person Shooters
First-person ShootersFirst-person Shooters
First-person Shooters
Β 
μ‹¬μ˜ˆλžŒ, <ν”„λ‘œμ νŠΈDH> AI λ‚΄λΉ„κ²Œμ΄μ…˜ μ‹œμŠ€ν…œ, NDC2018
μ‹¬μ˜ˆλžŒ, <ν”„λ‘œμ νŠΈDH> AI λ‚΄λΉ„κ²Œμ΄μ…˜ μ‹œμŠ€ν…œ, NDC2018μ‹¬μ˜ˆλžŒ, <ν”„λ‘œμ νŠΈDH> AI λ‚΄λΉ„κ²Œμ΄μ…˜ μ‹œμŠ€ν…œ, NDC2018
μ‹¬μ˜ˆλžŒ, <ν”„λ‘œμ νŠΈDH> AI λ‚΄λΉ„κ²Œμ΄μ…˜ μ‹œμŠ€ν…œ, NDC2018
Β 
The Technology of Uncharted: Drake’s Fortune
The Technology of Uncharted: Drake’s FortuneThe Technology of Uncharted: Drake’s Fortune
The Technology of Uncharted: Drake’s Fortune
Β 
Game Development Step by Step
Game Development Step by StepGame Development Step by Step
Game Development Step by Step
Β 
Mobile Game Development in Unity
Mobile Game Development in UnityMobile Game Development in Unity
Mobile Game Development in Unity
Β 
Introduction to Unity3D Game Engine
Introduction to Unity3D Game EngineIntroduction to Unity3D Game Engine
Introduction to Unity3D Game Engine
Β 
μœ„λŒ€ν•œ κ²Œμž„κ°œλ°œνŒ€μ˜ 곡톡점
μœ„λŒ€ν•œ κ²Œμž„κ°œλ°œνŒ€μ˜ κ³΅ν†΅μ μœ„λŒ€ν•œ κ²Œμž„κ°œλ°œνŒ€μ˜ 곡톡점
μœ„λŒ€ν•œ κ²Œμž„κ°œλ°œνŒ€μ˜ 곡톡점
Β 
λ ˆλ²¨λ””μžμΈ νŠΉκ°• μ΄λ™ν›ˆ
λ ˆλ²¨λ””μžμΈ νŠΉκ°• μ΄λ™ν›ˆλ ˆλ²¨λ””μžμΈ νŠΉκ°• μ΄λ™ν›ˆ
λ ˆλ²¨λ””μžμΈ νŠΉκ°• μ΄λ™ν›ˆ
Β 
Game Design - Lecture 1
Game Design - Lecture 1Game Design - Lecture 1
Game Design - Lecture 1
Β 
Kgc2012 온라인 κ²Œμž„μ„ μœ„ν•œ κ²Œμž„ 였브젝트 섀계
Kgc2012 온라인 κ²Œμž„μ„ μœ„ν•œ κ²Œμž„ 였브젝트 섀계Kgc2012 온라인 κ²Œμž„μ„ μœ„ν•œ κ²Œμž„ 였브젝트 섀계
Kgc2012 온라인 κ²Œμž„μ„ μœ„ν•œ κ²Œμž„ 였브젝트 섀계
Β 
NDC 2013, λ§ˆλΉ„λ…ΈκΈ° μ˜μ›…μ „ 개발 ν…Œν¬λ‹ˆμ»¬ 포슀트-λͺ¨ν…œ
NDC 2013, λ§ˆλΉ„λ…ΈκΈ° μ˜μ›…μ „ 개발 ν…Œν¬λ‹ˆμ»¬ 포슀트-λͺ¨ν…œNDC 2013, λ§ˆλΉ„λ…ΈκΈ° μ˜μ›…μ „ 개발 ν…Œν¬λ‹ˆμ»¬ 포슀트-λͺ¨ν…œ
NDC 2013, λ§ˆλΉ„λ…ΈκΈ° μ˜μ›…μ „ 개발 ν…Œν¬λ‹ˆμ»¬ 포슀트-λͺ¨ν…œ
Β 
Building a turn-based game prototype using ECS - Unite Copenhagen 2019
Building a turn-based game prototype using ECS - Unite Copenhagen 2019Building a turn-based game prototype using ECS - Unite Copenhagen 2019
Building a turn-based game prototype using ECS - Unite Copenhagen 2019
Β 
The Guerrilla Guide to Game Code
The Guerrilla Guide to Game CodeThe Guerrilla Guide to Game Code
The Guerrilla Guide to Game Code
Β 
Look Ma, No Jutter! Optimizing Performance Across Oculus Mobile
Look Ma, No Jutter! Optimizing Performance Across Oculus MobileLook Ma, No Jutter! Optimizing Performance Across Oculus Mobile
Look Ma, No Jutter! Optimizing Performance Across Oculus Mobile
Β 
06. Game Architecture
06. Game Architecture06. Game Architecture
06. Game Architecture
Β 
Game playing in artificial intelligent technique
Game playing in artificial intelligent technique Game playing in artificial intelligent technique
Game playing in artificial intelligent technique
Β 

Viewers also liked

Game Programming 09 - AI
Game Programming 09 - AIGame Programming 09 - AI
Game Programming 09 - AINick Pruehs
Β 
Game Programming 08 - Tool Development
Game Programming 08 - Tool DevelopmentGame Programming 08 - Tool Development
Game Programming 08 - Tool DevelopmentNick Pruehs
Β 
Game Programming 13 - Debugging & Performance Optimization
Game Programming 13 - Debugging & Performance OptimizationGame Programming 13 - Debugging & Performance Optimization
Game Programming 13 - Debugging & Performance OptimizationNick Pruehs
Β 
Game Programming 10 - Localization
Game Programming 10 - LocalizationGame Programming 10 - Localization
Game Programming 10 - LocalizationNick Pruehs
Β 
Game Programming 04 - Style & Design Principles
Game Programming 04 - Style & Design PrinciplesGame Programming 04 - Style & Design Principles
Game Programming 04 - Style & Design PrinciplesNick Pruehs
Β 
What Would Blizzard Do
What Would Blizzard DoWhat Would Blizzard Do
What Would Blizzard DoNick Pruehs
Β 
School For Games 2015 - Unity Engine Basics
School For Games 2015 - Unity Engine BasicsSchool For Games 2015 - Unity Engine Basics
School For Games 2015 - Unity Engine BasicsNick Pruehs
Β 
Tool Development A - Git
Tool Development A - GitTool Development A - Git
Tool Development A - GitNick Pruehs
Β 
Game Programming 02 - Component-Based Entity Systems
Game Programming 02 - Component-Based Entity SystemsGame Programming 02 - Component-Based Entity Systems
Game Programming 02 - Component-Based Entity SystemsNick Pruehs
Β 
Designing an actor model game architecture with Pony
Designing an actor model game architecture with PonyDesigning an actor model game architecture with Pony
Designing an actor model game architecture with PonyNick Pruehs
Β 
Game Programming 12 - Shaders
Game Programming 12 - ShadersGame Programming 12 - Shaders
Game Programming 12 - ShadersNick Pruehs
Β 
Game Programming 01 - Introduction
Game Programming 01 - IntroductionGame Programming 01 - Introduction
Game Programming 01 - IntroductionNick Pruehs
Β 
Game Development Challenges
Game Development ChallengesGame Development Challenges
Game Development ChallengesNick Pruehs
Β 
Eight Rules for Making Your First Great Game
Eight Rules for Making Your First Great GameEight Rules for Making Your First Great Game
Eight Rules for Making Your First Great GameNick Pruehs
Β 
Scrum - but... Agile Game Development in Small Teams
Scrum - but... Agile Game Development in Small TeamsScrum - but... Agile Game Development in Small Teams
Scrum - but... Agile Game Development in Small TeamsNick Pruehs
Β 
Physics for Game Programmers
Physics for Game ProgrammersPhysics for Game Programmers
Physics for Game ProgrammersUng-Su Lee
Β 
Game Programming 05 - Development Tools
Game Programming 05 - Development ToolsGame Programming 05 - Development Tools
Game Programming 05 - Development ToolsNick Pruehs
Β 
Game Programming 06 - Automated Testing
Game Programming 06 - Automated TestingGame Programming 06 - Automated Testing
Game Programming 06 - Automated TestingNick Pruehs
Β 
Gaming Process
Gaming ProcessGaming Process
Gaming ProcessSharad Mitra
Β 

Viewers also liked (20)

Game Programming 09 - AI
Game Programming 09 - AIGame Programming 09 - AI
Game Programming 09 - AI
Β 
Game Programming 08 - Tool Development
Game Programming 08 - Tool DevelopmentGame Programming 08 - Tool Development
Game Programming 08 - Tool Development
Β 
Game Programming 13 - Debugging & Performance Optimization
Game Programming 13 - Debugging & Performance OptimizationGame Programming 13 - Debugging & Performance Optimization
Game Programming 13 - Debugging & Performance Optimization
Β 
Game Programming 10 - Localization
Game Programming 10 - LocalizationGame Programming 10 - Localization
Game Programming 10 - Localization
Β 
Game Programming 04 - Style & Design Principles
Game Programming 04 - Style & Design PrinciplesGame Programming 04 - Style & Design Principles
Game Programming 04 - Style & Design Principles
Β 
What Would Blizzard Do
What Would Blizzard DoWhat Would Blizzard Do
What Would Blizzard Do
Β 
School For Games 2015 - Unity Engine Basics
School For Games 2015 - Unity Engine BasicsSchool For Games 2015 - Unity Engine Basics
School For Games 2015 - Unity Engine Basics
Β 
Tool Development A - Git
Tool Development A - GitTool Development A - Git
Tool Development A - Git
Β 
Game Programming 02 - Component-Based Entity Systems
Game Programming 02 - Component-Based Entity SystemsGame Programming 02 - Component-Based Entity Systems
Game Programming 02 - Component-Based Entity Systems
Β 
Designing an actor model game architecture with Pony
Designing an actor model game architecture with PonyDesigning an actor model game architecture with Pony
Designing an actor model game architecture with Pony
Β 
Game Programming 12 - Shaders
Game Programming 12 - ShadersGame Programming 12 - Shaders
Game Programming 12 - Shaders
Β 
Game Programming 01 - Introduction
Game Programming 01 - IntroductionGame Programming 01 - Introduction
Game Programming 01 - Introduction
Β 
Game Development Challenges
Game Development ChallengesGame Development Challenges
Game Development Challenges
Β 
Eight Rules for Making Your First Great Game
Eight Rules for Making Your First Great GameEight Rules for Making Your First Great Game
Eight Rules for Making Your First Great Game
Β 
Scrum - but... Agile Game Development in Small Teams
Scrum - but... Agile Game Development in Small TeamsScrum - but... Agile Game Development in Small Teams
Scrum - but... Agile Game Development in Small Teams
Β 
Physics for Game Programmers
Physics for Game ProgrammersPhysics for Game Programmers
Physics for Game Programmers
Β 
Game Programming 05 - Development Tools
Game Programming 05 - Development ToolsGame Programming 05 - Development Tools
Game Programming 05 - Development Tools
Β 
Game Programming 06 - Automated Testing
Game Programming 06 - Automated TestingGame Programming 06 - Automated Testing
Game Programming 06 - Automated Testing
Β 
Final econo dx(1)
Final econo dx(1)Final econo dx(1)
Final econo dx(1)
Β 
Gaming Process
Gaming ProcessGaming Process
Gaming Process
Β 

Similar to Game Programming 11 - Game Physics

Cajamarca isaac diseΓ±o y construccion de la maqueta de movimiento perpetuo
Cajamarca isaac diseΓ±o y construccion de la maqueta de movimiento perpetuoCajamarca isaac diseΓ±o y construccion de la maqueta de movimiento perpetuo
Cajamarca isaac diseΓ±o y construccion de la maqueta de movimiento perpetuoJASSONISAACCAJAMARCA
Β 
Dinamica rotacional
Dinamica rotacionalDinamica rotacional
Dinamica rotacionalKramerCaiza
Β 
3c. uniform circular motion
3c. uniform circular motion3c. uniform circular motion
3c. uniform circular motiondukies_2000
Β 
2.2 Acceleration
2.2 Acceleration2.2 Acceleration
2.2 Accelerationmlong24
Β 
2.2 Phy I - Acceleration
2.2 Phy I - Acceleration2.2 Phy I - Acceleration
2.2 Phy I - Accelerationmlong24
Β 
1.Day 1 Rectilinera Motion Part 01.pdf
1.Day 1 Rectilinera Motion Part 01.pdf1.Day 1 Rectilinera Motion Part 01.pdf
1.Day 1 Rectilinera Motion Part 01.pdfruwan dissanayake
Β 
PPT-Rectilinear Motion.pptx
PPT-Rectilinear Motion.pptxPPT-Rectilinear Motion.pptx
PPT-Rectilinear Motion.pptxKenneth Arlando
Β 
Chapter 12 kinematics of a particle part-i
Chapter 12 kinematics of a particle   part-iChapter 12 kinematics of a particle   part-i
Chapter 12 kinematics of a particle part-iSajid Yasin
Β 
Force of rotating system
Force of rotating systemForce of rotating system
Force of rotating systemdaveson700
Β 
Simulation And Modelling
Simulation And ModellingSimulation And Modelling
Simulation And ModellingAbhishek Chandra
Β 
Rotational Motion & Equilibrium
Rotational Motion & EquilibriumRotational Motion & Equilibrium
Rotational Motion & EquilibriumTimothy Welsh
Β 
Lab 05 – Gravitation and Keplers Laws Name __________________.docx
Lab 05 – Gravitation and Keplers Laws Name __________________.docxLab 05 – Gravitation and Keplers Laws Name __________________.docx
Lab 05 – Gravitation and Keplers Laws Name __________________.docxDIPESH30
Β 
Hatten spring 1561232600_stablesprings0.7.3
Hatten spring 1561232600_stablesprings0.7.3Hatten spring 1561232600_stablesprings0.7.3
Hatten spring 1561232600_stablesprings0.7.3widgetdog
Β 
physics 9702 theory pdf fr A level cambridge.This will assist in understandin...
physics 9702 theory pdf fr A level cambridge.This will assist in understandin...physics 9702 theory pdf fr A level cambridge.This will assist in understandin...
physics 9702 theory pdf fr A level cambridge.This will assist in understandin...PermissionTafadzwaCh
Β 
Velocity time graphs , Free fall.pdf
Velocity time graphs , Free fall.pdfVelocity time graphs , Free fall.pdf
Velocity time graphs , Free fall.pdfdaminorteystephen
Β 

Similar to Game Programming 11 - Game Physics (20)

Cajamarca isaac diseΓ±o y construccion de la maqueta de movimiento perpetuo
Cajamarca isaac diseΓ±o y construccion de la maqueta de movimiento perpetuoCajamarca isaac diseΓ±o y construccion de la maqueta de movimiento perpetuo
Cajamarca isaac diseΓ±o y construccion de la maqueta de movimiento perpetuo
Β 
Ch2 2011 s
Ch2 2011 sCh2 2011 s
Ch2 2011 s
Β 
Dinamica rotacional
Dinamica rotacionalDinamica rotacional
Dinamica rotacional
Β 
Moments
MomentsMoments
Moments
Β 
3c. uniform circular motion
3c. uniform circular motion3c. uniform circular motion
3c. uniform circular motion
Β 
2.1 linear motion
2.1   linear motion2.1   linear motion
2.1 linear motion
Β 
2.2 Acceleration
2.2 Acceleration2.2 Acceleration
2.2 Acceleration
Β 
2.2 Phy I - Acceleration
2.2 Phy I - Acceleration2.2 Phy I - Acceleration
2.2 Phy I - Acceleration
Β 
1.Day 1 Rectilinera Motion Part 01.pdf
1.Day 1 Rectilinera Motion Part 01.pdf1.Day 1 Rectilinera Motion Part 01.pdf
1.Day 1 Rectilinera Motion Part 01.pdf
Β 
PPT-Rectilinear Motion.pptx
PPT-Rectilinear Motion.pptxPPT-Rectilinear Motion.pptx
PPT-Rectilinear Motion.pptx
Β 
Chapter 12 kinematics of a particle part-i
Chapter 12 kinematics of a particle   part-iChapter 12 kinematics of a particle   part-i
Chapter 12 kinematics of a particle part-i
Β 
Force of rotating system
Force of rotating systemForce of rotating system
Force of rotating system
Β 
Simulation And Modelling
Simulation And ModellingSimulation And Modelling
Simulation And Modelling
Β 
Simple Harmonic Motion
Simple Harmonic MotionSimple Harmonic Motion
Simple Harmonic Motion
Β 
Rotational Motion & Equilibrium
Rotational Motion & EquilibriumRotational Motion & Equilibrium
Rotational Motion & Equilibrium
Β 
Lab 05 – Gravitation and Keplers Laws Name __________________.docx
Lab 05 – Gravitation and Keplers Laws Name __________________.docxLab 05 – Gravitation and Keplers Laws Name __________________.docx
Lab 05 – Gravitation and Keplers Laws Name __________________.docx
Β 
Hatten spring 1561232600_stablesprings0.7.3
Hatten spring 1561232600_stablesprings0.7.3Hatten spring 1561232600_stablesprings0.7.3
Hatten spring 1561232600_stablesprings0.7.3
Β 
physics 9702 theory pdf fr A level cambridge.This will assist in understandin...
physics 9702 theory pdf fr A level cambridge.This will assist in understandin...physics 9702 theory pdf fr A level cambridge.This will assist in understandin...
physics 9702 theory pdf fr A level cambridge.This will assist in understandin...
Β 
Shm 1
Shm 1Shm 1
Shm 1
Β 
Velocity time graphs , Free fall.pdf
Velocity time graphs , Free fall.pdfVelocity time graphs , Free fall.pdf
Velocity time graphs , Free fall.pdf
Β 

More from Nick Pruehs

Unreal Engine Basics 06 - Animation, Audio, Visual Effects
Unreal Engine Basics 06 - Animation, Audio, Visual EffectsUnreal Engine Basics 06 - Animation, Audio, Visual Effects
Unreal Engine Basics 06 - Animation, Audio, Visual EffectsNick Pruehs
Β 
Unreal Engine Basics 05 - User Interface
Unreal Engine Basics 05 - User InterfaceUnreal Engine Basics 05 - User Interface
Unreal Engine Basics 05 - User InterfaceNick Pruehs
Β 
Unreal Engine Basics 04 - Behavior Trees
Unreal Engine Basics 04 - Behavior TreesUnreal Engine Basics 04 - Behavior Trees
Unreal Engine Basics 04 - Behavior TreesNick Pruehs
Β 
Unreal Engine Basics 03 - Gameplay
Unreal Engine Basics 03 - GameplayUnreal Engine Basics 03 - Gameplay
Unreal Engine Basics 03 - GameplayNick Pruehs
Β 
Unreal Engine Basics 02 - Unreal Editor
Unreal Engine Basics 02 - Unreal EditorUnreal Engine Basics 02 - Unreal Editor
Unreal Engine Basics 02 - Unreal EditorNick Pruehs
Β 
Unreal Engine Basics 01 - Game Framework
Unreal Engine Basics 01 - Game FrameworkUnreal Engine Basics 01 - Game Framework
Unreal Engine Basics 01 - Game FrameworkNick Pruehs
Β 
Game Programming - Cloud Development
Game Programming - Cloud DevelopmentGame Programming - Cloud Development
Game Programming - Cloud DevelopmentNick Pruehs
Β 
Game Programming - Git
Game Programming - GitGame Programming - Git
Game Programming - GitNick Pruehs
Β 
Game Programming 00 - Exams
Game Programming 00 - ExamsGame Programming 00 - Exams
Game Programming 00 - ExamsNick Pruehs
Β 
Tool Development 10 - MVVM, Tool Chains
Tool Development 10 - MVVM, Tool ChainsTool Development 10 - MVVM, Tool Chains
Tool Development 10 - MVVM, Tool ChainsNick Pruehs
Β 

More from Nick Pruehs (10)

Unreal Engine Basics 06 - Animation, Audio, Visual Effects
Unreal Engine Basics 06 - Animation, Audio, Visual EffectsUnreal Engine Basics 06 - Animation, Audio, Visual Effects
Unreal Engine Basics 06 - Animation, Audio, Visual Effects
Β 
Unreal Engine Basics 05 - User Interface
Unreal Engine Basics 05 - User InterfaceUnreal Engine Basics 05 - User Interface
Unreal Engine Basics 05 - User Interface
Β 
Unreal Engine Basics 04 - Behavior Trees
Unreal Engine Basics 04 - Behavior TreesUnreal Engine Basics 04 - Behavior Trees
Unreal Engine Basics 04 - Behavior Trees
Β 
Unreal Engine Basics 03 - Gameplay
Unreal Engine Basics 03 - GameplayUnreal Engine Basics 03 - Gameplay
Unreal Engine Basics 03 - Gameplay
Β 
Unreal Engine Basics 02 - Unreal Editor
Unreal Engine Basics 02 - Unreal EditorUnreal Engine Basics 02 - Unreal Editor
Unreal Engine Basics 02 - Unreal Editor
Β 
Unreal Engine Basics 01 - Game Framework
Unreal Engine Basics 01 - Game FrameworkUnreal Engine Basics 01 - Game Framework
Unreal Engine Basics 01 - Game Framework
Β 
Game Programming - Cloud Development
Game Programming - Cloud DevelopmentGame Programming - Cloud Development
Game Programming - Cloud Development
Β 
Game Programming - Git
Game Programming - GitGame Programming - Git
Game Programming - Git
Β 
Game Programming 00 - Exams
Game Programming 00 - ExamsGame Programming 00 - Exams
Game Programming 00 - Exams
Β 
Tool Development 10 - MVVM, Tool Chains
Tool Development 10 - MVVM, Tool ChainsTool Development 10 - MVVM, Tool Chains
Tool Development 10 - MVVM, Tool Chains
Β 

Recently uploaded

SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
Β 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
Β 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
Β 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
Β 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
Β 
Integration and Automation in Practice: CI/CD in MuleΒ Integration and Automat...
Integration and Automation in Practice: CI/CD in MuleΒ Integration and Automat...Integration and Automation in Practice: CI/CD in MuleΒ Integration and Automat...
Integration and Automation in Practice: CI/CD in MuleΒ Integration and Automat...Patryk Bandurski
Β 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
Β 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
Β 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
Β 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
Β 
FULL ENJOY πŸ” 8264348440 πŸ” Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY πŸ” 8264348440 πŸ” Call Girls in Diplomatic Enclave | DelhiFULL ENJOY πŸ” 8264348440 πŸ” Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY πŸ” 8264348440 πŸ” Call Girls in Diplomatic Enclave | Delhisoniya singh
Β 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
Β 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
Β 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
Β 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAndikSusilo4
Β 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
Β 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
Β 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
Β 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
Β 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
Β 

Recently uploaded (20)

SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
Β 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
Β 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
Β 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Β 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Β 
Integration and Automation in Practice: CI/CD in MuleΒ Integration and Automat...
Integration and Automation in Practice: CI/CD in MuleΒ Integration and Automat...Integration and Automation in Practice: CI/CD in MuleΒ Integration and Automat...
Integration and Automation in Practice: CI/CD in MuleΒ Integration and Automat...
Β 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
Β 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
Β 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
Β 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
Β 
FULL ENJOY πŸ” 8264348440 πŸ” Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY πŸ” 8264348440 πŸ” Call Girls in Diplomatic Enclave | DelhiFULL ENJOY πŸ” 8264348440 πŸ” Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY πŸ” 8264348440 πŸ” Call Girls in Diplomatic Enclave | Delhi
Β 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
Β 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
Β 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
Β 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
Β 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Β 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
Β 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
Β 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Β 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
Β 

Game Programming 11 - Game Physics

  • 2. Objectives β€’ To understand the basics of kinematics and dynamics in games β€’ To get an overview of a simple numeric integration approach for phyics β€’ To learn how to resolve rigid body collisions 2 / 83
  • 3. Motivation β€’ Next thing to make your game feel right, besides graphics and sound β€’ Can be integral part of your gameplay β€’ Usually just a close approximation to real physics will be enough β€œSpeedy thing goes in, speedy thing comes out.” - GLaDOS 3 / 83
  • 4. Kinematics vs. Dynamics β€’ Kinematics is the study of movement over time. β–ͺ Doesn’t matter why things are where there are now β–ͺ Doesn’t matter what causes the movement β–ͺ Just deals with the actual movement itself β€’ Dynamics is the study of forces and masses that cause kinematic quantities to change over time. 4 / 83
  • 5. Kinematics – Velocity Velocity is the rate of change of position over time. 5 / 83 𝒗 = 𝒅𝒙 𝒅𝒕
  • 6. Kinematics – Acceleration Acceleration is the rate of change of velocity over time. 6 / 83 𝒂 = 𝒅𝒗 𝒅𝒕
  • 7. Change of velocity Solving for v and integrating yields the velocity after a given time t, aside from some unknown constant C: 7 / 83 𝐚 = 𝐝𝐯 𝐝𝐭 𝒅𝒗 = 𝒂 𝒅𝒕 𝒗(𝒕) = ΰΆ± 𝒂 𝒅𝒕 𝒗(𝒕) = 𝒂𝒕 + π‘ͺ
  • 8. Change of velocity We can find the unknown constant to be the initial velocity by computing the initial velocity: 8 / 83 𝒗 = 𝒂𝒕 + π‘ͺ 𝒗 𝟎 = πŸŽπ’‚ + π‘ͺ 𝒗 𝟎 = π‘ͺ
  • 9. Change of velocity Thus, given the acceleration a and initial velocity v0, the velocity after any given time t is 9 / 83 𝒗(𝒕) = 𝒂𝒕 + 𝒗 𝟎
  • 10. Change of position The position after any given time t can be found the same way: 10 / 83 𝐯 = 𝐝𝐱 𝐝𝐭 𝒅𝒙 = 𝒗 𝒅𝒕 𝒅𝒙 = 𝒂𝒕 + 𝒗 𝟎 𝒅𝒕 𝒙(𝒕) = ΰΆ± 𝒂𝒕 + 𝒗 𝟎 𝒅𝒕 𝒙(𝒕) = 𝟏 𝟐 𝒂𝒕 𝟐 + 𝒗 𝟎 𝒕 + 𝒙 𝟎
  • 11. Kinematics – Momentum Momentum is the product of the mass and velocity of an object. 11 / 83 𝒑 = π’Žπ’—
  • 12. Dynamics – Force Force is the rate of change of momentum over time (Newton’s Second Law). 12 / 83 𝑭 = 𝒅𝒑 𝒅𝒕
  • 13. Change of acceleration For constant mass, force and acceleration are related as follows: 13 / 83 𝐹 = 𝐝𝐩 𝐝𝐭 definition force = 𝒅 π’Žπ’— 𝒅𝒕 definition momentum = π’Ž 𝒅𝒗 𝒅𝒕 constant mass = π’Žπ’‚ definition acceleration
  • 14. Numerical Integration β€’ Start at a certain initial position and velocity β€’ Take a small step forward in time to find the velocity and position at the next time value β€’ Do this repeatedly to go forward in time in small increments, each time taking the results of the previous integration as the starting point for the next 14 / 83
  • 15. Explicit Euler Integration C# 15 / 83 // Fixed time step and constant force. const float dt = 1; const float force = 10.0f; // Create new body without initial velocity. var body = new Body { Mass = 1.0f, Position = 0.0f, Velocity = 0.0f }; // Simulate ten steps. for (float t = 1; t <= 10; t++) { body.Position += body.Velocity * dt; var acceleration = force / body.Mass; body.Velocity += acceleration * dt; }
  • 16. Explicit Euler Integration t position velocity 1 0 10 2 10 20 3 30 30 4 60 40 5 100 50 6 150 60 7 210 70 8 280 80 9 360 90 10 450 100 16 / 83 Explicit Euler integration with dt = 1
  • 17. Inaccuracy 𝒙 = 𝟎. πŸ“π’‚π’• 𝟐 + 𝒗𝒕 + 𝒙 𝟎 with 𝒂 = 𝟏𝟎, 𝒕 = 𝟏𝟎, 𝒗 = 𝟎, 𝒙 𝟎 = 𝟎 = 0.5 Γ— 10 Γ— 102 + 0𝑑 + 0 = 0.5 Γ— 10 Γ— 100 = 500 17 / 83 Exact physical position at t = 10 is: This implies an error of (500 – 450) / 500 = 10% after only ten seconds for dt = 1!
  • 18. Explicit Euler Integration t position velocity 1 4.5 10 2 19 20 3 43.5 30 4 78 40 5 122.5 50 6 177 60 7 241.5 70 8 316 80 9 400.5 90 10 495 100 18 / 83 Explicit Euler integration with dt = 0.1
  • 19. Variable vs. fixed time steps Usually, we’re working with variable time steps in game simulations: However, this approach has major drawbacks in when simulating physics. 19 / 83 public void Update(float deltaTime) { // Do something awesome here... }
  • 20. Variable time steps in physics β€’ Physics will β€œfeel” slightly different depending on your framerate β€’ Fast objects won’t collide as expected β€’ Spring simulation will explode to infinity 20 / 83
  • 21. Fixed time steps in physics β€’ In order to ensure a fixed time step that feels right, we need to have the physics simulation … β–ͺ Don’t update too often if frames are rendered very fast β–ͺ Catch up if frames are rendered very slowly β€’ This is achieved by accumulating deltas across frames, updating several times per frame if necessary. 21 / 83
  • 22. Fixed time steps in physics C# 22 / 83 var random = new Random(); // Fixed time step and constant force. const float fixedDt = 1f / 60f; const float force = 10.0f; float totalTime = 0.0f; float accumulatedDt = 0.0f; // Create new body without initial velocity. var body = new Body { Mass = 1.0f, Position = 0.0f, Velocity = 0.0f }; // Simulate ten steps. for (int t = 0; t <= 10; t++) { // Random delta. float dt = (float)random.NextDouble() / 45; totalTime += dt; accumulatedDt += dt; while (accumulatedDt > fixedDt) { var acceleration = force / body.Mass; body.Velocity += acceleration * fixedDt; body.Position += body.Velocity * fixedDt; accumulatedDt -= fixedDt; } }
  • 23. Fixed time steps in physics t dt accumulatedTime position velocity 0 0.022 0.022 0 0 0 0.022 0.005 0.003 0.167 1 0.020 0.026 0.003 0.167 1 0.020 0.009 0.008 0.333 2 0.005 0.014 0.008 0.333 3 0.003 0.017 0.008 0.333 3 0.003 0 0.017 0.500 4 0.011 0.011 0.017 0.500 5 0.019 0.030 0.017 0.500 5 0.019 0.013 0.028 0.667 23 / 83 Fixed time steps with dt = 1 / 60 = 0.016
  • 24. Gotcha! Accumulated time steps can cause an infinite loop if your physics simulation takes more time than your fixed time step! Clamp at a maximum number of simulation steps per frame to avoid this. 24 / 83
  • 25. Rigid bodies β€’ All of the above assumes a constant mass concentrated in a single point β€’ However, in games we have to deal with bodies having their mass distributed over their area (or volume) β€’ Rigid bodies are shapes that don’t change or deform during physics simulation β€’ We’ll focus on these for the time being 25 / 83
  • 26. Rigid bodies β€’ For the time being, we’ll model our rigid body as a set of point masses β€’ The total momentum of the rigid body equals the sum of all momentums of all points that make up that body 𝑝 π‘…π‘–π‘”π‘–π‘‘π‘π‘œπ‘‘π‘¦ = ෍ 𝑖 π‘šπ‘– 𝑣𝑖 26 / 83
  • 27. Center of mass We define the center of mass of a rigid body as the linear combination of the position vectors of all points that make up that body, weighted by their masses, divided by the total mass of the body. π‘₯ πΆπ‘’π‘›π‘‘π‘’π‘Ÿπ‘‚π‘“π‘€π‘Žπ‘ π‘  = σ𝑖 π‘₯𝑖 π‘šπ‘– 𝑀 π‘…π‘–π‘”π‘–π‘‘π‘π‘œπ‘‘π‘¦ 27 / 83
  • 28. Center of mass Let’s modify this equation a bit: 28 / 12 π‘₯ πΆπ‘’π‘›π‘‘π‘’π‘Ÿπ‘‚π‘“π‘€π‘Žπ‘ π‘  = σ𝑖 π‘₯𝑖 π‘šπ‘– 𝑀 π‘…π‘–π‘”π‘–π‘‘π‘π‘œπ‘‘π‘¦ 𝑀 π‘…π‘–π‘”π‘–π‘‘π‘π‘œπ‘‘π‘¦ π‘₯ πΆπ‘’π‘›π‘‘π‘’π‘Ÿπ‘‚π‘“π‘€π‘Žπ‘ π‘  = ෍ 𝑖 π‘₯𝑖 π‘šπ‘– multiplied with 𝑀 π‘…π‘–π‘”π‘–π‘‘π‘π‘œπ‘‘π‘¦ 𝑑(𝑀 π‘…π‘–π‘”π‘–π‘‘π‘π‘œπ‘‘π‘¦ π‘₯ πΆπ‘’π‘›π‘‘π‘’π‘Ÿπ‘‚π‘“π‘€π‘Žπ‘ π‘ ) 𝑑𝑑 = ෍ 𝑖 𝑑(π‘₯𝑖 π‘šπ‘–) 𝑑𝑑 𝑑/𝑑𝑑 = ෍ 𝑖 π‘šπ‘– 𝑑π‘₯𝑖 𝑑𝑑 constant mass = ෍ 𝑖 π‘šπ‘– 𝑣𝑖 definition velocity = 𝑝 π‘…π‘–π‘”π‘–π‘‘π‘π‘œπ‘‘π‘¦ definition momentum
  • 29. Center of mass Now, let’s take a look at the second part again: 29 / 83 𝑑(𝑀 π‘…π‘–π‘”π‘–π‘‘π‘π‘œπ‘‘π‘¦ π‘₯ πΆπ‘’π‘›π‘‘π‘’π‘Ÿπ‘‚π‘“π‘€π‘Žπ‘ π‘ ) 𝑑𝑑 = 𝑀 π‘…π‘–π‘”π‘–π‘‘π‘π‘œπ‘‘π‘¦ 𝑑π‘₯ πΆπ‘’π‘›π‘‘π‘’π‘Ÿπ‘‚π‘“π‘€π‘Žπ‘ π‘  𝑑𝑑 constant mass = 𝑀 π‘…π‘–π‘”π‘–π‘‘π‘π‘œπ‘‘π‘¦ 𝑣 πΆπ‘’π‘›π‘‘π‘’π‘Ÿπ‘‚π‘“π‘€π‘Žπ‘ π‘  definitio n velocity
  • 30. Center of mass Combining both results yields a stunning property of the center of mass! 𝒑 π‘Ήπ’Šπ’ˆπ’Šπ’…π’ƒπ’π’…π’š = 𝑴 π‘Ήπ’Šπ’ˆπ’Šπ’…π’ƒπ’π’…π’š 𝒗 π‘ͺ𝒆𝒏𝒕𝒆𝒓𝑢𝒇𝑴𝒂𝒔𝒔 30 / 83
  • 31. Center of mass Combining both results yields a stunning property of the center of mass! 𝒑 π‘Ήπ’Šπ’ˆπ’Šπ’…π’ƒπ’π’…π’š = 𝑴 π‘Ήπ’Šπ’ˆπ’Šπ’…π’ƒπ’π’…π’š 𝒗 π‘ͺ𝒆𝒏𝒕𝒆𝒓𝑢𝒇𝑴𝒂𝒔𝒔 For finding the momentums of any rigid body, we can treat that body as single point mass and velocity. 31 / 83
  • 32. Center of mass This further applies to forces, as well: 32 / 83 πΉπ‘…π‘–π‘”π‘–π‘‘π‘π‘œπ‘‘π‘¦ = 𝑑𝑝 π‘…π‘–π‘”π‘–π‘‘π‘π‘œπ‘‘π‘¦ 𝑑𝑑 = 𝑑(𝑀 π‘…π‘–π‘”π‘–π‘‘π‘π‘œπ‘‘π‘¦ 𝑣 πΆπ‘’π‘›π‘‘π‘’π‘Ÿπ‘‚π‘“π‘€π‘Žπ‘ π‘ ) 𝑑𝑑 as we’ve just proven = 𝑀 π‘…π‘–π‘”π‘–π‘‘π‘π‘œπ‘‘π‘¦ 𝑑𝑣 πΆπ‘’π‘›π‘‘π‘’π‘Ÿπ‘‚π‘“π‘€π‘Žπ‘ π‘  𝑑𝑑 constant mass = 𝑀 π‘…π‘–π‘”π‘–π‘‘π‘π‘œπ‘‘π‘¦ π‘Ž πΆπ‘’π‘›π‘‘π‘’π‘Ÿπ‘‚π‘“π‘€π‘Žπ‘ π‘  definition acceleration
  • 33. Center of mass This further applies to forces, as well: We can treat all forces acting our rigid body as if their sum is acting on a point at the center of mass with the mass of the entire body. 33 / 83 πΉπ‘…π‘–π‘”π‘–π‘‘π‘π‘œπ‘‘π‘¦ = 𝑑𝑝 π‘…π‘–π‘”π‘–π‘‘π‘π‘œπ‘‘π‘¦ 𝑑𝑑 = 𝑑(𝑀 π‘…π‘–π‘”π‘–π‘‘π‘π‘œπ‘‘π‘¦ 𝑣 πΆπ‘’π‘›π‘‘π‘’π‘Ÿπ‘‚π‘“π‘€π‘Žπ‘ π‘ ) 𝑑𝑑 as we’ve just proven = 𝑀 π‘…π‘–π‘”π‘–π‘‘π‘π‘œπ‘‘π‘¦ 𝑑𝑣 πΆπ‘’π‘›π‘‘π‘’π‘Ÿπ‘‚π‘“π‘€π‘Žπ‘ π‘  𝑑𝑑 constant mass = 𝑀 π‘…π‘–π‘”π‘–π‘‘π‘π‘œπ‘‘π‘¦ π‘Ž πΆπ‘’π‘›π‘‘π‘’π‘Ÿπ‘‚π‘“π‘€π‘Žπ‘ π‘  definition acceleration
  • 34. Rotation β€’ So far, we’ve been talking all about linear momentum and linear acceleration. β€’ Now, we want to figure out how forces applied to our rigid bodies make them rotate. β€’ Where these forces are applied to the body will play an important role. 34 / 83
  • 35. Kinematics – Orientation The orientation Ω of an object is the angular difference between the world coordinate system and a coordinate system fixed in that object, in radians. 35 / 83
  • 36. Kinematics – Angular Velocity Angular Velocity is the rate of change of orientation over time. 36 / 83 𝝎 = 𝒅Ω 𝒅𝒕
  • 37. Kinematics – Angular Acceleration Angular Acceleration is the rate of change of angular velocity over time. 37 / 83 𝜢 = 𝒅 πœ” 𝒅𝒕
  • 38. Linear Velocity from Angular Velocity β€’ We often need to find the velocity of an arbitrary point on our object β–ͺ i.e. velocity of colliding points to compute how hard they hit each other β€’ Without rotation, the velocity of any point in the body is the same β–ͺ Velocity of the center of mass β€’ With rotation, every point might have a different velocity β–ͺ Obviously, we can’t keep track of the velocity of each of the infinity of points 38 / 83
  • 39. Linear Velocity from Angular Velocity Claim: The linear velocity of any point P inside an object that is rotating about its origin O, but not translating, is given by the following equation: 39 / 83 𝒗 𝑷 = πŽπ‘Άπ‘·βŠ₯
  • 40. Hint In 2D, the perpendicular of a vector (x, y) is (-y, x). 40 / 83
  • 41. Linear Velocity from Angular Velocity - Proof πŽπ‘Άπ‘·βŠ₯ has the correct magnitude, because and Ω 𝑢𝑷 is the length P is moving when moving Ω radians along the arc whose radius vector is 𝑢𝑷 , by definition of radians. 41 / 83 πœ”π‘‚π‘ƒβŠ₯ = πœ” 𝑂𝑃βŠ₯ = πœ” 𝑂𝑃 perpendiculary doesn’t change length = 𝑑Ω 𝑑𝑑 𝑂𝑃 definition πœ” = 𝑑(Ω 𝑂𝑃 ) 𝑑𝑑 𝑂𝑃 is constant
  • 42. Linear Velocity from Angular Velocity - Proof πŽπ‘Άπ‘·βŠ₯ has the correct direction, because a point rotating around another fixed point can only move perpendicularly to the vector between the points, or the movement wouldn’t be a simple rotation. πŽπ‘Άπ‘·βŠ₯ has the correct sign, because we’re measuring Ω in the counterclockwise direction. Ο‰ is positive when the point is rotating counterclockwise. The perpendicular operator points in the counterclockwise direction relative to the radius vector. 42 / 83
  • 43. Linear Velocity from Angular Velocity The linear velocity of any point P inside an object that is rotating about its origin O, but not translating, is given by the following equation: 43 / 83 𝒗 𝑷 = πŽπ‘Άπ‘·βŠ₯
  • 44. Linear Velocity from Angular Velocity The linear velocity of any point P inside an object that is rotating about its origin O, and is translating, is given by the following equation: 44 / 83 ?
  • 45. Chasles’ Theorem β€’ Chasles’ Theorem breaks up motion into linear and angular components. β€’ We consider any movement of our rigid body as β–ͺ translating a single point in the body β–ͺ rotating the rest of the body around that point 45 / 83
  • 46. Chasles’ Theorem The linear velocity of any point P inside a moving object that is rotating about its origin O is given by the following equation: (without proof) 46 / 83 𝒗 𝑷 = 𝒗 𝑢 + πŽπ‘Άπ‘·βŠ₯
  • 47. Kinematics – Angular Momentum The Angular Momentum of a point P tells us how much of the linear momentum pP of P is rotating around the origin. 47 / 83 𝑳 𝑢𝑷 = 𝑢𝑷βŠ₯ Γ— 𝒑 𝑷
  • 48. Kinematics – Angular Momentum The Angular Momentum of a point P tells us how much of the linear momentum pP of P is rotating around the origin. Note how angular momentum of a point P needs a reference (here: O), in contrast to linear momentum. 48 / 83 𝑳 𝑢𝑷 = 𝑢𝑷βŠ₯ Γ— 𝒑 𝑷
  • 49. Dynamics – Torque Torque is the rate of change of angular momentum over time. 49 / 83 𝝉 𝑢𝑷 = 𝒅 𝑳 𝑢𝑷 𝒅𝒕
  • 50. Dynamics – Torque We can use the torque to determine how much of the force applied at point P is causing the object to rotate: 50 / 83 𝜏 𝑂𝑃 = dLOP dt definition torque = d(OPβŠ₯Γ— pP) dt definition angular momentum = OPβŠ₯ Γ— dpp dt + dOPβŠ₯ dt Γ— pp product rule = (OPβŠ₯ Γ— 𝐹𝑃) + (vP Γ— 𝑝P) def. linear force, def. linear velocity = OPβŠ₯ Γ— 𝐹𝑃 velocity and momentum of P are parallel
  • 51. Calculating Angular Momentum Again, just like change in velocity can be numerically integrated using acceleration, change in angular momentum can be integrated using torque, from an applied force and position of application: 𝐿 𝑂𝑃 𝑑 = ΰΆ± 𝜏 𝑂𝑃 𝑑𝑑 = ΰΆ± OPβŠ₯ Γ— 𝐹𝑃 𝑑𝑑 51 / 83
  • 52. Moment of Inertia β€’ The moment of inertia I of an object is a measure of how hard it is to rotate the object about its center of mass. β€’ It is the sum of the squared distances from the center of mass to each other point in the body, scaling each squared distance by the mass of the respective point. 𝐼 = ෍ 𝑖 π‘šπ‘–OiβŠ₯ 2 52 / 83
  • 53. Moment of Inertia The moment of inertia can be used to derive the total angular momentum: 𝐿 = ෍ 𝑖 OiβŠ₯ Γ— pi definition angular momentum = ෍ 𝑖 OiβŠ₯ Γ— (π‘šπ‘– 𝑣𝑖) Definition linear momentum = ෍ 𝑖 OiβŠ₯ Γ— (π‘šπ‘– πœ”π‘‚π‘–βŠ₯) Linear velocity from angular velocity = πœ” ෍ 𝑖 OiβŠ₯ Γ— (π‘šπ‘– 𝑂𝑖βŠ₯) Angular velocity same for all points i = πœ” ෍ 𝑖 π‘šπ‘–OiβŠ₯ 2 = πœ”πΌ definition moment of intertia
  • 54. Hint As the moment of inertia is based on the mass and relative position of all points of a rigid body, only, it is constant and has to be computed only once! 54 / 83
  • 55. Dynamics – Torque Integration shows how torque and angular acceleration are related: 𝜏 = 𝑑𝐿 𝑑𝑑 definition torque = π‘‘πœ”πΌ 𝑑𝑑 as we’ve just proven = 𝐼 π‘‘πœ” 𝑑𝑑 moment of inertia constant = 𝐼𝛼 Definition angular acceleration 55 / 83
  • 56. Dynamics – Torque Thus, knowing the torque on our body, we can compute angular acceleration, and then find angular velocity and orientation by numeric integration. 𝝉 = π‘°πœΆ 56 / 83
  • 57. Full Physics Simulation – Setup For each rigid body: 1. Calculate center of mass and moment of inertia at the center of mass. 2. Set initial position, orientation, linear velocity and angular velocity. 57 / 83
  • 58. Full Physics Simulation – Loop For each rigid body: 1. Collect all forces on the body, including their points of application. 2. Sum all forces and compute linear acceleration. 3. Compute the torque caused by each force. 4. Sum all torque and compute angular acceleration. 5. Numerically integrate linear acceleration and angular acceleration to update linear velocity and angular velocity, and position and orientation. 58 / 83
  • 59. Hint Usually, games will treat both mass and moment of inertia as properties of the rigid body. 59 / 83
  • 60. Collision Response β€’ Given we know that there is a collision, the task is to find out how to handle that collision. β€’ We need to decide where the colliding objects move, and if and how they start spinning. β€’ By now, velocities never changes instantly, but by means forces applied over time, only. 60 / 83
  • 61. Impulse β€’ An impulse changes the momentum (and thus, the velocity) of a rigid body instantly, without the need of integration over time. β€’ We’re going to use Newton’s Law of Restitution for Instantaneous Collisions with No Friction to find the impulses to apply in case of a collision. 61 / 83
  • 62. Newton’s Law of Restitution for Instantaneous Collisions with No Friction β€’ Instantaneous: in no time β€’ Restitution: coefficient of restitution models the compression and restitution of impacting bodies with a single scalar β€’ No friction: impulse is entirely pointed in the direction of the collision normal 62 / 83
  • 63. Collision Data β€’ Collision point P β€’ Center of mass of both bodies A, B β€’ Velocity of the collision point of both bodies 𝑣 𝐴, 𝑣 𝐡 β€’ Collision normal n 63 / 83
  • 64. Derived Collision Data Relative velocity 𝑣 𝐴𝐡 = 𝑣 𝐴 βˆ’ 𝑣 𝐡 Relative normal velocity 𝑣 𝐴𝐡 𝑛 = 𝑣 𝐴 βˆ’ 𝑣 𝐡 𝑛 64 / 83
  • 65. Coefficient of Restitution β€’ The Coefficient of Restitution πœ– tells us how much of the incoming energy is dissipated during the collision. β€’ πœ– = 1 yields a totally elastic collision (super ball) β€’ πœ– = 0 yields a totally plastic collision (all energy absorbed) 𝑣 𝐴𝐡 β€² 𝑛 = βˆ’πœ–π‘£ 𝐴𝐡 𝑛 65 / 83
  • 66. Collision Impulse By understanding the collision impulse j as change of momentum, we expect the resulting velocities 𝑣 𝐴 β€² and 𝑣 𝐡 β€² to yield the following: 𝑣 𝐴 β€² = 𝑣 𝐴 + 𝑗 𝑀𝐴 𝑛 𝑣 𝐡 β€² = 𝑣 𝐡 βˆ’ 𝑗 𝑀 𝐡 𝑛 66 / 83
  • 67. Finding the Collision Impulse Now that we’ve got everything in place, we can finally compute the collision impulse. 67 / 83 βˆ’πœ–π‘£ 𝐴𝐡 𝑛 = 𝑣 𝐴𝐡 β€² 𝑛 definition coefficient of restitution = (𝑣 𝐴 β€² βˆ’ 𝑣 𝐡 β€² )𝑛 definition relative velocity = (𝑣 𝐴 + 𝑗 𝑀𝐴 𝑛 βˆ’ 𝑣 𝐡 + 𝑗 𝑀 𝐡 𝑛)𝑛 definition collision impulse = 𝑣 𝐴 𝑛 + 𝑗 𝑀𝐴 𝑛𝑛 βˆ’ 𝑣 𝐡 𝑛 + 𝑗 𝑀 𝐡 𝑛𝑛 distribution = 𝑣 𝐴 𝑛 βˆ’ 𝑣 𝐡 𝑛 + 𝑗 𝑀𝐴 𝑛𝑛 + 𝑗 𝑀 𝐡 𝑛𝑛 commutative property = 𝑣 𝐴𝐡 𝑛 + 𝑗 𝑀𝐴 𝑛𝑛 + 𝑗 𝑀 𝐡 𝑛𝑛 definition relative velocity
  • 68. Finding the Collision Impulse Now that we’ve got everything in place, we can finally compute the collision impulse. 68 / 83 𝑣 𝐴𝐡 𝑛 + 𝑗 𝑀𝐴 𝑛𝑛 + 𝑗 𝑀 𝐡 𝑛𝑛 = βˆ’πœ–π‘£ 𝐴𝐡 𝑛 𝑗 𝑀𝐴 𝑛𝑛 + 𝑗 𝑀 𝐡 𝑛𝑛 = βˆ’πœ–π‘£ 𝐴𝐡 𝑛 βˆ’ 𝑣 𝐴𝐡 𝑛 𝑗( 1 𝑀𝐴 𝑛𝑛 + 1 𝑀 𝐡 𝑛𝑛) = βˆ’πœ–π‘£ 𝐴𝐡 𝑛 βˆ’ 𝑣 𝐴𝐡 𝑛 distribution 𝑗 = βˆ’πœ–π‘£ 𝐴𝐡 𝑛 βˆ’ 𝑣 𝐴𝐡 𝑛 1 𝑀𝐴 𝑛𝑛 + 1 𝑀 𝐡 𝑛𝑛
  • 69. Finding the Collision Impulse Now that we’ve got everything in place, we can finally compute the collision impulse. 69 / 83 𝑗 = βˆ’πœ–π‘£ 𝐴𝐡 𝑛 βˆ’ 𝑣 𝐴𝐡 𝑛 1 𝑀𝐴 𝑛𝑛 + 1 𝑀 𝐡 𝑛𝑛 = βˆ’π‘£ 𝐴𝐡 𝑛(1 + Ο΅) 1 𝑀𝐴 𝑛𝑛 + 1 𝑀 𝐡 𝑛𝑛 distribution = βˆ’π‘£ 𝐴𝐡 𝑛(1 + Ο΅) 𝑛𝑛( 1 𝑀𝐴 + 1 𝑀 𝐡 ) distribution
  • 70. Finding the Collision Impulse Now that we’ve got everything in place, we can finally compute the collision impulse. 70 / 83 𝑗 = βˆ’πœ–π‘£ 𝐴𝐡 𝑛 βˆ’ 𝑣 𝐴𝐡 𝑛 1 𝑀𝐴 𝑛𝑛 + 1 𝑀 𝐡 𝑛𝑛 = βˆ’π‘£ 𝐴𝐡 𝑛(1 + Ο΅) 1 𝑀𝐴 𝑛𝑛 + 1 𝑀 𝐡 𝑛𝑛 distribution = βˆ’π‘£ 𝐴𝐡 𝑛(1 + Ο΅) 𝑛𝑛( 1 𝑀𝐴 + 1 𝑀 𝐡 ) distribution Plugging in j back into our collision impulse equation yields the new velocities of A and B!
  • 71. Collision Impulse II Finally, we need to understand how to have the collision impulse j change the angular momentum: πœ” 𝐴 β€² = πœ” 𝐴 + 𝐴𝑃βŠ₯ 𝑗𝑛 𝐼𝐴 πœ” 𝐡 β€² = πœ” 𝐡 βˆ’ 𝐡𝑃βŠ₯ 𝑗𝑛 𝐼 𝐡 71 / 83
  • 72. Finding the Collision Impulse Let’s close by computing the collision impulse with spin: 72 / 12 βˆ’πœ–π‘£ 𝐴𝐡 𝑛 = 𝑣 𝐴𝐡 β€² 𝑛 definition coefficient of restitution = (𝑣 𝐴𝑃 β€² βˆ’ 𝑣 𝐡𝑃 β€² )𝑛 definition relative velocity = (𝑣 𝐴 β€² + πœ” 𝐴 β€² 𝐴𝑃βŠ₯ βˆ’ (𝑣 𝐡 β€² + πœ” 𝐡 β€² 𝐡𝑃βŠ₯))𝑛 Chasles’ Theorem = (𝑣 𝐴 β€² + πœ” 𝐴 β€² 𝐴𝑃βŠ₯ βˆ’ 𝑣 𝐡 β€² βˆ’ πœ” 𝐡 β€² 𝐡𝑃βŠ₯)𝑛 = (𝑣 𝐴 + 𝑗 𝑀𝐴 𝑛 + (πœ” 𝐴 + 𝐴𝑃βŠ₯ 𝑗𝑛 𝐼𝐴 )𝐴𝑃βŠ₯ βˆ’ (𝑣 𝐡 βˆ’ 𝑗 𝑀 𝐡 𝑛) βˆ’ (πœ” 𝐡 βˆ’ 𝐡𝑃βŠ₯ 𝑗𝑛 𝐼 𝐡 )𝐡𝑃βŠ₯)𝑛 definition collision impulse = (𝑣 𝐴 + 𝑗 𝑀𝐴 𝑛 + πœ” 𝐴 𝐴𝑃βŠ₯ + 𝐴𝑃βŠ₯ 2 𝑗𝑛 𝐼𝐴 βˆ’ 𝑣 𝐡 + 𝑗 𝑀 𝐡 𝑛 βˆ’ πœ” 𝐡 𝐡𝑃βŠ₯ + 𝐡𝑃βŠ₯ 2 𝑗𝑛 𝐼 𝐡 )𝑛 = 𝑣 𝐴 𝑛 + 𝑗 𝑀𝐴 𝑛𝑛 + πœ” 𝐴 𝐴𝑃βŠ₯ 𝑛 + 𝐴𝑃βŠ₯ 2 𝑗𝑛𝑛 𝐼𝐴 βˆ’ 𝑣 𝐡 𝑛 + 𝑗 𝑀 𝐡 𝑛𝑛 βˆ’ πœ” 𝐡 𝐡𝑃βŠ₯ 𝑛 + 𝐡𝑃βŠ₯ 2 𝑗𝑛𝑛 𝐼 𝐡 distribution
  • 73. Finding the Collision Impulse Let’s close by computing the collision impulse with spin: 73 / 12 𝑗 𝑀𝐴 𝑛𝑛 + 𝐴𝑃βŠ₯ 2 𝑗𝑛𝑛 𝐼𝐴 + 𝑗 𝑀 𝐡 𝑛𝑛 + 𝐡𝑃βŠ₯ 2 𝑗𝑛𝑛 𝐼 𝐡 = βˆ’π‘£ 𝐴 𝑛 βˆ’ πœ” 𝐴 𝐴𝑃βŠ₯ 𝑛 + 𝑣 𝐡 𝑛 + πœ” 𝐡 𝐡𝑃βŠ₯ 𝑛 βˆ’ πœ–π‘£ 𝐴𝐡 𝑛 j to left side, non-j to right side 𝑗𝑛𝑛( 1 𝑀𝐴 + 𝐴𝑃βŠ₯ 2 𝐼𝐴 + 1 𝑀 𝐡 + 𝐡𝑃βŠ₯ 2 𝐼 𝐡 ) = βˆ’π‘›(𝑣 𝐴 + πœ” 𝐴 𝐴𝑃βŠ₯ βˆ’ 𝑣 𝐡 βˆ’ πœ” 𝐡 𝐡𝑃βŠ₯ + πœ–π‘£ 𝐴𝐡) distribution 𝑗𝑛𝑛( 1 𝑀𝐴 + 𝐴𝑃βŠ₯ 2 𝐼𝐴 + 1 𝑀 𝐡 + 𝐡𝑃βŠ₯ 2 𝐼 𝐡 ) = βˆ’π‘›(𝑣 𝐴𝑃 βˆ’ 𝑣 𝐡𝑃 + πœ–π‘£ 𝐴𝐡) Chasles’ Theorem 𝑗𝑛𝑛( 1 𝑀𝐴 + 𝐴𝑃βŠ₯ 2 𝐼𝐴 + 1 𝑀 𝐡 + 𝐡𝑃βŠ₯ 2 𝐼 𝐡 ) = βˆ’π‘›(𝑣 𝐴𝐡 + πœ–π‘£ 𝐴𝐡) definition relative velocity 𝑗𝑛𝑛( 1 𝑀𝐴 + 𝐴𝑃βŠ₯ 2 𝐼𝐴 + 1 𝑀 𝐡 + 𝐡𝑃βŠ₯ 2 𝐼 𝐡 ) = βˆ’π‘›π‘£ 𝐴𝐡(1 + πœ–) distribution 𝑗 = βˆ’π‘›π‘£ 𝐴𝐡(1 + πœ–) 𝑛𝑛( 1 𝑀𝐴 + 𝐴𝑃βŠ₯ 2 𝐼𝐴 + 1 𝑀 𝐡 + 𝐡𝑃βŠ₯ 2 𝐼 𝐡 )
  • 74. Collision Detection β€’ Now that we know how to handle collisions, all that’s left is to understand how to detect them β€’ As detecting intersections between arbitrary polygons is quite expensive, they are usually wrapped by some kind of collision shape β€’ With these shapes, typical test like shape-shape intersection and ray-shape intersection become far cheaper β€’ The quality of the collision detection depends on how good the shapes fit the actual body 74 / 83
  • 75. Collision Spheres Detecting whether two spheres A and B intersect is as easy as comparing their distance to the sum of their radii. 75 / 83
  • 76. Collision Spheres The potential collision point lies on the ray from sphere A to B at the exact radius of A. 76 / 83
  • 77. Collision Spheres Detecting whether a ray intersects a sphere requires some tedious, but basic math (see References) 77 / 83
  • 78. Axis-Aligned Bounding Boxes Detecting whether two axis-aligned bounding boxes 𝐴 π‘šπ‘–π‘›, 𝐴 π‘šπ‘Žπ‘₯ and (𝐡 π‘šπ‘–π‘›, 𝐡 π‘šπ‘Žπ‘₯) intersect can be easily checked using the separating axis theorem: 78 / 83
  • 79. Axis-Aligned Bounding Boxes Detecting whether two axis-aligned bounding boxes 𝐴 π‘šπ‘–π‘›, 𝐴 π‘šπ‘Žπ‘₯ and (𝐡 π‘šπ‘–π‘›, 𝐡 π‘šπ‘Žπ‘₯) intersect can be easily checked using the separating axis theorem: 𝐴 π‘šπ‘–π‘› π‘₯ > 𝐡 π‘šπ‘Žπ‘₯ π‘₯ or 𝐡 π‘šπ‘–π‘› π‘₯ > 𝐴 π‘šπ‘Žπ‘₯ π‘₯ or 𝐴 π‘šπ‘–π‘› 𝑦 > 𝐡 π‘šπ‘Žπ‘₯ 𝑦 or 𝐡 π‘šπ‘–π‘› 𝑦 > 𝐴 π‘šπ‘Žπ‘₯ 𝑦 or 𝐴 π‘šπ‘–π‘› 𝑧 > 𝐡 π‘šπ‘Žπ‘₯ 𝑧 or 𝐡 π‘šπ‘–π‘› 𝑧 > 𝐴 π‘šπ‘Žπ‘₯ 𝑧 79 / 83
  • 80. Tunneling β€’ If your objects move too fast, you run in danger of missing collisions due to your numerical integration step size. β€’ Imagine a sphere moving fast towards a thin wall. 80 / 83
  • 81. Tunneling – Possible Solutions β€’ Make the wall thicker. β–ͺ Need to instruct all level designers. β€’ Impose an upper bound on object speed. β€’ Find the speculative contact through the bounding box of the previous position of the moving object and the current one, and sub- step from the contact point β–ͺ Arbitrary convex polygons are a challenge (see Continuous Collision by Erin Catto in References) 81 / 83
  • 82. Octrees β€’ Checking every pair of objects can be very expensive β€’ The number of required checks can be reduced by subdividing the space into smaller parts, and checking only pairs of objects who are found within the same part 82 / 83 Image by Bill Jacobs
  • 83. Octree Construction β€’ Start with an empty root node covering the entire world β€’ Whenever you add an object to the world, start at the root node and traverse the tree, finding the node farthest from the root that fully contains the object β€’ If the node has reached its maximum capacity now, subdivide it into children 83 / 83
  • 84. Collision Detection using Octrees β€’ Given an octree containing shapes, we only need to check all pairs of shapes that are found within the same node β€’ Shaped in non-leaf nodes need to be checked against all shapes of all child nodes, and their children 84 / 83
  • 85. Optimizing Octrees β€’ If the average object size begins to exceed the node size, objects will start to be put in parent nodes more often. β€’ Limiting the depth of the octree helps avoiding this issue. β€’ For the same reason, it might be necessary to merge nodes again if objects have moved away. 85 / 83
  • 86. Future Work β€’ 3D (Matrices & Quaternions) β€’ Joints β€’ Non-rigid bodies β€’ Detecting Arbitrary Collisions 86 / 83
  • 87. References β€’ Fiedler. Game Physics – Integration Basics. http://gafferongames.com/game-physics/integration- basics/, 2006. β€’ Fielder. Game Physics – Fix Your Timestep! http://gafferongames.com/game-physics/fix-your- timestep/, 2006. β€’ Hecker. Physics, The Next Frontier. Game Developer Magazine, October/November 1996. β€’ Hecker. Physics, Part 2: Angular Effects. Game Developer Magazine, December 1996/January 1997. β€’ Hecker. Physics, Part 3: Collision Response. Game Developer Magazine, March 1997. β€’ Catto. Box2D User Manual. http://box2d.org/manual.pdf, 2007. β€’ Catto. Physics for Game Programmers – Continuous Collision. http://www.gdcvault.com/play/1018239/Physics-for-Game-Programmers-Continuous, 2013. β€’ Baraff. Physically Based Modelling – Rigid Body Simulation. http://www.pixar.com/companyinfo/research/pbm2001/pdf/notesg.pdf, 2001. β€’ Jacobs. OpenGL Tutorial – Collision Detection. http://www.videotutorialsrock.com/opengl_tutorial/collision_detection/text.php, 2014. β€’ Su. Ray-Sphere Intersection. http://www.cs.tufts.edu/~sarasu/courses/comp175- 2009fa/pdf/comp175-15-ray-sphere.pdf, November 11, 2009. 87 / 83
  • 89. 10 Minute Review Session β€’ What’s the difference between kinematics and dynamics? β€’ What is velocity? β€’ What is acceleration? β€’ What is momentum? β€’ What is force? β€’ In your own words: How does Explicit Euler Integration work? β€’ Why are fixed time steps important in physics simulation? β€’ What is a rigid body?
  • 90. 10 Minute Review Session β€’ What is the center of mass? β€’ In your own words: Explain Chasles’ Theorem! β€’ What is torque? β€’ What is moment of inertia? β€’ What is an impulse? β€’ Which data is required for resolving collisions? β€’ Which collision shapes do you know? β€’ How can you prevent tunneling? β€’ How can you reduce the number of collisions to check for?