Game Development Reference
In-Depth Information
Figure A-3. Vector reversal
Vector Addition: The += Operator
This summation operator is used for vector addition, whereby the passed vector is added
to the current vector, component by component. Graphically, vectors are added in tip-
to-tail fashion, as illustrated in Figure A-4 .
Figure A-4. Vector addition
Here's the code that adds the vector u to our Vector class vector:
inline Vector& Vector::operator+=(Vector u)
{
x += u.x;
y += u.y;
z += u.z;
return *this;
}
 
Search Nedrilad ::




Custom Search