1Representing Object Movement
Requires Position, Velocity and Acceleration
2Position
The location of an object in space, represented by a vector (2D or 3D)
3Velocity
Amount of change in a position, represented in direction and magnitude (speed)
4Acceleration
The amount of change in velocity
Not typically stored, calculated using other factors
5Newton's First Law
Law of Inertia
An object keeps its velocity unless acted upon by some other force
6Inertia
Resistance to change in motion
7Newton's Second Law
Force = mass x acceleration
8Newton's Third Law
For every action there is an equal and opposite reaction
9Equations of Motion
SUVAT equations
s = Displacement
u = Initial Velocity
v = Final Velocity
a = Acceleration
t = Time
v = u + at
s = ut + 1/2at^2
s = 1/2(u+v)t
v^2 = u^2 + 2as
10Vectors
Quantities that have both a magnitude and a direction.
E.g. [1, 0, 2]
Easily addable, easily multiplicative with a scalar
Normalised direction can be calculated by:
-vector / vector length
11Derivatives
Calculation of change in something, makes for easy translation between velocity, acceleration, etc.
12Integrals
The reversing of derivatives, used for figuring out the states of objects in the future.
13Explicit Euler
vn+1 = vn + andt
pn+1 = pn + vndt
Uses the velocity and acceleration of the current frame to get the velocity of the next
Not perfect, we ignore acceleration throughout the timestep, causing inaccuracies over time
14Implicit Euler
vn+1 = vn + an+1dt
pn+1 = pn + vn+1dt
Uses the projected velocity and acceleration of the next frame to get the velocity of the next
More accurate if you have the data, but since we don't due to real time simulation it is wildly inaccurate (prediction)
15Semi-Implicit Euler
vn+1 = vn + andt
pn+1 = pn + vn+1dt
Uses the acceleration of the current frame and the projected velocity of the next frame.
Most accurate we can do in real time
16Time in physics engines
Extremely important, as objects need to be consistent with each other
17VSync
Stands for "vertical synchronization," is used to synchronize the graphics card/framerate with the output on the monitor.
18Fixed Timestep
A customizable framerate-independent interval that dictates when physics calculations and FixedUpdate() events are performed, regardless of how fast the machine is running.
The smaller this is the better, as it gives more accurate results.
19Physics Bodies
Objects recognised by a physics engine that it will update.
20Particles
Easiest representation of a physics body
Has mass and position
Doesn't have orientation
21Rigid Bodies
Most common representation of a physics body
Has mass, position, and volume the mess is distributed around, as well as orientation
Doesn't change shape over time
22Springs
Elastic connectors that bring objects together and push them apart.
Uses Hooke's Law for the calculation (F = -kx) (K = elasticity of spring, X = distance from resting length)
Takes into account spring damping to get the effect of friction (F = -kx - c.v) (c = damping factor, v = velocity along spring axis)
23Soft Bodies
Rigid bodies that can deform, used for cloth-type material.
Typically modelled with a grid of rigid bodies connected via springs with resting length equal to grid spacing.
If a force is applied to one of the masses, the springs attached to it stretch and eventually apply force to all the masses.
Does require extra structural support to maintain their 3D shapes
24Physics Engine Loop
Integrate Acceleration
Collision Detection
Collision Resolution
Integrate Velocity
25Integrating Acceleration
Forces that have acted on an object in a timestep are stored for calculation.
a = F/m
26Mass
The amount of matter in an object
Stored in physics engines as 1/m, in order for a quicker calculation. Allows for infinitely heavy objects (m = 0)
27Collision Detection & Resolution
Objects in the world are examined for collisions, and if so they react accordingly.
Done before velocity is calculated so the reactions can be taken into account.
Done after acceleration in order to determine momentum, so it can be conserved.
28Integration of Velocity
Uses all previously calculated information to get the velocity of the object (using Semi-Implicit Euler or similar).
Typically game engines use a damping factor to reduce velocity over time (simulation of air resistance)