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); }
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; }
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.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;
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.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);
255 inline static Matrixd identity(
void );
279 inline static Matrixd ortho(
double left,
double right,
280 double bottom,
double top,
281 double zNear,
double zFar);
286 inline static Matrixd ortho2D(
double left,
double right,
287 double bottom,
double top);
292 inline static Matrixd frustum(
double left,
double right,
293 double bottom,
double top,
294 double zNear,
double zFar);
300 inline static Matrixd perspective(
double fovy,
double aspectRatio,
301 double zNear,
double zFar);
319 inline Vec3f postMult(
const Vec3f& v )
const;
320 inline Vec3d postMult(
const Vec3d& v )
const;
321 inline Vec3f operator* (
const Vec3f& v )
const;
322 inline Vec3d operator* (
const Vec3d& v )
const;
325 inline Vec4f postMult(
const Vec4f& v )
const;
326 inline Vec4d postMult(
const Vec4d& v )
const;
327 inline Vec4f operator* (
const Vec4f& v )
const;
328 inline Vec4d operator* (
const Vec4d& v )
const;
330#ifdef OSG_USE_DEPRECATED_API
331 inline void set(
const Quat& q) { makeRotate(q); }
332 inline void get(
Quat& q)
const { q = getRotate(); }
349 Vec3d x_vec(_mat[0][0],_mat[1][0],_mat[2][0]);
350 Vec3d y_vec(_mat[0][1],_mat[1][1],_mat[2][1]);
351 Vec3d z_vec(_mat[0][2],_mat[1][2],_mat[2][2]);
373 inline void preMultTranslate(
const Vec3d& v );
374 inline void preMultTranslate(
const Vec3f& v );
376 inline void postMultTranslate(
const Vec3d& v );
377 inline void postMultTranslate(
const Vec3f& v );
380 inline void preMultScale(
const Vec3d& v );
381 inline void preMultScale(
const Vec3f& v );
383 inline void postMultScale(
const Vec3d& v );
384 inline void postMultScale(
const Vec3f& v );
387 inline void preMultRotate(
const Quat& q );
389 inline void postMultRotate(
const Quat& q );
391 inline void operator *= (
const Matrixd& other )
392 {
if(
this == &other ) {
396 else postMult( other );
434 virtual const char*
className()
const {
return "Matrix"; }
551 double bottom,
double top,
552 double zNear,
double zFar)
560 double bottom,
double top)
568 double bottom,
double top,
569 double zNear,
double zFar)
577 double zNear,
double zFar)
667 return Vec3f( (
m._mat[0][0]*v.
x() +
m._mat[1][0]*v.
y() +
m._mat[2][0]*v.
z()),
668 (
m._mat[0][1]*v.
x() +
m._mat[1][1]*v.
y() +
m._mat[2][1]*v.
z()),
669 (
m._mat[0][2]*v.
x() +
m._mat[1][2]*v.
y() +
m._mat[2][2]*v.
z()));
673 return Vec3d( (
m._mat[0][0]*v.
x() +
m._mat[1][0]*v.
y() +
m._mat[2][0]*v.
z()),
674 (
m._mat[0][1]*v.
x() +
m._mat[1][1]*v.
y() +
m._mat[2][1]*v.
z()),
675 (
m._mat[0][2]*v.
x() +
m._mat[1][2]*v.
y() +
m._mat[2][2]*v.
z()));
680 return Vec3f( (
m._mat[0][0]*v.
x() +
m._mat[0][1]*v.
y() +
m._mat[0][2]*v.
z()),
681 (
m._mat[1][0]*v.
x() +
m._mat[1][1]*v.
y() +
m._mat[1][2]*v.
z()),
682 (
m._mat[2][0]*v.
x() +
m._mat[2][1]*v.
y() +
m._mat[2][2]*v.
z()) ) ;
686 return Vec3d( (
m._mat[0][0]*v.
x() +
m._mat[0][1]*v.
y() +
m._mat[0][2]*v.
z()),
687 (
m._mat[1][0]*v.
x() +
m._mat[1][1]*v.
y() +
m._mat[1][2]*v.
z()),
688 (
m._mat[2][0]*v.
x() +
m._mat[2][1]*v.
y() +
m._mat[2][2]*v.
z()) ) ;
693 for (
unsigned i = 0; i < 3; ++i)
707 for (
unsigned i = 0; i < 3; ++i)
721 for (
unsigned i = 0; i < 3; ++i)
735 for (
unsigned i = 0; i < 3; ++i)
749 _mat[0][0] *= v[0];
_mat[0][1] *= v[0];
_mat[0][2] *= v[0];
_mat[0][3] *= v[0];
750 _mat[1][0] *= v[1];
_mat[1][1] *= v[1];
_mat[1][2] *= v[1];
_mat[1][3] *= v[1];
751 _mat[2][0] *= v[2];
_mat[2][1] *= v[2];
_mat[2][2] *= v[2];
_mat[2][3] *= v[2];
756 _mat[0][0] *= v[0];
_mat[0][1] *= v[0];
_mat[0][2] *= v[0];
_mat[0][3] *= v[0];
757 _mat[1][0] *= v[1];
_mat[1][1] *= v[1];
_mat[1][2] *= v[1];
_mat[1][3] *= v[1];
758 _mat[2][0] *= v[2];
_mat[2][1] *= v[2];
_mat[2][2] *= v[2];
_mat[2][3] *= v[2];
763 _mat[0][0] *= v[0];
_mat[1][0] *= v[0];
_mat[2][0] *= v[0];
_mat[3][0] *= v[0];
764 _mat[0][1] *= v[1];
_mat[1][1] *= v[1];
_mat[2][1] *= v[1];
_mat[3][1] *= v[1];
765 _mat[0][2] *= v[2];
_mat[1][2] *= v[2];
_mat[2][2] *= v[2];
_mat[3][2] *= v[2];
770 _mat[0][0] *= v[0];
_mat[1][0] *= v[0];
_mat[2][0] *= v[0];
_mat[3][0] *= v[0];
771 _mat[0][1] *= v[1];
_mat[1][1] *= v[1];
_mat[2][1] *= v[1];
_mat[3][1] *= v[1];
772 _mat[0][2] *= v[2];
_mat[1][2] *= v[2];
_mat[2][2] *= v[2];
_mat[3][2] *= v[2];
777 if (
q.zeroRotation())
786 if (
q.zeroRotation())
void makeRotate(value_type angle, const Vec3d &axis)
Matrixd(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)
float other_value_type
Definition Matrixd:31
void setRotate(const Quat &q)
Vec3d getScale() const
Definition Matrixd:348
~Matrixd()
Definition Matrixd:45
static Vec3f transform3x3(const Vec3f &v, const Matrixd &m)
Definition Matrixd:665
static Matrixd ortho2D(double left, double right, double bottom, double top)
Definition Matrixd:559
void postMultRotate(const Quat &q)
Definition Matrixd:784
bool isIdentity() const
Definition Matrixd:95
void makeRotate(const Vec3d &from, const Vec3d &to)
void set(const Matrixd &rhs)
Definition Matrixd:71
void setTrans(value_type tx, value_type ty, value_type tz)
void makeTranslate(value_type, value_type, value_type)
void preMultScale(const Vec3d &v)
Definition Matrixd:747
void makeLookAt(const Vec3d &eye, const Vec3d ¢er, const Vec3d &up)
value_type _mat[4][4]
Definition Matrixd:407
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 makeRotate(value_type angle, const Vec3f &axis)
bool getOrtho(float &left, float &right, float &bottom, float &top, float &zNear, float &zFar) const
static Matrixd orthoNormal(const Matrixd &matrix)
Definition Matrixd:543
void setTrans(const Vec3f &v)
void postMultScale(const Vec3d &v)
Definition Matrixd:761
Matrixd(const Matrixd &mat)
Definition Matrixd:34
Matrixd(const Matrixf &mat)
Matrixd()
Definition Matrixd:33
bool getPerspective(double &fovy, double &aspectRatio, double &zNear, double &zFar) const
bool invert_4x4(const Matrixd &rhs)
static Matrixd frustum(double left, double right, double bottom, double top, double zNear, double zFar)
Definition Matrixd:567
void makeRotate(const Quat &)
void makeScale(const Vec3d &)
void makeScale(value_type, value_type, value_type)
value_type * ptr()
Definition Matrixd:92
bool transpose(const Matrixd &rhs)
void setTrans(const Vec3d &v)
Matrixd(float const *const ptr)
Definition Matrixd:36
static Matrixd lookAt(const Vec3f &eye, const Vec3f ¢er, const Vec3f &up)
Definition Matrixd:584
static Matrixd ortho(double left, double right, double bottom, double top, double zNear, double zFar)
Definition Matrixd:550
void makeFrustum(double left, double right, double bottom, double top, double zNear, double zFar)
Matrixd(const Quat &quat)
Definition Matrixd:38
void getLookAt(Vec3d &eye, Vec3d ¢er, Vec3d &up, value_type lookDistance=1.0f) const
void orthoNormalize(const Matrixd &rhs)
Matrixd(double const *const ptr)
Definition Matrixd:37
int compare(const Matrixd &m) const
void preMultTranslate(const Vec3d &v)
Definition Matrixd:691
void makeRotate(value_type angle1, const Vec3d &axis1, value_type angle2, const Vec3d &axis2, value_type angle3, const Vec3d &axis3)
const value_type * ptr() const
Definition Matrixd:93
Vec3f operator*(const Vec3f &v) const
Definition Matrixd:813
Vec3f preMult(const Vec3f &v) const
Definition Matrixd:618
void makeRotate(value_type angle, value_type x, value_type y, value_type z)
value_type operator()(int row, int col) const
Definition Matrixd:54
static Matrixd scale(const Vec3f &sv)
Definition Matrixd:458
bool valid() const
Definition Matrixd:56
static Matrixd perspective(double fovy, double aspectRatio, double zNear, double zFar)
Definition Matrixd:576
void makeTranslate(const Vec3f &)
void set(float const *const ptr)
Definition Matrixd:75
void postMult(const Matrixd &)
Vec3d getTrans() const
Definition Matrixd:346
void makeOrtho(double left, double right, double bottom, double top, double zNear, double zFar)
static Matrixd rotate(const Vec3f &from, const Vec3f &to)
Definition Matrixd:523
void makeScale(const Vec3f &)
static Matrixd inverse(const Matrixd &matrix)
Definition Matrixd:536
Vec3f postMult(const Vec3f &v) const
Definition Matrixd:602
value_type & operator()(int row, int col)
Definition Matrixd:53
void decompose(osg::Vec3d &translation, osg::Quat &rotation, osg::Vec3d &scale, osg::Quat &so) const
void set(const Matrixf &rhs)
void getLookAt(Vec3f &eye, Vec3f ¢er, Vec3f &up, value_type lookDistance=1.0f) const
bool getOrtho(double &left, double &right, double &bottom, double &top, double &zNear, double &zFar) const
void makeOrtho2D(double left, double right, double bottom, double top)
Definition Matrixd:164
bool invert_4x3(const Matrixd &rhs)
double value_type
Definition Matrixd:30
void preMultRotate(const Quat &q)
Definition Matrixd:775
static Matrixd translate(const Vec3f &dv)
Definition Matrixd:475
void preMult(const Matrixd &)
void makeTranslate(const Vec3d &)
void makeRotate(value_type angle1, const Vec3f &axis1, value_type angle2, const Vec3f &axis2, value_type angle3, const Vec3f &axis3)
bool getFrustum(double &left, double &right, double &bottom, double &top, double &zNear, double &zFar) const
void makePerspective(double fovy, double aspectRatio, double zNear, double zFar)
void postMultTranslate(const Vec3d &v)
Definition Matrixd:719
void makeRotate(const Vec3f &from, const Vec3f &to)
bool getPerspective(float &fovy, float &aspectRatio, float &zNear, float &zFar) const
bool invert(const Matrixd &rhs)
Definition Matrixd:233
static Matrixd identity(void)
Definition Matrixd:444
bool getFrustum(float &left, float &right, float &bottom, float &top, float &zNear, float &zFar) const
void decompose(osg::Vec3f &translation, osg::Quat &rotation, osg::Vec3f &scale, osg::Quat &so) const
bool isNaN() const
Definition Matrixd:57
void mult(const Matrixd &, const Matrixd &)
void set(double const *const ptr)
Definition Matrixd:81
bool transpose3x3(const Matrixd &rhs)
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)
Definition Matrixd:420
RefMatrixd(const Matrixf &other)
Definition Matrixd:417
virtual bool isSameKindAs(const Object *obj) const
Definition Matrixd:432
RefMatrixd(Matrixd::value_type const *const def)
Definition Matrixd:419
virtual Object * cloneType() const
Definition Matrixd:430
RefMatrixd(const RefMatrixd &other)
Definition Matrixd:418
virtual Object * clone(const CopyOp &) const
Definition Matrixd:431
RefMatrixd()
Definition Matrixd:415
virtual const char * libraryName() const
Definition Matrixd:433
virtual ~RefMatrixd()
Definition Matrixd:439
RefMatrixd(const Matrixd &other)
Definition Matrixd:416
virtual const char * className() const
Definition Matrixd:434
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