Game Development Reference
F IGURE 2.4
The geometry of scalar-vector multiplication.
F IGURE 2.5
The geometry of vector addition.
In code it is very easy to add vectors together or subtract them. For two vectors a
and b , their sum is given by
a x +
a y +
a z +
where a x , a y ,and a z are the x , y ,and z components of the vector a :wewillnormally
use this notation rather than x , y ,and z to avoid confusion when dealing with more
than one vector.
Vector addition is achieved by adding the components of the two vectors together.
This can be implemented for the + operator:
Excerpt from include/cyclone/core.h
// ... Other Vector3 code as before ...
/** Adds the given vector to this. */
void operator+=(const Vector3& v)