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); }
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; }
64 if( &rhs ==
this )
return *
this;
75 inline void set(
float const *
const ptr)
78 for(
int i=0;i<16;++i) local_ptr[i]=(
value_type)ptr[i];
81 inline void set(
double const *
const ptr)
84 for(
int i=0;i<16;++i) local_ptr[i]=(
value_type)ptr[i];
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;
144 double bottom,
double top,
145 double zNear,
double zFar);
152 double& bottom,
double& top,
153 double& zNear,
double& zFar)
const;
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);
175 double bottom,
double top,
176 double zNear,
double zFar);
183 double& bottom,
double& top,
184 double& zNear,
double& zFar)
const;
188 float& bottom,
float& top,
189 float& zNear,
float& zFar)
const;
196 double zNear,
double zFar);
209 double& zNear,
double& zFar)
const;
213 float& zNear,
float& zFar)
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);
255 inline static Matrixf identity(
void );
280 inline static Matrixf ortho(
double left,
double right,
281 double bottom,
double top,
282 double zNear,
double zFar);
287 inline static Matrixf ortho2D(
double left,
double right,
288 double bottom,
double top);
293 inline static Matrixf frustum(
double left,
double right,
294 double bottom,
double top,
295 double zNear,
double zFar);
301 inline static Matrixf perspective(
double fovy,
double aspectRatio,
302 double zNear,
double zFar);
320 inline Vec3f postMult(
const Vec3f& v )
const;
321 inline Vec3d postMult(
const Vec3d& v )
const;
322 inline Vec3f operator* (
const Vec3f& v )
const;
323 inline Vec3d operator* (
const Vec3d& v )
const;
326 inline Vec4f postMult(
const Vec4f& v )
const;
327 inline Vec4d postMult(
const Vec4d& v )
const;
328 inline Vec4f operator* (
const Vec4f& v )
const;
329 inline Vec4d operator* (
const Vec4d& v )
const;
331#ifdef OSG_USE_DEPRECATED_API
332 inline void set(
const Quat& q) { makeRotate(q); }
333 inline void get(
Quat& q)
const { q = getRotate(); }
351 Vec3d x_vec(_mat[0][0],_mat[1][0],_mat[2][0]);
352 Vec3d y_vec(_mat[0][1],_mat[1][1],_mat[2][1]);
353 Vec3d z_vec(_mat[0][2],_mat[1][2],_mat[2][2]);
375 inline void preMultTranslate(
const Vec3d& v );
376 inline void preMultTranslate(
const Vec3f& v );
378 inline void postMultTranslate(
const Vec3d& v );
379 inline void postMultTranslate(
const Vec3f& v );
382 inline void preMultScale(
const Vec3d& v );
383 inline void preMultScale(
const Vec3f& v );
385 inline void postMultScale(
const Vec3d& v );
386 inline void postMultScale(
const Vec3f& v );
389 inline void preMultRotate(
const Quat& q );
391 inline void postMultRotate(
const Quat& q );
393 inline void operator *= (
const Matrixf& other )
394 {
if(
this == &other ) {
398 else postMult( other );
412 _mat[0][0]*rhs, _mat[0][1]*rhs, _mat[0][2]*rhs, _mat[0][3]*rhs,
413 _mat[1][0]*rhs, _mat[1][1]*rhs, _mat[1][2]*rhs, _mat[1][3]*rhs,
414 _mat[2][0]*rhs, _mat[2][1]*rhs, _mat[2][2]*rhs, _mat[2][3]*rhs,
415 _mat[3][0]*rhs, _mat[3][1]*rhs, _mat[3][2]*rhs, _mat[3][3]*rhs);
444 _mat[0][0]/rhs, _mat[0][1]/rhs, _mat[0][2]/rhs, _mat[0][3]/rhs,
445 _mat[1][0]/rhs, _mat[1][1]/rhs, _mat[1][2]/rhs, _mat[1][3]/rhs,
446 _mat[2][0]/rhs, _mat[2][1]/rhs, _mat[2][2]/rhs, _mat[2][3]/rhs,
447 _mat[3][0]/rhs, _mat[3][1]/rhs, _mat[3][2]/rhs, _mat[3][3]/rhs);
476 _mat[0][0] + rhs.
_mat[0][0],
477 _mat[0][1] + rhs.
_mat[0][1],
478 _mat[0][2] + rhs.
_mat[0][2],
479 _mat[0][3] + rhs.
_mat[0][3],
480 _mat[1][0] + rhs.
_mat[1][0],
481 _mat[1][1] + rhs.
_mat[1][1],
482 _mat[1][2] + rhs.
_mat[1][2],
483 _mat[1][3] + rhs.
_mat[1][3],
484 _mat[2][0] + rhs.
_mat[2][0],
485 _mat[2][1] + rhs.
_mat[2][1],
486 _mat[2][2] + rhs.
_mat[2][2],
487 _mat[2][3] + rhs.
_mat[2][3],
488 _mat[3][0] + rhs.
_mat[3][0],
489 _mat[3][1] + rhs.
_mat[3][1],
490 _mat[3][2] + rhs.
_mat[3][2],
491 _mat[3][3] + rhs.
_mat[3][3]);
499 _mat[0][0] += rhs.
_mat[0][0];
500 _mat[0][1] += rhs.
_mat[0][1];
501 _mat[0][2] += rhs.
_mat[0][2];
502 _mat[0][3] += rhs.
_mat[0][3];
503 _mat[1][0] += rhs.
_mat[1][0];
504 _mat[1][1] += rhs.
_mat[1][1];
505 _mat[1][2] += rhs.
_mat[1][2];
506 _mat[1][3] += rhs.
_mat[1][3];
507 _mat[2][0] += rhs.
_mat[2][0];
508 _mat[2][1] += rhs.
_mat[2][1];
509 _mat[2][2] += rhs.
_mat[2][2];
510 _mat[2][3] += rhs.
_mat[2][3];
511 _mat[3][0] += rhs.
_mat[3][0];
512 _mat[3][1] += rhs.
_mat[3][1];
513 _mat[3][2] += rhs.
_mat[3][2];
514 _mat[3][3] += rhs.
_mat[3][3];
546 virtual const char*
className()
const {
return "Matrix"; }
663 double bottom,
double top,
664 double zNear,
double zFar)
672 double bottom,
double top)
680 double bottom,
double top,
681 double zNear,
double zFar)
689 double zNear,
double zFar)
771 return Vec3f( (
m._mat[0][0]*v.
x() +
m._mat[1][0]*v.
y() +
m._mat[2][0]*v.
z()),
772 (
m._mat[0][1]*v.
x() +
m._mat[1][1]*v.
y() +
m._mat[2][1]*v.
z()),
773 (
m._mat[0][2]*v.
x() +
m._mat[1][2]*v.
y() +
m._mat[2][2]*v.
z()));
777 return Vec3d( (
m._mat[0][0]*v.
x() +
m._mat[1][0]*v.
y() +
m._mat[2][0]*v.
z()),
778 (
m._mat[0][1]*v.
x() +
m._mat[1][1]*v.
y() +
m._mat[2][1]*v.
z()),
779 (
m._mat[0][2]*v.
x() +
m._mat[1][2]*v.
y() +
m._mat[2][2]*v.
z()));
784 return Vec3f( (
m._mat[0][0]*v.
x() +
m._mat[0][1]*v.
y() +
m._mat[0][2]*v.
z()),
785 (
m._mat[1][0]*v.
x() +
m._mat[1][1]*v.
y() +
m._mat[1][2]*v.
z()),
786 (
m._mat[2][0]*v.
x() +
m._mat[2][1]*v.
y() +
m._mat[2][2]*v.
z()) ) ;
790 return Vec3d( (
m._mat[0][0]*v.
x() +
m._mat[0][1]*v.
y() +
m._mat[0][2]*v.
z()),
791 (
m._mat[1][0]*v.
x() +
m._mat[1][1]*v.
y() +
m._mat[1][2]*v.
z()),
792 (
m._mat[2][0]*v.
x() +
m._mat[2][1]*v.
y() +
m._mat[2][2]*v.
z()) ) ;
797 for (
unsigned i = 0; i < 3; ++i)
811 for (
unsigned i = 0; i < 3; ++i)
825 for (
unsigned i = 0; i < 3; ++i)
839 for (
unsigned i = 0; i < 3; ++i)
853 _mat[0][0] *= v[0];
_mat[0][1] *= v[0];
_mat[0][2] *= v[0];
_mat[0][3] *= v[0];
854 _mat[1][0] *= v[1];
_mat[1][1] *= v[1];
_mat[1][2] *= v[1];
_mat[1][3] *= v[1];
855 _mat[2][0] *= v[2];
_mat[2][1] *= v[2];
_mat[2][2] *= v[2];
_mat[2][3] *= v[2];
860 _mat[0][0] *= v[0];
_mat[0][1] *= v[0];
_mat[0][2] *= v[0];
_mat[0][3] *= v[0];
861 _mat[1][0] *= v[1];
_mat[1][1] *= v[1];
_mat[1][2] *= v[1];
_mat[1][3] *= v[1];
862 _mat[2][0] *= v[2];
_mat[2][1] *= v[2];
_mat[2][2] *= v[2];
_mat[2][3] *= v[2];
867 _mat[0][0] *= v[0];
_mat[1][0] *= v[0];
_mat[2][0] *= v[0];
_mat[3][0] *= v[0];
868 _mat[0][1] *= v[1];
_mat[1][1] *= v[1];
_mat[2][1] *= v[1];
_mat[3][1] *= v[1];
869 _mat[0][2] *= v[2];
_mat[1][2] *= v[2];
_mat[2][2] *= v[2];
_mat[3][2] *= v[2];
874 _mat[0][0] *= v[0];
_mat[1][0] *= v[0];
_mat[2][0] *= v[0];
_mat[3][0] *= v[0];
875 _mat[0][1] *= v[1];
_mat[1][1] *= v[1];
_mat[2][1] *= v[1];
_mat[3][1] *= v[1];
876 _mat[0][2] *= v[2];
_mat[1][2] *= v[2];
_mat[2][2] *= v[2];
_mat[3][2] *= v[2];
882 if (
q.zeroRotation())
891 if (
q.zeroRotation())
void setTrans(const Vec3d &v)
Matrixf(const Matrixd &mat)
void postMultTranslate(const Vec3d &v)
Definition Matrixf:823
static Matrixf perspective(double fovy, double aspectRatio, double zNear, double zFar)
Definition Matrixf:688
void mult(const Matrixf &, const Matrixf &)
static Matrixf identity(void)
Definition Matrixf:556
Matrixf(value_type a00, value_type a01, value_type a02, value_type a03, value_type a10, value_type a11, value_type a12, value_type a13, value_type a20, value_type a21, value_type a22, value_type a23, value_type a30, value_type a31, value_type a32, value_type a33)
void preMultScale(const Vec3d &v)
Definition Matrixf:851
bool isNaN() const
Definition Matrixf:57
static Matrixf lookAt(const Vec3f &eye, const Vec3f ¢er, const Vec3f &up)
Definition Matrixf:696
static Vec3f transform3x3(const Vec3f &v, const Matrixf &m)
Definition Matrixf:769
bool invert(const Matrixf &rhs)
Definition Matrixf:233
void makeRotate(const Vec3d &from, const Vec3d &to)
Vec3d getScale() const
Definition Matrixf:350
static Matrixf ortho(double left, double right, double bottom, double top, double zNear, double zFar)
Definition Matrixf:662
bool getPerspective(double &fovy, double &aspectRatio, double &zNear, double &zFar) const
float value_type
Definition Matrixf:30
static Matrixf scale(const Vec3f &sv)
Definition Matrixf:570
static Matrixf inverse(const Matrixf &matrix)
Definition Matrixf:648
void makeScale(const Vec3f &)
value_type & operator()(int row, int col)
Definition Matrixf:53
const value_type * ptr() const
Definition Matrixf:93
bool invert_4x4(const Matrixf &rhs)
void makeRotate(value_type angle1, const Vec3d &axis1, value_type angle2, const Vec3d &axis2, value_type angle3, const Vec3d &axis3)
void set(const Matrixf &rhs)
Definition Matrixf:71
void makePerspective(double fovy, double aspectRatio, double zNear, double zFar)
void orthoNormalize(const Matrixf &rhs)
bool invert_4x3(const Matrixf &rhs)
void decompose(osg::Vec3f &translation, osg::Quat &rotation, osg::Vec3f &scale, osg::Quat &so) const
void preMultTranslate(const Vec3d &v)
Definition Matrixf:795
void makeRotate(value_type angle, value_type x, value_type y, value_type z)
static Matrixf translate(const Vec3f &dv)
Definition Matrixf:587
void makeScale(const Vec3d &)
Vec3f postMult(const Vec3f &v) const
Definition Matrixf:710
void setRotate(const Quat &q)
Matrixf(const Matrixf &mat)
Definition Matrixf:34
int compare(const Matrixf &m) const
void set(const Matrixd &rhs)
static Matrixf orthoNormal(const Matrixf &matrix)
Definition Matrixf:655
value_type operator()(int row, int col) const
Definition Matrixf:54
bool getFrustum(double &left, double &right, double &bottom, double &top, double &zNear, double &zFar) const
void setTrans(const Vec3f &v)
bool transpose3x3(const Matrixf &rhs)
void set(float const *const ptr)
Definition Matrixf:75
void preMultRotate(const Quat &q)
Definition Matrixf:880
void makeRotate(const Vec3f &from, const Vec3f &to)
void set(double const *const ptr)
Definition Matrixf:81
bool valid() const
Definition Matrixf:56
value_type * ptr()
Definition Matrixf:92
void set(value_type a00, value_type a01, value_type a02, value_type a03, value_type a10, value_type a11, value_type a12, value_type a13, value_type a20, value_type a21, value_type a22, value_type a23, value_type a30, value_type a31, value_type a32, value_type a33)
void makeScale(value_type, value_type, value_type)
void makeRotate(value_type angle1, const Vec3f &axis1, value_type angle2, const Vec3f &axis2, value_type angle3, const Vec3f &axis3)
Vec3f operator*(const Vec3f &v) const
Definition Matrixf:915
static Matrixf rotate(const Vec3f &from, const Vec3f &to)
Definition Matrixf:635
void decompose(osg::Vec3d &translation, osg::Quat &rotation, osg::Vec3d &scale, osg::Quat &so) const
void postMultRotate(const Quat &q)
Definition Matrixf:889
void getLookAt(Vec3d &eye, Vec3d ¢er, Vec3d &up, value_type lookDistance=1.0f) const
void makeTranslate(const Vec3f &)
~Matrixf()
Definition Matrixf:45
void preMult(const Matrixf &)
value_type _mat[4][4]
Definition Matrixf:519
bool getOrtho(double &left, double &right, double &bottom, double &top, double &zNear, double &zFar) const
static Matrixf frustum(double left, double right, double bottom, double top, double zNear, double zFar)
Definition Matrixf:679
Vec3f preMult(const Vec3f &v) const
Definition Matrixf:725
Matrixf(float const *const ptr)
Definition Matrixf:36
bool transpose(const Matrixf &rhs)
Vec3d getTrans() const
Definition Matrixf:348
void makeLookAt(const Vec3d &eye, const Vec3d ¢er, const Vec3d &up)
Matrixf()
Definition Matrixf:33
void postMult(const Matrixf &)
void makeTranslate(value_type, value_type, value_type)
bool getOrtho(float &left, float &right, float &bottom, float &top, float &zNear, float &zFar) const
void makeOrtho(double left, double right, double bottom, double top, double zNear, double zFar)
void getLookAt(Vec3f &eye, Vec3f ¢er, Vec3f &up, value_type lookDistance=1.0f) const
void postMultScale(const Vec3d &v)
Definition Matrixf:865
Matrixf(const Quat &quat)
Definition Matrixf:38
Matrixf(double const *const ptr)
Definition Matrixf:37
bool isIdentity() const
Definition Matrixf:95
void makeRotate(const Quat &)
void makeOrtho2D(double left, double right, double bottom, double top)
Definition Matrixf:164
void makeFrustum(double left, double right, double bottom, double top, double zNear, double zFar)
bool getFrustum(float &left, float &right, float &bottom, float &top, float &zNear, float &zFar) const
void setTrans(value_type tx, value_type ty, value_type tz)
void makeTranslate(const Vec3d &)
static Matrixf ortho2D(double left, double right, double bottom, double top)
Definition Matrixf:671
void makeRotate(value_type angle, const Vec3d &axis)
bool getPerspective(float &fovy, float &aspectRatio, float &zNear, float &zFar) const
void makeRotate(value_type angle, const Vec3f &axis)
double other_value_type
Definition Matrixf:31
virtual Object * cloneType() const
Definition Matrixf:542
virtual const char * className() const
Definition Matrixf:546
virtual ~RefMatrixf()
Definition Matrixf:551
virtual Object * clone(const CopyOp &) const
Definition Matrixf:543
RefMatrixf(Matrixf::value_type const *const def)
Definition Matrixf:531
RefMatrixf()
Definition Matrixf:527
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)
Definition Matrixf:532
RefMatrixf(const Matrixd &other)
Definition Matrixf:529
RefMatrixf(const RefMatrixf &other)
Definition Matrixf:530
virtual const char * libraryName() const
Definition Matrixf:545
virtual bool isSameKindAs(const Object *obj) const
Definition Matrixf:544
RefMatrixf(const Matrixf &other)
Definition Matrixf:528
value_type & z()
Definition Vec3d:87
value_type & x()
Definition Vec3d:85
value_type & y()
Definition Vec3d:86
value_type length() const
Definition Vec3d:181
value_type & z()
Definition Vec3f:82
value_type & y()
Definition Vec3f:81
value_type & x()
Definition Vec3f:80
value_type & x()
Definition Vec4d:90
value_type & y()
Definition Vec4d:91
value_type & z()
Definition Vec4d:92
value_type & w()
Definition Vec4d:93
value_type & y()
Definition Vec4f:88
value_type & x()
Definition Vec4f:87
value_type & z()
Definition Vec4f:89
value_type & w()
Definition Vec4f:90
author: Julien Valentin 2017 (mp3butcher@hotmail.com)
Definition AlphaFunc:19
Vec3f operator*(const Vec3f &v, const Matrixd &m)
Definition Matrixd:793
T * get(unsigned int contextID)
Definition ContextData:152
bool isNaN(float v)
Definition Math:133
#define NULL
Definition osg/Export:55
#define OSG_EXPORT
Definition osg/Export:39