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