Title: Particle Kinematics: Translation at Constant Velocity
1Fac. of Comp., Eng. Tech. Staffordshire
University
Programming Physics Engines for Games
Particle KinematicsTranslation at Constant
Velocity
Dr. Claude C. Chibelushi
2Outline
- Introduction
- Motion Formulas
- Problem Solving Procedure
- Software Implementation
- Summary
3Introduction
- This lecture considers rigid body which has
- no (or negligible) angular motion
- only translational motion considered
- particle model can be used
- no net external force
4Introduction
- Implication of Newtons 1st and 2nd law of
motion - no net force results in no acceleration
- hence constant velocity
- constant magnitude (may be 0)
- constant direction
- hence rectilinear motion
5Motion Formulas
Translation at constant velocity
6Motion Formulas
- Average speed
- distance travelled divided by corresponding
duration - For rectilinear motion distance travelled equals
displacement magnitude - hence, during time interval ?t t2 t1
- for displacement ?s s2 s1, average velocity
v ?s / ?t - If velocity is constant
- average velocity equals instantaneous velocity
7Motion Formulas
Rearranging gives
Generalising p2 to p, and t2 to t (i.e. p is
position at any instant t) gives
If t1 0 (e.g. stop watch reset to 0 at instant
t1) then
8Motion Formulas
Summary of formula set
No net external force
General case
Special case t1 0
9Problem Solving Procedure
- 1D motion
- Specify coordinate system
- origin
- positive and negative direction along axis of
motion - e.g. corresponding to forward or backward movement
10Problem Solving Procedure
- 1D motion
- Specify known motion parameters
- use signed scalar values
- Compute unknown motion parameter(s) using
appropriate formula(s)
11Problem Solving Procedure
- 1D motion example
- Develop physics engine for coolest game ever
- Boy Racer Returns!
12Problem Solving Procedure
- 1D motion example
- Boy racing car along straight road from Stafford
to Stoke - road length 30 km
- car speed at departure point 60 km / h
- no net external force acts on car and driver
throughout race - challenge break the record (20 min)
- Did boy racer win?
13Problem Solving Procedure
- 2D motion
- Specify coordinate system
- origin
- positive and negative direction of x- and
y-coordinate axes, corresponding to e.g. - forward or backward movement
- up or down movement
14Problem Solving Procedure
- 2D motion
- Specify known motion parameters
- two signed scalar values for each 2D parameter
- Compute unknown motion parameter(s) using
appropriate formula(s) - can apply formula(s) to each axis, independently
of other axis
15Problem Solving Procedure
- 2D motion example
- Develop physics engine for VR application Save
Dino - the last surviving dinosaur is running for its
life, in a hail of asteroids - Dinos path crosses asteroid path
- player sets asteroid velocity
- computer advises Dino what speed to avoid
16Problem Solving Procedure
- 2D motion example
- Initial motion parameters
- position (x, y) data
- dinosaur (10 km, 210 km)
- asteroid (10 km, 10 km)
- asteroid speed 100 km / h (constant)
- Dinosaur speed constant
- challenge save Dino! Tell Dino what speed to
avoid
17Software Implementation
- Define data structures
- possible data grouping
- // C structure for 2D point or vector
- typedef struct vector2DTag
- float x
- float y
- Point2D, Vector2D
- note structure replaced by class in Java
18Software Implementation
- possible data grouping (ctd.)
- // C structure for particle in 2D space
- typedef struct particle2DTag
- Point2D pos
- Vector2D vel
- Particle2D
19Software Implementation
- Declare variables
- particle position, velocity
- Particle2D asteroid
- simulation time
- long int curTime
20Software Implementation
- Initialise known quantities
- asteroid.pos.x 10000.0
- asteroid.pos.y 10000.0
- asteroid.vel.x 70710.7
- asteroid.vel.y 70710.7
21Software Implementation
- Update simulation state (in simulation loop)
- curTime readComputerTime()
- timeStep curTime - prevUpdateTime
- prevUpdateTime curTime
- asteroid.pos.x asteroid.vel.x timeStep
- asteroid.vel.y asteroid.vel.y timeStep
22Software Implementation
- Update simulation state (ctd.)
- simplification for fixed time step
- position increment / decrement at each
simulation clock tick is constant (calculated
once outside simulation loop) - Vector2D posStep
- posStep.x asteroid.vel.x timeStep
- posStep.y asteroid.vel.y timeStep
- update position (inside simulation loop)
- asteroid.pos.x posStep.x
- asteroid.vel.y posStep.y
23Suggested Reading
- Relevant parts of Ch. 2, D.M. Bourg, Physics for
Game Developers, OReilly Associates, 2002.
24Summary
- No net external force, hence
- no motion
- or rectilinear motion at constant velocity
- equation of translational motion position update
step proportional to time interval - proportionality factor velocity
25Summary
- Problem solving procedure
- specify coordinate system, and known motion
parameters - compute unknown motion parameter(s)
- Software implementation
- define data structures
- possibly group related variables
- declare variables and initialise known quantities
- repeatedly update simulation state