Game Development Reference
In-Depth Information
{
x += v.x;
y += v.y;
z += v.z;
}
/**
* Returns the value of the given vector added to this.
*/
Vector3 operator+(const Vector3& v) const
{
return Vector3(x+v.x, y+v.y, z+v.z);
}
};
In the same way vector subtraction is also performed by subtracting the compo-
nents of each vector:
=
a x
a y
a z
b x
b y
b z
a x
b x
a
b
=
a y
b y
a z
b z
which is implemented in the same way as addition:
Excerpt from include/cyclone/core.h
class Vector3
{
// ... Other Vector3 code as before ...
/** Subtracts the given vector from this. */
void operator-=(const Vector3& v)
{
x -= v.x;
y -= v.y;
z -= v.z;
}
/**
* Returns the value of the given vector subtracted from this.
*/
Vector3 operator-(const Vector3& v) const
{
return Vector3(x-v.x, y-v.y, z-v.z);
Search Nedrilad ::




Custom Search