mirror of
https://github.com/ENSL/NS.git
synced 2024-11-24 05:21:16 +00:00
5dcc163bd5
git-svn-id: https://unknownworlds.svn.cloudforge.com/ns1@379 67975925-1194-0748-b3d5-c16f83f1a3a1
47 lines
818 B
C++
47 lines
818 B
C++
#ifndef UTIL_MAT3_H
|
|
#define UTIL_MAT3_H
|
|
|
|
/**
|
|
* 3x3 Matrix class.
|
|
*/
|
|
class Mat3
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
|
* Elements are uninitialized.
|
|
*/
|
|
Mat3();
|
|
|
|
/**
|
|
* Converts from Euler angles to a rotation matrix.
|
|
*/
|
|
Mat3(const float angles[3]);
|
|
|
|
float& operator()(int r, int c);
|
|
float operator()(int r, int c) const;
|
|
|
|
/**
|
|
* Extracts Euler angles from the matrix.
|
|
*/
|
|
void GetEulerAngles(float angles[3]) const;
|
|
void SetEulerAngles(const float angles[3]);
|
|
void TransformVector(float vector[3]) const;
|
|
|
|
/**
|
|
* If the columns of the matrix are orthonormal (as is the case with a
|
|
* rotation matrix), then the transpose is also the inverse.
|
|
*/
|
|
Mat3 Transpose() const;
|
|
|
|
private:
|
|
|
|
float element[3][3];
|
|
|
|
};
|
|
|
|
Mat3 operator*(const Mat3& m1, const Mat3& m2);
|
|
|
|
#endif
|
|
|