Game Development Reference
In-Depth Information
const vector4 vector4::operator + (const vector4 &rhs) const
{
vector4 r;
r.x() = x() + rhs.x();
r.y() = y() + rhs.y();
r.z() = z() + rhs.z();
r.w() = w() + rhs.w();
return r;
}
vector4 &vector4::operator += (const vector4 &rhs)
{
x() += rhs.x();
y() += rhs.y();
z() += rhs.z();
w() += rhs.w();
return *this;
}
1.2.1.2Vector Subtraction
Just as addition, subtraction is the straightforward operation of subtracting each of the vec-
tor's components.
Vector subtraction is an operation we will find often when working in games, it allows us
to calculate a vector between the end points of two other vectors.
Figure 4 - Vector subtraction
This means that if we have two vectors u, v in space representing two points in space,
by performing a vector subtraction of u - v we get the vector between these two points.
Search WWH ::




Custom Search