Matrix3.h
00001 #ifndef _MATRIX3_H_
00002 #define _MATRIX3_H_
00003
00004 #include "Vector3.h"
00005
00006 class Matrix3 {
00007
00008 Vector3 _v[3];
00009
00010 public:
00011
00012 Matrix3();
00013 Matrix3(const Vector3 &v0,const Vector3 &v1,const Vector3 &v2);
00014 Matrix3(const float &x00, const float &x01, const float &x02,
00015 const float &x10, const float &x11, const float &x12,
00016 const float &x20, const float &x21, const float &x22);
00017
00018 Matrix3 & zero();
00019 Vector3 &operator[](int n);
00020 const Vector3 &operator[](int n) const;
00021
00022 void setOne(const int c, const Vector3 &v);
00023 void setOne(const int c, const float v1, const float v2, const float v3);
00024 void setAll(const Vector3 &v1, const Vector3 &v2, const Vector3 &v3);
00025 void setAll(const Vector3 *v);
00026 Vector3 getOne(const int c);
00027 void getAll(Vector3 &v1, Vector3 &v2, Vector3 &v3);
00028
00029 Matrix3 & id();
00030 Matrix3 & transpose();
00031 float det();
00032 Matrix3 & inv();
00033 Matrix3& outer(const Vector3 &a, const Vector3 &b);
00034 Matrix3& vecCross(const Vector3 &v);
00035 Matrix3& cay(const Vector3 &v);
00036 Matrix3& rotAround(const Vector3 &v, float angle);
00037
00038 Matrix3 operator*(const Matrix3 &m);
00039 Vector3 operator*(const Vector3 &v);
00040 friend Matrix3 operator*(const Matrix3 &m, float d);
00041 friend Matrix3 operator*(float d, const Matrix3 &m);
00042 friend Matrix3 operator/(const Matrix3 &m, float d);
00043
00044 Matrix3 operator+(const Matrix3 &m) const;
00045 Matrix3 operator-(const Matrix3 &m) const;
00046 Matrix3 operator-() const;
00047
00048 Matrix3& operator=(const Matrix3 &m);
00049 Matrix3& operator+=(const Matrix3 &m);
00050 Matrix3& operator-=(const Matrix3 &m);
00051 Matrix3& operator*=(const float s);
00052 Matrix3& operator/=(const float s);
00053
00054 int operator==(const Matrix3 &m) const;
00055 int operator!=(const Matrix3 &m) const;
00056
00057 void print(ostream &out) const;
00058 friend ostream& operator << (ostream &out, const Matrix3 &m);
00059
00060 };
00061
00062 inline Vector3 &Matrix3::operator[](int n) {
00063 return _v[n];
00064 }
00065
00066 inline const Vector3 &Matrix3::operator[](int n) const {
00067 return _v[n];
00068 }
00069
00070 inline ostream & operator << (ostream &out, const Matrix3 &m) {
00071 m.print(out);
00072 return out;
00073 }
00074
00075 #endif // _MATRIX3_H_