Class MHVector



A vector represents a magnitude and a direction. It has three components x, y and z. The vector can be visualized as a line segment that starts at (0, 0, 0) and ends at (x, y, z). The line length is the magnitude.

Member Functions

Member Variables


MHVector(void)

Default constructor, creates an vector with x, y and z set to zero.


MHVector(MHFloat newX, MHFloat newY, MHFloat newZ)

Constructor, sets x, y and z to the provided values.


MHVector(const MHVector &source)

Copy constructor, creates an MHVector that's a copy of source.


MHVector crossProduct(const MHVector &vectorTwo)

Returns the cross product between this vector and vectorTwo.


void fromQuaternion(const Quaternion &source)

Before calling fromQuaternion, this vector should have one or more of x, y or z non-zero. We create a Point3D at (x, y, z) and rotate it by source. The resulting position is stored as the new vector. If only one of x, y or z is non-zero, we're essentially taking a forward direction and causing it to point towards the direction given by the quaternion.


MHVector normalize(void)

Returns a vector with the same direction as this one, but with a length of 1.


MHFloat x

MHFloat y

MHFloat z

The elements that make up the vector.











Back to Contents