Game Development Reference
In-Depth Information
Vector& operator/=(float s);
Vector operator-(void);
};
// Constructor
inline Vector::Vector(void)
{
x = 0;
y = 0;
z = 0;
}
// Constructor
inline Vector::Vector(float xi, float yi, float zi)
{
x = xi;
y = yi;
z = zi;
}
Magnitude
The Magnitude method simply calculates the scalar magnitude of the vector according
to the formula:
| v | = x 2 + y 2 + z 2
This is for a zero-based vector where the components are specified relative to the origin.
The magnitude of a vector is equal to its length, as illustrated in Figure A-1 .
Figure A-1. Vector length (magnitude)
 
Search Nedrilad ::




Custom Search