A three dimensional vector unit whose elements are stored as floats.
||Creates a |
||The x value of the vector.|
||The y value of the vector.|
||The z value of the vector.|
|Return Type||Function Name||Parameters||Description|
||Gets the value at the given index. (Indices 0, 1, and 2 are equal to x, y, and z, respectively.)|
||Length||Returns the length of this vector.|
||Normalize||Returns the normalization factor for this vector. (See Remarks.)|
||Sets the value at the given index to the given value. (Indices 0, 1, and 2 are equal to x, y, and z, respectively.)|
||SqrLength||Returns the length-squared of this vector.|
A normalized vector is a vector whose length is equal to one, otherwise known as a unit vector. To convert a vector into a unit vector, get the normalization factor by calling the Normalize function, then divide each of the vector's x, y, and z coordinates by that factor.
cVector3f vBaseVector(2.0, 5.0, 3.0); float fNormFactor = vBaseVector.Normalize(); cVector3f vNormalizedVector(vBaseVector.x / fNormFactor, vBaseVector.y / fNormFactor, vBaseVector.z / fNormFactor);