] >
Note: this web page uses MathML, mathematics markup for the web. We have installed mathjax which should render the MathML, but if the maths rendering looks broken, try Firefox, as it has strong MathML support. Chrome/Chromium support is being introduced.
The behaviour of objects subject to forces has long been studied in physics, in the area known as mechanics. Within mechanics are sub-areas of statics, where objects are fixed, and dynamics where objects move.
Dynamics is the most relevant to games and graphics.
There are two broad categories of motion studied in dynamics: linear motion and rotational motion.
Dynamics includes the laws of motion. These are physical laws which describe how the universe works.
Newton's laws of motion are the foundation for much of mechanics, from [1]:
By Newtons first law when there is no force, i.e. F=0 the velocity remains constant. Assuming an object is moving in the x direction:
We can solve for x by integrating both sides of the equation:
where is the initial velocity in the x direction.
This equation allows the calculation of x for any value of t, i.e. ,
Constant acceleration is a special case which occurs when a force is constant, and assuming mass is constant, Newton's second law says acceleration is constant.
One situation in which constant acceleration occurs is objects close to the earth's surface subject falling due to gravity, which all undergo the same acceleration in the y direction:
To solve, integrate twice to get
where and are the initial velocity and position in the y direction respectively.
This equation allows the calculation of y for any value of t, i.e.
Projectile motion is the type of motion a projectile, such as a cannon ball, undertakes when subject to the force of gravity. Projectile motion has the shape of a parabola
Because gravity acts only in the vertical direction, and (it is assumed that) there are no forces in the horizontal direction, the only acceleration is in the y direction.
Thus projectile motion can be separated into constant acceleration in the y direction, as above, and constant velocity in the x direction, by Newton's first law.
The parametric equations for projectile motion are then just those above:
Often the symbol is used for the position, or position vector, of a point given by parametric equations.
The initial velocities in the x and y directions are known if the initial velocity vector is in kept in component form, i.e. or can be calculated using the cos and sin of the angle the initial velocity vector makes with the x axis and
The time of flight of a projectile can be calculated by working out the time at which the projectile hits the ground. For example, the simplest case is where a projectile is fired from and hits flat ground at
Equations like the ones above which describe how an object moves, including differential equations, initial positions and velocities, are called equations of motion. Then we solve the equations of motion to give position as a function of time of the objects involved. The position of objects over time is usually the most important aspect of the solution.
Differential equations, such as the one above, are solved by integration. There are two main approaches: analytical and numerical. Some cases, such as projectile motion above, can be solved analytically. But in many or even most cases numerical integration must be used, as analytical solution is not possible. One example is particles which interact with each by forces such as gravity, or in general where ever there are collisions. Most physics in games uses numerical integration.
Numerical integration amounts to working out small changes, or deltas, in one variable given small changes in another - usually time if objects are moving. Approximate estimated values can be found by linearization, or more simply linear interpolation using gradients, and remembering that gradients are derivatives.
For example, given velocity v and a small change in time dt a new position can be found:
Similarly, given acceleration a and dt a new velocity can be be found as:
Putting both of those together, and skipping over many issues about accuracy, we get:
Notice that position is updated first, and then velocity, although other techniques may update variables in different orders.
Also notice that for the case of constant acceleration, where the acceleration never changes, can simplify as:
The above numerial approach is called Euler integration. It is simple, but fairly inaccurate.
More accuracy can be obtained by different ways of estimating values. For example, a better estimate of velocity over the time interval t, t+dt might be at the midpoint:
This approach is known as the improved Euler method, and also as the midpoint method.
The velocity Verlet integration approach incorporates an acceleration term when updating the position, and uses the average of the acceleration at the start and at the end of the time step to update velocity:
Another approach is to use not linear interpolation, but quadratic or cubic interpolation - using not just 2 values, but 3 or 4.
There is a very extensive body of knowledge about numerical methods, which are particularly important in physics simulations. Game physics are increasingly using the same techniques, however accuracy is usually not as important and for example may be traded for performance.
A simple C program for projectile motion which calculates motion both analytically and numerically
Often in games objects slide on surfaces. A basis for computing their motion can be found in the block on a ramp or inclined plane problem:
Assume the only force acting is gravity, and there is no friction. The force due to gravity, usually known as weight, is .
The weight force can be resolved into vectors perpendicular ⟂ and parallel ∥ to the plane:
The block sits and slides on the surface of the plane, but does not fall through. By Newton's third law equal and opposite forces in the direction normal i.e. perpendicular to the ramp cancel each other out - the force of the block on the plane in the direction of the normal due to gravity, and the equal and opposite reaction or normal force that the plane exerts on the block:
So the net or resultant force acting on the block is and by Newton's second law gives
In order to numerically integrate the motion need the accelerations and in the and directions respectively. They can be obtained by resolving the (resultant) force in the and directions
Objects moving in a fluid or gas encounter a drag force, which resists, i.e. acts opposite to the motion. Typically the drag force increases with an object's speed. A simple model for drag uses the square of the velocity and a coefficent of drag:
Objects in contact encounter friction which resists sliding or relative motion. There are two types: static and dynamic or kinetic. Static friction occurs before objects start to slide, after which dynamic friction occurs.
A simple model of dynamic friction uses a coefficent of drag which increases with how much force is being applied between the sliding surfaces, i.e. the normal force:
For objects which are smooth friction can be quite low, and as their relative speed increases drag is usually the more important force.
A simple example C program for a block on a ramp.
One way which is being pursued to achieve both higher performance and more accuracy is to use the GPU to perform physics calculations.
Using the GPU to perform non-graphics calculations is referred to as GPU computing. GPUs are being used for biology, cryptography, weather simulation etc.
[1] Wikipedia: Newton's law