00001 #ifndef __Matrix__
00002 #define __Matrix__
00003
00004 #include <string>
00005
00006 using namespace std;
00007
00008
00009 class Vector;
00010 class Matrix;
00011
00012
00013
00015
00016
00017
00019
00020 class Vector {
00021 friend class Matrix;
00022 public:
00023 Vector();
00024 Vector(const float x, const float y, const float z, const float w = 1.0f);
00025 Vector(const Vector& other);
00026
00027 float getX() const;
00028 float getY() const;
00029 float getZ() const;
00030 float getW() const;
00031
00032 void setX(const float x);
00033 void setY(const float y);
00034 void setZ(const float z);
00035 void setW(const float w);
00036
00037 void setXYZW(const float x, const float y, const float z, const float w = 1.0f);
00038
00039 float getMagnitude() const;
00040 float getSquareMagnitude() const;
00041
00042 void normalize();
00043
00044 void mapToReal();
00045
00046 Vector& operator=(const Vector& other);
00047
00048 bool operator==(const Vector& other) const;
00049 bool operator!=(const Vector& other) const;
00050 bool operator< (const Vector& other) const;
00051 bool operator<=(const Vector& other) const;
00052 bool operator> (const Vector& other) const;
00053 bool operator>=(const Vector& other) const;
00054
00055 Vector& operator+=(const Vector& other);
00056 Vector& operator-=(const Vector& other);
00057 Vector& operator*=(const float scale);
00058 Vector& operator/=(const float scale);
00059
00060 const Vector operator+(const Vector& other) const;
00061 const Vector operator-(const Vector& other) const;
00062 const Vector operator*(const float scale) const;
00063 const Vector operator/(const float scale) const;
00064
00065 float dotProduct (const Vector& other) const;
00066 Vector crossProduct(const Vector& other) const;
00067
00068 Vector rotateAroundAxis(const Vector& axis, float theta) const;
00069 Vector rotateThetaPhi(const float Theta, const float Phi) const;
00070
00071 const Vector operator*(const Matrix& other) const;
00072
00073 string toString() const;
00074
00075 protected:
00076 float _x, _y, _z, _w;
00077 };
00078
00079
00080
00081
00082
00083
00085
00086
00087
00089
00090 class Matrix {
00091 friend class Vector;
00092 public:
00093
00094 Matrix();
00095 Matrix(const float* matrix);
00096 Matrix(const Matrix& other);
00097 Matrix(
00098 const float a0, const float a1, const float a2, const float a3,
00099 const float a4, const float a5, const float a6, const float a7,
00100 const float a8, const float a9, const float a10, const float a11,
00101 const float a12, const float a13, const float a14, const float a15
00102 );
00103
00104 float* getData();
00105
00106 float computeDeterminant() const;
00107 const Matrix computeInverse() const;
00108
00109 const Matrix operator*(const Matrix& other) const;
00110 const Vector operator*(const Vector& other) const;
00111
00112 string toString() const;
00113
00114 protected:
00115 float _data[16];
00116 };
00117
00118
00119 #endif