-1, if the length of this vector is less than \a length. */ int CompareLength(ufix length) const; /** Compare the length of this vector with another. This is faster than comparing two values returned by Length(). E.g. instead of @code if(vector1.Length()

-1, if the length of this is less than the length of \a vector. */ int CompareLengths(const Vector3& vector) const; /** Calculate the square of the length of this vector. This is faster than Length() and is useful when comparing a vector length with a constant or pre-calculated value. (Comparing the square of lengths will give the same result as comparing the lengths.) @param fraction Set to the fraction part of the result, i.e the 32 bits to the right of the binary point. @return The integer part of the result. */ uint32_t LengthSquared(uint32_t& fraction) const; /** Calculate the unit vector which lies in the same direction as this vector. I.e. scale this vector so it has a length of 1.0. Rounding inacuracies mean the length of this 'unit' vector will actualy lie in the range 0x0.fffe to 0x1.0000. @return The unit vector. */ Vector3 UnitVector() const; /** Calculate the unit vector which is normal to this vector and a second vector. I.e. the unit vector which is at right angles to both this vector and the second vector; acording to the right-hand rule. Rounding inacuracies mean the length of this 'unit' vector will actualy lie in the range 0x0.fffe to 0x1.0000. @param vector The second vector. @return The unit vector normal to this and \a vector. */ Vector3 Normal(const Vector3& vector) const; /** Calculate the angle between this vector and a second vector. @param vector The second vector. @return The angle between this and \a vector. This lies in the range 0x0000 and 0x8000. @see fixangle */ fixangle Angle(const Vector3& vector) const; /** Calculate the unit vector which is normal to the two vectors formed by (\a point1 - this) and (\a point2 - this). I.e. the unit vector which is at right angles to both of these; acording to the right-hand rule. Rounding inacuracies mean the length of this 'unit' vector will actualy lie in the range 0x0.fffe to 0x1.0000. @param point1 The first point. @param point2 The second point. @return The normal vector. */ Vector3 Normal(const Vector3& point1,const Vector3& point2) const; /** Calculate the angle between the two vectors formed by (\a point1 - this) and (\a point2 - this). @param point1 The first point. @param point2 The second point. @return The angle. This lies in the range 0x0000 and 0x8000. @see fixangle */ fixangle Angle(const Vector3& point1,const Vector3& point2) const; /** Translate an array of vectors. I.e. add the given offset to each vector in an array. @param outVectors Pointer to array where translated vectors will be written to. @param vectorCount Number of vectors in array. @param inVectors Pointer to array vectors to be translated. @param offset The offset to add to each vector in the array. */ static void Translate(Vector3* outVectors,unsigned vectorCount,const Vector3* inVectors,const Vector3& offset); /** Scale an array of vectors. I.e. perform a scalar multiply on each vector in an array. @param outVectors Pointer to array where scaled vectors will be written to. @param vectorCount Number of vectors in array. @param inVectors Pointer to array vectors to be scaled. @param scale The value to scale each component of each vector by. */ static void Scale(Vector3* outVectors,unsigned vectorCount,const Vector3* inVectors,fix scale); private: /** Scale the components of this array such that the component with the largest magnitude has its most-significant bit at the given position. @param bits Bit position for MSB of largest component. */ void NormaliseComponents(unsigned bits); public: fix X; /**< The X component */ fix Y; /**< The Y component */ fix Z; /**< The Z component */ }; /** @brief A type representing a 3D point */ typedef Vector3 Point3; /** @brief A class representing a 3x3 matrix. */ class Matrix3 { public: /** Constructor which doesn't initialise the matrix object */ inline Matrix3() {} /** Constructor which initialises the matrix object using three 3vectors @param row1 Values for first row in matrix. @param row2 Values for second row in matrix. @param row3 Values for third row in matrix. */ inline Matrix3(const Vector3 row1,const Vector3 row2,const Vector3 row3) : Row1(row1), Row2(row2), Row3(row3) {} /** Multiply this matrix by a 3vector. @param vector The vector to multiply by. This is treated as a column vector. @return Result of mutiplying this matrix by \a vector */ Vector3 operator * (const Vector3& vector) const; /** Transpose a matrix. (Exchange rows with columns.) @return The transposition of this matrix. */ Matrix3 Transposition() const; /** Tranform an array of vectors by multiplying each against this matrix, acording to the operator*() function. @param outVectors Pointer to array where transformed vectors will be written to. @param vectorCount Number of vectors in array. @param inVectors Pointer to array vectors to be transformed. */ void Transform(Vector3* outVectors,unsigned vectorCount,const Vector3* inVectors); public: Vector3 Row1; /**< The elements for row 1 of the matrix */ Vector3 Row2; /**< The elements for row 2 of the matrix */ Vector3 Row3; /**< The elements for row 3 of the matrix */ }; /** @} */ // End of group #endif