matrix4.hpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef _MATRIX4_HPP_
00020 #define _MATRIX4_HPP_
00021
00022 #include <iostream>
00023 #include <vector>
00024
00025 namespace cpe
00026 {
00027 class v4;
00028 class v3;
00029
00030 class matrix4
00031 {
00032
00033 public:
00034
00035
00036
00037
00038
00039
00040
00042 matrix4();
00044 matrix4(const double& x00,const double& x01,const double& x02,const double& x03,
00045 const double& x10,const double& x11,const double& x12,const double& x13,
00046 const double& x20,const double& x21,const double& x22,const double& x23,
00047 const double& x30,const double& x31,const double& x32,const double& x33);
00048
00049
00050
00051
00052
00053
00054
00056 static matrix4 identity();
00058 static matrix4 zeros();
00060 static matrix4 rotation(const v3& axis,const double& angle);
00062 static matrix4 scale(const double& s);
00064 static matrix4 scale(const double& s_x,const double& s_y,const double& s_z,const double& s_w);
00065
00066
00067
00068
00069
00070
00071
00072
00074 const double& operator()(const size_t& k1,const size_t& k2) const;
00076 double& operator()(const size_t& k1,const size_t& k2);
00077
00080 const double* pointer() const;
00083 double* pointer_unprotected();
00084
00085
00086
00087
00088
00089
00090
00091
00092
00094 friend matrix4 operator+(const matrix4& m1,const matrix4& m2);
00096 friend matrix4 operator+(const double& s,const matrix4& m);
00098 friend matrix4 operator+(const matrix4& m,const double& s);
00099
00101 friend matrix4 operator-(const matrix4& m1,const matrix4& m2);
00103 friend matrix4 operator-(const double& s,const matrix4& m);
00105 friend matrix4 operator-(const matrix4& m,const double& s);
00106
00108 friend matrix4 operator*(const double& s,const matrix4& m);
00110 friend matrix4 operator*(const matrix4& m,const double& s);
00112 friend v4 operator*(const matrix4& m,const v4& v);
00114 friend v4 operator*(const v4& v,const matrix4& m);
00116 friend matrix4 operator*(const matrix4& m1,const matrix4& m2);
00118 friend matrix4 operator/(const matrix4& m,const double& s);
00119
00120
00122 matrix4& operator+=(const matrix4& m);
00124 matrix4& operator+=(const double& s);
00126 matrix4& operator-=(const matrix4& m);
00128 matrix4& operator-=(const double& s);
00130 matrix4& operator*=(const double& s);
00132 matrix4& operator/=(const double& s);
00133
00135 matrix4 operator-() const;
00136
00140 matrix4 product_compontentwise(const matrix4& m) const;
00145 matrix4& product_compontentwise_internal(const matrix4& m);
00146
00148 double scalar_product(const v4& a,const v4& b) const;
00149
00151 matrix4 transposed() const;
00152
00153
00154
00155
00156
00157
00158
00159
00161 friend std::ostream& operator<<(std::ostream& stream,const matrix4& m);
00162
00163
00164
00165
00166
00167 private:
00168
00169
00170
00171
00172
00173
00174
00176 double m[16];
00177
00178
00179
00180
00181
00182
00183
00184
00186 void assert_size(const size_t& k1,const size_t& k2) const throw(std::exception);
00187
00188 };
00189 }
00190
00191 #endif