Object motion is represented with vectors.

Velocity is a vector:

Vector direction is direction of movement

Vector magnitude is speed of movement

Velocity vector corresponds to amount object will move in one unit of time.

*Displacement* = *Velocity* * *time*

If an object starts at position **P _{0}**,
with velocity

after

P(t) = P_{0}+ V * t

Note: choice of units is arbitrary, as long as things are consistent.

e.g. use meters for distance, seconds for time, and meters/second for velocity.

Don't try to combine meters/second with miles/hour, for instance.

The previous formula only works if the object moves with a constant velocity.

In many cases, objects' velocities change over time.

In such a case, velocity is a function that we integrate.

*Displacement* = *Velocity* *dt*

In complex motion, there isn't an analytical solution (i.e. a simple formula).

*Euler integration* approximates an integral by step-wise addition.

At each time step, we move the object in a straight line using the current velocity:

dt = t_{1}- t_{0}P(t_{1}) = P(t_{0}) + V * dt

Example: bounce.py

Velocity is the integral of acceleration:

Applying Euler integration again gives:

dt = t_{1}- t_{0}Acc = computeAcceleration() Vel = Vel + Acc * dt Pos = Pos + Vel * dt

Gravity near the Earth's surface produces a constant acceleration
of 9.8 m/sec^{2}

In this case:

Acc = Vector([0, -9.8, 0])

Example: gravbounce.py

Newton's 2nd Law of Motion:

Which can be rewritten as

If an object has mass *M*, and force *F* is applied to it,

its motion can be calculated via Euler integration:

Acc = F / M Vel += Acc * dt Pos += Vel * dt

Note that *F*, *Acc*, *Vel*, and *Pos*
are all vectors. *M* is a scalar.

*F* = (*G* * *M _{1}* *

For a complete simulation, we need to calculate the force on each object every frame.

When multiple forces are applied, their vectors are added.

Example: gravorbit.py

Drag (slow moving objects):

*F* = *C _{drag}* *

Drag (fast moving objects):

*F* = *C _{drag}* *

Buoyancy:

*F* = *ρ _{liquid}* *

Example: buoyancy.py