Game Development Reference

In-Depth Information

using the overloaded operator forms of
+
and
*
wedefinedearlier.Infactthisisexactly

the purpose of our
addScaledVector
method, so we can write

position.addScaledVector(velocity, t);

and have it done in one operation, rather than taking the risk that our compiler will

decide to create and pass around extra vectors on the stack.

We now have almost all the mathematics we need for the particle engine imple-

mentation. We will implement the integration step in the next chapter, after we look

at the physics involved in simulating particles.

2.3

S
UMMARY

Vectors form the basis of all the mathematics in this topic. As we've seen, they are

easy to manipulate numerically and through simple routines in code. It is impor-

tant to remember, however, that vectors are geometrical: they represent positions and

movements in space. It is very often much simpler to understand the formulae in this

book in terms of their corresponding geometric properties rather than look at them

numerically.

Describing positions and movements in terms of vectors is fine, but to make a

physics engine we'll need to begin to link the two. That is, we'll have to encode into

our physics engine the laws of physics that say how position and movement and time

are connected. This is the subject of chapter 3.