36 inline explicit Matrixd(
float const *
const ptr ) { set(ptr); }
37 inline explicit Matrixd(
double const *
const ptr ) { set(ptr); }
38 inline explicit Matrixd(
const Quat& quat ) { makeRotate(quat); }
40 Matrixd(value_type a00, value_type a01, value_type a02, value_type a03,
41 value_type a10, value_type a11, value_type a12, value_type a13,
42 value_type a20, value_type a21, value_type a22, value_type a23,
43 value_type a30, value_type a31, value_type a32, value_type a33);
47 int compare(
const Matrixd& m)
const;
49 bool operator < (
const Matrixd& m)
const {
return compare(m)<0; }
50 bool operator == (
const Matrixd& m)
const {
return compare(m)==0; }
51 bool operator != (
const Matrixd& m)
const {
return compare(m)!=0; }
53 inline value_type&
operator()(
int row,
int col) {
return _mat[row][col]; }
54 inline value_type
operator()(
int row,
int col)
const {
return _mat[row][col]; }
64 if( &rhs ==
this )
return *
this;
75 inline void set(
float const *
const ptr)
77 value_type* local_ptr = (value_type*)_mat;
78 for(
int i=0;i<16;++i) local_ptr[i]=(value_type)ptr[i];
81 inline void set(
double const *
const ptr)
83 value_type* local_ptr = (value_type*)_mat;
84 for(
int i=0;i<16;++i) local_ptr[i]=(value_type)ptr[i];
87 void set(value_type a00, value_type a01, value_type a02,value_type a03,
88 value_type a10, value_type a11, value_type a12,value_type a13,
89 value_type a20, value_type a21, value_type a22,value_type a23,
90 value_type a30, value_type a31, value_type a32,value_type a33);
92 value_type *
ptr() {
return (value_type*)_mat; }
93 const value_type *
ptr()
const {
return (
const value_type *)_mat; }
97 return _mat[0][0]==1.0 && _mat[0][1]==0.0 && _mat[0][2]==0.0 && _mat[0][3]==0.0 &&
98 _mat[1][0]==0.0 && _mat[1][1]==1.0 && _mat[1][2]==0.0 && _mat[1][3]==0.0 &&
99 _mat[2][0]==0.0 && _mat[2][1]==0.0 && _mat[2][2]==1.0 && _mat[2][3]==0.0 &&
100 _mat[3][0]==0.0 && _mat[3][1]==0.0 && _mat[3][2]==0.0 && _mat[3][3]==1.0;
105 void makeScale(
const Vec3f& );
106 void makeScale(
const Vec3d& );
107 void makeScale( value_type, value_type, value_type );
109 void makeTranslate(
const Vec3f& );
110 void makeTranslate(
const Vec3d& );
111 void makeTranslate( value_type, value_type, value_type );
113 void makeRotate(
const Vec3f& from,
const Vec3f& to );
114 void makeRotate(
const Vec3d& from,
const Vec3d& to );
115 void makeRotate( value_type angle,
const Vec3f& axis );
116 void makeRotate( value_type angle,
const Vec3d& axis );
117 void makeRotate( value_type angle, value_type x, value_type y, value_type z );
118 void makeRotate(
const Quat& );
119 void makeRotate( value_type angle1,
const Vec3f& axis1,
120 value_type angle2,
const Vec3f& axis2,
121 value_type angle3,
const Vec3f& axis3);
122 void makeRotate( value_type angle1,
const Vec3d& axis1,
123 value_type angle2,
const Vec3d& axis2,
124 value_type angle3,
const Vec3d& axis3);
143 void makeOrtho(
double left,
double right,
144 double bottom,
double top,
145 double zNear,
double zFar);
151 bool getOrtho(
double& left,
double& right,
152 double& bottom,
double& top,
153 double& zNear,
double& zFar)
const;
156 bool getOrtho(
float& left,
float& right,
157 float& bottom,
float& top,
158 float& zNear,
float& zFar)
const;
165 double bottom,
double top)
167 makeOrtho(left,right,bottom,top,-1.0,1.0);
174 void makeFrustum(
double left,
double right,
175 double bottom,
double top,
176 double zNear,
double zFar);
182 bool getFrustum(
double& left,
double& right,
183 double& bottom,
double& top,
184 double& zNear,
double& zFar)
const;
187 bool getFrustum(
float& left,
float& right,
188 float& bottom,
float& top,
189 float& zNear,
float& zFar)
const;
195 void makePerspective(
double fovy,
double aspectRatio,
196 double zNear,
double zFar);
208 bool getPerspective(
double& fovy,
double& aspectRatio,
209 double& zNear,
double& zFar)
const;
212 bool getPerspective(
float& fovy,
float& aspectRatio,
213 float& zNear,
float& zFar)
const;
224 value_type lookDistance=1.0f)
const;
230 value_type lookDistance=1.0f)
const;
235 bool is_4x3 = (rhs.
_mat[0][3]==0.0 && rhs.
_mat[1][3]==0.0 && rhs.
_mat[2][3]==0.0 && rhs.
_mat[3][3]==1.0);
236 return is_4x3 ? invert_4x3(rhs) : invert_4x4(rhs);
240 bool invert_4x3(
const Matrixd& rhs);
243 bool invert_4x4(
const Matrixd& rhs);
246 void orthoNormalize(
const Matrixd& rhs);
249 inline static Matrixd identity(
void );
252 inline static Matrixd scale( value_type sx, value_type sy, value_type sz);
255 inline static Matrixd translate( value_type x, value_type y, value_type z);
258 inline static Matrixd rotate( value_type angle, value_type x, value_type y, value_type z);
259 inline static Matrixd rotate( value_type angle,
const Vec3f& axis);
260 inline static Matrixd rotate( value_type angle,
const Vec3d& axis);
261 inline static Matrixd rotate( value_type angle1,
const Vec3f& axis1,
262 value_type angle2,
const Vec3f& axis2,
263 value_type angle3,
const Vec3f& axis3);
264 inline static Matrixd rotate( value_type angle1,
const Vec3d& axis1,
265 value_type angle2,
const Vec3d& axis2,
266 value_type angle3,
const Vec3d& axis3);
273 inline static Matrixd ortho(
double left,
double right,
274 double bottom,
double top,
275 double zNear,
double zFar);
280 inline static Matrixd ortho2D(
double left,
double right,
281 double bottom,
double top);
286 inline static Matrixd frustum(
double left,
double right,
287 double bottom,
double top,
288 double zNear,
double zFar);
294 inline static Matrixd perspective(
double fovy,
double aspectRatio,
295 double zNear,
double zFar);
313 inline Vec3f postMult(
const Vec3f& v )
const;
314 inline Vec3d postMult(
const Vec3d& v )
const;
319 inline Vec4f postMult(
const Vec4f& v )
const;
320 inline Vec4d postMult(
const Vec4d& v )
const;
324 #ifdef USE_DEPRECATED_API
325 inline void set(
const Quat& q) { makeRotate(q); }
326 inline void get(Quat& q)
const { q = getRotate(); }
329 void setRotate(
const Quat& q);
334 Quat getRotate()
const;
336 void setTrans( value_type tx, value_type ty, value_type tz );
337 void setTrans(
const Vec3f& v );
338 void setTrans(
const Vec3d& v );
343 Vec3d x_vec(_mat[0][0],_mat[1][0],_mat[2][0]);
344 Vec3d y_vec(_mat[0][1],_mat[1][1],_mat[2][1]);
345 Vec3d z_vec(_mat[0][2],_mat[1][2],_mat[2][2]);
363 void preMult(
const Matrixd& );
364 void postMult(
const Matrixd& );
367 inline void preMultTranslate(
const Vec3d& v );
368 inline void preMultTranslate(
const Vec3f& v );
370 inline void postMultTranslate(
const Vec3d& v );
371 inline void postMultTranslate(
const Vec3f& v );
374 inline void preMultScale(
const Vec3d& v );
375 inline void preMultScale(
const Vec3f& v );
377 inline void postMultScale(
const Vec3d& v );
378 inline void postMultScale(
const Vec3f& v );
381 inline void preMultRotate(
const Quat& q );
383 inline void postMultRotate(
const Quat& q );
385 inline void operator *= (
const Matrixd& other )
386 {
if(
this == &other ) {
390 else postMult( other );
401 value_type _mat[4][4];
422 a30, a31, a32, a33) {}
428 virtual const char*
className()
const {
return "Matrix"; }
506 m.
makeRotate(angle1,axis1,angle2,axis2,angle3,axis3);
514 m.
makeRotate(angle1,axis1,angle2,axis2,angle3,axis3);
545 double bottom,
double top,
546 double zNear,
double zFar)
549 m.
makeOrtho(left,right,bottom,top,zNear,zFar);
554 double bottom,
double top)
562 double bottom,
double top,
563 double zNear,
double zFar)
571 double zNear,
double zFar)
687 for (
unsigned i = 0; i < 3; ++i)
693 _mat[3][1] += tmp*_mat[i][1];
694 _mat[3][2] += tmp*_mat[i][2];
695 _mat[3][3] += tmp*_mat[i][3];
701 for (
unsigned i = 0; i < 3; ++i)
707 _mat[3][1] += tmp*_mat[i][1];
708 _mat[3][2] += tmp*_mat[i][2];
709 _mat[3][3] += tmp*_mat[i][3];
715 for (
unsigned i = 0; i < 3; ++i)
721 _mat[1][i] += tmp*_mat[1][3];
722 _mat[2][i] += tmp*_mat[2][3];
723 _mat[3][i] += tmp*_mat[3][3];
729 for (
unsigned i = 0; i < 3; ++i)
735 _mat[1][i] += tmp*_mat[1][3];
736 _mat[2][i] += tmp*_mat[2][3];
737 _mat[3][i] += tmp*_mat[3][3];
743 _mat[0][0] *= v[0];
_mat[0][1] *= v[0];
_mat[0][2] *= v[0];
_mat[0][3] *= v[0];
744 _mat[1][0] *= v[1];
_mat[1][1] *= v[1];
_mat[1][2] *= v[1];
_mat[1][3] *= v[1];
745 _mat[2][0] *= v[2];
_mat[2][1] *= v[2];
_mat[2][2] *= v[2];
_mat[2][3] *= v[2];
750 _mat[0][0] *= v[0];
_mat[0][1] *= v[0];
_mat[0][2] *= v[0];
_mat[0][3] *= v[0];
751 _mat[1][0] *= v[1];
_mat[1][1] *= v[1];
_mat[1][2] *= v[1];
_mat[1][3] *= v[1];
752 _mat[2][0] *= v[2];
_mat[2][1] *= v[2];
_mat[2][2] *= v[2];
_mat[2][3] *= v[2];
757 _mat[0][0] *= v[0];
_mat[1][0] *= v[0];
_mat[2][0] *= v[0];
_mat[3][0] *= v[0];
758 _mat[0][1] *= v[1];
_mat[1][1] *= v[1];
_mat[2][1] *= v[1];
_mat[3][1] *= v[1];
759 _mat[0][2] *= v[2];
_mat[1][2] *= v[2];
_mat[2][2] *= v[2];
_mat[3][2] *= v[2];
764 _mat[0][0] *= v[0];
_mat[1][0] *= v[0];
_mat[2][0] *= v[0];
_mat[3][0] *= v[0];
765 _mat[0][1] *= v[1];
_mat[1][1] *= v[1];
_mat[2][1] *= v[1];
_mat[3][1] *= v[1];
766 _mat[0][2] *= v[2];
_mat[1][2] *= v[2];
_mat[2][2] *= v[2];
_mat[3][2] *= v[2];
static Matrixd perspective(double fovy, double aspectRatio, double zNear, double zFar)
void postMultScale(const Vec3d &v)
bool zeroRotation() const
Vec3f postMult(const Vec3f &v) const
const value_type * ptr() const
void makeFrustum(double left, double right, double bottom, double top, double zNear, double zFar)
static Matrixd translate(const Vec3f &dv)
RefMatrixd(const Matrixd &other)
Vec3f operator*(const Vec3f &v) const
RefMatrixd(const RefMatrixd &other)
static Matrixd identity(void)
virtual const char * libraryName() const
static Matrixd orthoNormal(const Matrixd &matrix)
virtual const char * className() const
static Vec3f transform3x3(const Vec3f &v, const Matrixd &m)
RefMatrixd(const Matrixf &other)
void makePerspective(double fovy, double aspectRatio, double zNear, double zFar)
void makeScale(const Vec3f &)
static Matrixd rotate(const Vec3f &from, const Vec3f &to)
void orthoNormalize(const Matrixd &rhs)
void set(float const *const ptr)
void set(double const *const ptr)
static Matrixd ortho(double left, double right, double bottom, double top, double zNear, double zFar)
RefMatrixd(Matrixd::value_type const *const def)
Matrixd(double const *const ptr)
static Matrixd inverse(const Matrixd &matrix)
virtual bool isSameKindAs(const Object *obj) const
Matrixd(const Matrixd &mat)
Vec3f preMult(const Vec3f &v) const
static Matrixd ortho2D(double left, double right, double bottom, double top)
value_type operator()(int row, int col) const
void postMultTranslate(const Vec3d &v)
Matrixd(float const *const ptr)
Vec3f operator*(const Vec3f &v, const Matrixd &m)
void preMultTranslate(const Vec3d &v)
static Matrixd scale(const Vec3f &sv)
virtual Object * cloneType() const
bool invert(const Matrixd &rhs)
void makeOrtho(double left, double right, double bottom, double top, double zNear, double zFar)
void preMultRotate(const Quat &q)
void set(const Matrixd &rhs)
void mult(const Matrixd &, const Matrixd &)
value_type & operator()(int row, int col)
void makeRotate(const Vec3f &from, const Vec3f &to)
value_type length() const
RefMatrixd(Matrixd::value_type a00, Matrixd::value_type a01, Matrixd::value_type a02, Matrixd::value_type a03, Matrixd::value_type a10, Matrixd::value_type a11, Matrixd::value_type a12, Matrixd::value_type a13, Matrixd::value_type a20, Matrixd::value_type a21, Matrixd::value_type a22, Matrixd::value_type a23, Matrixd::value_type a30, Matrixd::value_type a31, Matrixd::value_type a32, Matrixd::value_type a33)
void makeLookAt(const Vec3d &eye, const Vec3d ¢er, const Vec3d &up)
void preMultScale(const Vec3d &v)
void setRotate(const Quat &q)
void postMultRotate(const Quat &q)
void makeTranslate(const Vec3f &)
virtual Object * clone(const CopyOp &) const
void makeOrtho2D(double left, double right, double bottom, double top)
Matrixd(const Quat &quat)
static Matrixd frustum(double left, double right, double bottom, double top, double zNear, double zFar)
static Matrixd lookAt(const Vec3f &eye, const Vec3f ¢er, const Vec3f &up)