36 inline explicit Matrixf(
float const *
const ptr ) { set(ptr); }
37 inline explicit Matrixf(
double const *
const ptr ) { set(ptr); }
38 inline explicit Matrixf(
const Quat& quat ) { makeRotate(quat); }
40 Matrixf( 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 Matrixf& m)
const;
49 bool operator < (
const Matrixf& m)
const {
return compare(m)<0; }
50 bool operator == (
const Matrixf& m)
const {
return compare(m)==0; }
51 bool operator != (
const Matrixf& 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.0f && _mat[0][1]==0.0f && _mat[0][2]==0.0f && _mat[0][3]==0.0f &&
98 _mat[1][0]==0.0f && _mat[1][1]==1.0f && _mat[1][2]==0.0f && _mat[1][3]==0.0f &&
99 _mat[2][0]==0.0f && _mat[2][1]==0.0f && _mat[2][2]==1.0f && _mat[2][3]==0.0f &&
100 _mat[3][0]==0.0f && _mat[3][1]==0.0f && _mat[3][2]==0.0f && _mat[3][3]==1.0f;
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.0f && rhs.
_mat[1][3]==0.0f && rhs.
_mat[2][3]==0.0f && rhs.
_mat[3][3]==1.0f);
236 return is_4x3 ? invert_4x3(rhs) : invert_4x4(rhs);
240 bool invert_4x3(
const Matrixf& rhs);
243 bool invert_4x4(
const Matrixf& rhs);
246 void orthoNormalize(
const Matrixf& rhs);
249 inline static Matrixf identity(
void );
252 inline static Matrixf scale( value_type sx, value_type sy, value_type sz);
255 inline static Matrixf translate( value_type x, value_type y, value_type z);
258 inline static Matrixf rotate( value_type angle, value_type x, value_type y, value_type z);
259 inline static Matrixf rotate( value_type angle,
const Vec3f& axis);
260 inline static Matrixf rotate( value_type angle,
const Vec3d& axis);
261 inline static Matrixf rotate( value_type angle1,
const Vec3f& axis1,
262 value_type angle2,
const Vec3f& axis2,
263 value_type angle3,
const Vec3f& axis3);
264 inline static Matrixf rotate( value_type angle1,
const Vec3d& axis1,
265 value_type angle2,
const Vec3d& axis2,
266 value_type angle3,
const Vec3d& axis3);
274 inline static Matrixf ortho(
double left,
double right,
275 double bottom,
double top,
276 double zNear,
double zFar);
281 inline static Matrixf ortho2D(
double left,
double right,
282 double bottom,
double top);
287 inline static Matrixf frustum(
double left,
double right,
288 double bottom,
double top,
289 double zNear,
double zFar);
295 inline static Matrixf perspective(
double fovy,
double aspectRatio,
296 double zNear,
double zFar);
314 inline Vec3f postMult(
const Vec3f& v )
const;
315 inline Vec3d postMult(
const Vec3d& v )
const;
320 inline Vec4f postMult(
const Vec4f& v )
const;
321 inline Vec4d postMult(
const Vec4d& v )
const;
325 #ifdef USE_DEPRECATED_API
326 inline void set(
const Quat& q) { makeRotate(q); }
327 inline void get(Quat& q)
const { q = getRotate(); }
330 void setRotate(
const Quat& q);
335 Quat getRotate()
const;
338 void setTrans( value_type tx, value_type ty, value_type tz );
339 void setTrans(
const Vec3f& v );
340 void setTrans(
const Vec3d& v );
345 Vec3d x_vec(_mat[0][0],_mat[1][0],_mat[2][0]);
346 Vec3d y_vec(_mat[0][1],_mat[1][1],_mat[2][1]);
347 Vec3d z_vec(_mat[0][2],_mat[1][2],_mat[2][2]);
365 void preMult(
const Matrixf& );
366 void postMult(
const Matrixf& );
369 inline void preMultTranslate(
const Vec3d& v );
370 inline void preMultTranslate(
const Vec3f& v );
372 inline void postMultTranslate(
const Vec3d& v );
373 inline void postMultTranslate(
const Vec3f& v );
376 inline void preMultScale(
const Vec3d& v );
377 inline void preMultScale(
const Vec3f& v );
379 inline void postMultScale(
const Vec3d& v );
380 inline void postMultScale(
const Vec3f& v );
383 inline void preMultRotate(
const Quat& q );
385 inline void postMultRotate(
const Quat& q );
387 inline void operator *= (
const Matrixf& other )
388 {
if(
this == &other ) {
392 else postMult( other );
406 _mat[0][0]*rhs, _mat[0][1]*rhs, _mat[0][2]*rhs, _mat[0][3]*rhs,
407 _mat[1][0]*rhs, _mat[1][1]*rhs, _mat[1][2]*rhs, _mat[1][3]*rhs,
408 _mat[2][0]*rhs, _mat[2][1]*rhs, _mat[2][2]*rhs, _mat[2][3]*rhs,
409 _mat[3][0]*rhs, _mat[3][1]*rhs, _mat[3][2]*rhs, _mat[3][3]*rhs);
435 inline Matrixf operator / (value_type rhs)
const
438 _mat[0][0]/rhs, _mat[0][1]/rhs, _mat[0][2]/rhs, _mat[0][3]/rhs,
439 _mat[1][0]/rhs, _mat[1][1]/rhs, _mat[1][2]/rhs, _mat[1][3]/rhs,
440 _mat[2][0]/rhs, _mat[2][1]/rhs, _mat[2][2]/rhs, _mat[2][3]/rhs,
441 _mat[3][0]/rhs, _mat[3][1]/rhs, _mat[3][2]/rhs, _mat[3][3]/rhs);
470 _mat[0][0] + rhs.
_mat[0][0],
471 _mat[0][1] + rhs.
_mat[0][1],
472 _mat[0][2] + rhs.
_mat[0][2],
473 _mat[0][3] + rhs.
_mat[0][3],
474 _mat[1][0] + rhs.
_mat[1][0],
475 _mat[1][1] + rhs.
_mat[1][1],
476 _mat[1][2] + rhs.
_mat[1][2],
477 _mat[1][3] + rhs.
_mat[1][3],
478 _mat[2][0] + rhs.
_mat[2][0],
479 _mat[2][1] + rhs.
_mat[2][1],
480 _mat[2][2] + rhs.
_mat[2][2],
481 _mat[2][3] + rhs.
_mat[2][3],
482 _mat[3][0] + rhs.
_mat[3][0],
483 _mat[3][1] + rhs.
_mat[3][1],
484 _mat[3][2] + rhs.
_mat[3][2],
485 _mat[3][3] + rhs.
_mat[3][3]);
493 _mat[0][0] += rhs.
_mat[0][0];
494 _mat[0][1] += rhs.
_mat[0][1];
495 _mat[0][2] += rhs.
_mat[0][2];
496 _mat[0][3] += rhs.
_mat[0][3];
497 _mat[1][0] += rhs.
_mat[1][0];
498 _mat[1][1] += rhs.
_mat[1][1];
499 _mat[1][2] += rhs.
_mat[1][2];
500 _mat[1][3] += rhs.
_mat[1][3];
501 _mat[2][0] += rhs.
_mat[2][0];
502 _mat[2][1] += rhs.
_mat[2][1];
503 _mat[2][2] += rhs.
_mat[2][2];
504 _mat[2][3] += rhs.
_mat[2][3];
505 _mat[3][0] += rhs.
_mat[3][0];
506 _mat[3][1] += rhs.
_mat[3][1];
507 _mat[3][2] += rhs.
_mat[3][2];
508 _mat[3][3] += rhs.
_mat[3][3];
513 value_type _mat[4][4];
534 a30, a31, a32, a33) {}
540 virtual const char*
className()
const {
return "Matrix"; }
618 m.
makeRotate(angle1,axis1,angle2,axis2,angle3,axis3);
626 m.
makeRotate(angle1,axis1,angle2,axis2,angle3,axis3);
657 double bottom,
double top,
658 double zNear,
double zFar)
661 m.
makeOrtho(left,right,bottom,top,zNear,zFar);
666 double bottom,
double top)
674 double bottom,
double top,
675 double zNear,
double zFar)
683 double zNear,
double zFar)
791 for (
unsigned i = 0; i < 3; ++i)
797 _mat[3][1] += tmp*_mat[i][1];
798 _mat[3][2] += tmp*_mat[i][2];
799 _mat[3][3] += tmp*_mat[i][3];
805 for (
unsigned i = 0; i < 3; ++i)
811 _mat[3][1] += tmp*_mat[i][1];
812 _mat[3][2] += tmp*_mat[i][2];
813 _mat[3][3] += tmp*_mat[i][3];
819 for (
unsigned i = 0; i < 3; ++i)
825 _mat[1][i] += tmp*_mat[1][3];
826 _mat[2][i] += tmp*_mat[2][3];
827 _mat[3][i] += tmp*_mat[3][3];
833 for (
unsigned i = 0; i < 3; ++i)
839 _mat[1][i] += tmp*_mat[1][3];
840 _mat[2][i] += tmp*_mat[2][3];
841 _mat[3][i] += tmp*_mat[3][3];
847 _mat[0][0] *= v[0];
_mat[0][1] *= v[0];
_mat[0][2] *= v[0];
_mat[0][3] *= v[0];
848 _mat[1][0] *= v[1];
_mat[1][1] *= v[1];
_mat[1][2] *= v[1];
_mat[1][3] *= v[1];
849 _mat[2][0] *= v[2];
_mat[2][1] *= v[2];
_mat[2][2] *= v[2];
_mat[2][3] *= v[2];
854 _mat[0][0] *= v[0];
_mat[0][1] *= v[0];
_mat[0][2] *= v[0];
_mat[0][3] *= v[0];
855 _mat[1][0] *= v[1];
_mat[1][1] *= v[1];
_mat[1][2] *= v[1];
_mat[1][3] *= v[1];
856 _mat[2][0] *= v[2];
_mat[2][1] *= v[2];
_mat[2][2] *= v[2];
_mat[2][3] *= v[2];
861 _mat[0][0] *= v[0];
_mat[1][0] *= v[0];
_mat[2][0] *= v[0];
_mat[3][0] *= v[0];
862 _mat[0][1] *= v[1];
_mat[1][1] *= v[1];
_mat[2][1] *= v[1];
_mat[3][1] *= v[1];
863 _mat[0][2] *= v[2];
_mat[1][2] *= v[2];
_mat[2][2] *= v[2];
_mat[3][2] *= v[2];
868 _mat[0][0] *= v[0];
_mat[1][0] *= v[0];
_mat[2][0] *= v[0];
_mat[3][0] *= v[0];
869 _mat[0][1] *= v[1];
_mat[1][1] *= v[1];
_mat[2][1] *= v[1];
_mat[3][1] *= v[1];
870 _mat[0][2] *= v[2];
_mat[1][2] *= v[2];
_mat[2][2] *= v[2];
_mat[3][2] *= v[2];
virtual const char * className() const
bool zeroRotation() const
static Matrixf rotate(const Vec3f &from, const Vec3f &to)
void makeOrtho2D(double left, double right, double bottom, double top)
static Matrixf ortho2D(double left, double right, double bottom, double top)
void preMultTranslate(const Vec3d &v)
void makeTranslate(const Vec3f &)
void postMultTranslate(const Vec3d &v)
Vec3f postMult(const Vec3f &v) const
static Matrixf identity(void)
Vec3f operator*(const Vec3f &v) const
virtual Object * cloneType() const
static Vec3f transform3x3(const Vec3f &v, const Matrixf &m)
void postMultScale(const Vec3d &v)
RefMatrixf(const Matrixd &other)
void set(float const *const ptr)
RefMatrixf(const Matrixf &other)
bool invert(const Matrixf &rhs)
Matrixf(float const *const ptr)
void orthoNormalize(const Matrixf &rhs)
void set(const Matrixf &rhs)
void preMultScale(const Vec3d &v)
void makePerspective(double fovy, double aspectRatio, double zNear, double zFar)
static Matrixf scale(const Vec3f &sv)
value_type operator()(int row, int col) const
void makeFrustum(double left, double right, double bottom, double top, double zNear, double zFar)
void makeOrtho(double left, double right, double bottom, double top, double zNear, double zFar)
Matrixf(const Matrixf &mat)
Vec3f preMult(const Vec3f &v) const
static Matrixf translate(const Vec3f &dv)
static Matrixf frustum(double left, double right, double bottom, double top, double zNear, double zFar)
Matrixf(const Quat &quat)
const value_type * ptr() const
static Matrixf lookAt(const Vec3f &eye, const Vec3f ¢er, const Vec3f &up)
virtual const char * libraryName() const
void setRotate(const Quat &q)
Vec3f operator*(const Vec3f &v, const Matrixd &m)
virtual Object * clone(const CopyOp &) const
static Matrixf ortho(double left, double right, double bottom, double top, double zNear, double zFar)
RefMatrixf(const RefMatrixf &other)
void set(double const *const ptr)
void postMultRotate(const Quat &q)
Matrixf(double const *const ptr)
value_type length() const
virtual bool isSameKindAs(const Object *obj) const
RefMatrixf(Matrixf::value_type a00, Matrixf::value_type a01, Matrixf::value_type a02, Matrixf::value_type a03, Matrixf::value_type a10, Matrixf::value_type a11, Matrixf::value_type a12, Matrixf::value_type a13, Matrixf::value_type a20, Matrixf::value_type a21, Matrixf::value_type a22, Matrixf::value_type a23, Matrixf::value_type a30, Matrixf::value_type a31, Matrixf::value_type a32, Matrixf::value_type a33)
void makeLookAt(const Vec3d &eye, const Vec3d ¢er, const Vec3d &up)
void mult(const Matrixf &, const Matrixf &)
RefMatrixf(Matrixf::value_type const *const def)
void preMultRotate(const Quat &q)
static Matrixf orthoNormal(const Matrixf &matrix)
value_type & operator()(int row, int col)
static Matrixf perspective(double fovy, double aspectRatio, double zNear, double zFar)
void makeRotate(const Vec3f &from, const Vec3f &to)
void makeScale(const Vec3f &)
static Matrixf inverse(const Matrixf &matrix)