32 #ifndef Matrix3_INCLUDE_ONCE 33 #define Matrix3_INCLUDE_ONCE 47 template<
typename T_Scalar>
56 e(0,0) = (T_Scalar)m.
e(0,0);
e(1,0) = (T_Scalar)m.
e(1,0);
e(2,0) = (T_Scalar)m.
e(2,0);
57 e(0,1) = (T_Scalar)m.
e(0,1);
e(1,1) = (T_Scalar)m.
e(1,1);
e(2,1) = (T_Scalar)m.
e(2,1);
58 e(0,2) = (T_Scalar)m.
e(0,2);
e(1,2) = (T_Scalar)m.
e(1,2);
e(2,2) = (T_Scalar)m.
e(2,2);
74 e(0,0) =
e(1,1) =
e(2,2) = n;
77 explicit Matrix3(T_Scalar e00, T_Scalar e01, T_Scalar e02,
78 T_Scalar e10, T_Scalar e11, T_Scalar e12,
79 T_Scalar e20, T_Scalar e21, T_Scalar e22)
81 e(0,0) = e00;
e(0,1) = e01;
e(0,2) = e02;
82 e(1,0) = e10;
e(1,1) = e11;
e(1,2) = e12;
83 e(2,0) = e20;
e(2,1) = e21;
e(2,2) = e22;
88 e(0,0) =
e(1,0) =
e(2,0) =
89 e(0,1) =
e(1,1) =
e(2,1) =
90 e(0,2) =
e(1,2) =
e(2,2) = val;
97 for(
int i=0; i<3; ++i)
98 for(
int j=0; j<3; ++j)
99 if (
e(j,i) > other.
e(j,i))
100 err +=
e(j,i) - other.
e(j,i);
102 err += other.
e(j,i) -
e(j,i);
153 return memcmp(m.
mVec,
mVec,
sizeof(T_Scalar)*9) == 0;
163 memcpy(
mVec, m.
mVec,
sizeof(T_Scalar)*9);
170 for(
int i=0; i<3; ++i)
171 for(
int j=0; j<3; ++j)
172 t.
e(j,i) =
e(j,i) + m.
e(j,i);
178 for(
int i=0; i<3; ++i)
179 for(
int j=0; j<3; ++j)
187 for(
int i=0; i<3; ++i)
188 for(
int j=0; j<3; ++j)
189 t.
e(j,i) =
e(j,i) - m.
e(j,i);
195 for(
int i=0; i<3; ++i)
196 for(
int j=0; j<3; ++j)
209 for(
int i=0; i<3; ++i)
210 for(
int j=0; j<3; ++j)
218 for(
int i=0; i<3; ++i)
219 for(
int j=0; j<3; ++j)
220 t.
e(j,i) =
e(j,i) + d;
226 for(
int i=0; i<3; ++i)
227 for(
int j=0; j<3; ++j)
235 for(
int i=0; i<3; ++i)
236 for(
int j=0; j<3; ++j)
237 t.
e(j,i) =
e(j,i) - d;
243 for(
int i=0; i<3; ++i)
244 for(
int j=0; j<3; ++j)
252 for(
int i=0; i<3; ++i)
253 for(
int j=0; j<3; ++j)
254 t.
e(j,i) =
e(j,i) * d;
260 for(
int i=0; i<3; ++i)
261 for(
int j=0; j<3; ++j)
270 for(
int i=0; i<3; ++i)
271 for(
int j=0; j<3; ++j)
272 t.
e(j,i) =
e(j,i) * d;
279 for(
int i=0; i<3; ++i)
280 for(
int j=0; j<3; ++j)
288 return memcmp(
ptr(), i.
ptr(),
sizeof(T_Scalar)*9) == 0;
294 t.
e(0,0) =
e(0,0); t.
e(1,0) =
e(1,0);
295 t.
e(0,1) =
e(0,1); t.
e(1,1) =
e(1,1);
302 e(0,0) = m.
e(0,0);
e(1,0) = m.
e(1,0);
303 e(0,1) = m.
e(0,1);
e(1,1) = m.
e(1,1);
311 const T_Scalar*
ptr()
const 319 for(
int i=0; i<3; ++i)
321 for(
int j=i; j<3; ++j)
334 for(
int i=0; i<3; ++i)
335 for(
int j=0; j<3; ++j)
342 for(
int i=0; i<3; ++i)
343 for(
int j=0; j<3; ++j)
344 dest.
e(j,i) =
e(i,j);
350 for(
int i=0; i<3; ++i)
351 for(
int j=0; j<3; ++j)
376 static const T_Scalar I3d[] =
378 (T_Scalar)1, (T_Scalar)0, (T_Scalar)0,
379 (T_Scalar)0, (T_Scalar)1, (T_Scalar)0,
380 (T_Scalar)0, (T_Scalar)0, (T_Scalar)1,
382 memcpy(
mVec, I3d,
sizeof(T_Scalar)*9);
496 out.
e(0,0) = q.
e(0,0)*p.
e(0,0) + q.
e(1,0)*p.
e(0,1) + q.
e(2,0)*p.
e(0,2);
497 out.
e(0,1) = q.
e(0,1)*p.
e(0,0) + q.
e(1,1)*p.
e(0,1) + q.
e(2,1)*p.
e(0,2);
498 out.
e(0,2) = q.
e(0,2)*p.
e(0,0) + q.
e(1,2)*p.
e(0,1) + q.
e(2,2)*p.
e(0,2);
500 out.
e(1,0) = q.
e(0,0)*p.
e(1,0) + q.
e(1,0)*p.
e(1,1) + q.
e(2,0)*p.
e(1,2);
501 out.
e(1,1) = q.
e(0,1)*p.
e(1,0) + q.
e(1,1)*p.
e(1,1) + q.
e(2,1)*p.
e(1,2);
502 out.
e(1,2) = q.
e(0,2)*p.
e(1,0) + q.
e(1,2)*p.
e(1,1) + q.
e(2,2)*p.
e(1,2);
504 out.
e(2,0) = q.
e(0,0)*p.
e(2,0) + q.
e(1,0)*p.
e(2,1) + q.
e(2,0)*p.
e(2,2);
505 out.
e(2,1) = q.
e(0,1)*p.
e(2,0) + q.
e(1,1)*p.
e(2,1) + q.
e(2,1)*p.
e(2,2);
506 out.
e(2,2) = q.
e(0,2)*p.
e(2,0) + q.
e(1,2)*p.
e(2,1) + q.
e(2,2)*p.
e(2,2);
514 return *
this =
multiply(t, *
this, m);
520 return *
this =
multiply(t, m, *
this);
524 const T_Scalar&
e(
int i,
int j)
const {
return mVec[j][i]; }
525 T_Scalar&
e(
int i,
int j) {
return mVec[j][i]; }
538 template<
typename T_Scalar>
546 template<
typename T_Scalar>
552 template<
typename T_Scalar>
559 template<
typename T_Scalar>
563 t.
x() = v.
x()*m.
e(0,0) + v.
y()*m.
e(0,1) + v.
z()*m.
e(0,2);
564 t.
y() = v.
x()*m.
e(1,0) + v.
y()*m.
e(1,1) + v.
z()*m.
e(1,2);
565 t.
z() = v.
x()*m.
e(2,0) + v.
y()*m.
e(2,1) + v.
z()*m.
e(2,2);
571 template<
typename T_Scalar>
575 t.
x() = v.
x()*m.
e(0,0) + v.
y()*m.
e(0,1) ;
576 t.
y() = v.
x()*m.
e(1,0) + v.
y()*m.
e(1,1) ;
581 template<
typename T_Scalar>
585 t.
x() = v.
x()*m.
e(0,0) + v.
y()*m.
e(1,0) + v.
z()*m.
e(2,0);
586 t.
y() = v.
x()*m.
e(0,1) + v.
y()*m.
e(1,1) + v.
z()*m.
e(2,1);
587 t.
z() = v.
x()*m.
e(0,2) + v.
y()*m.
e(1,2) + v.
z()*m.
e(2,2);
593 template<
typename T_Scalar>
597 t.
x() = v.
x()*m.
e(0,0) + v.
y()*m.
e(1,0) ;
598 t.
y() = v.
x()*m.
e(0,1) + v.
y()*m.
e(1,1) ;
602 template<
typename T_Scalar>
607 T_Scalar s = (T_Scalar)
sin(degrees);
608 T_Scalar c = (T_Scalar)
cos(degrees);
609 rot.
e(0,0) = (T_Scalar)c;
610 rot.
e(1,1) = (T_Scalar)c;
611 rot.
e(1,0) = (T_Scalar)s;
612 rot.
e(0,1) = -(T_Scalar)s;
616 template<
typename T_Scalar>
628 const T_Scalar& a11 =
e(0,0);
629 const T_Scalar& a21 =
e(1,0);
630 const T_Scalar& a31 =
e(2,0);
631 const T_Scalar& a12 =
e(0,1);
632 const T_Scalar& a22 =
e(1,1);
633 const T_Scalar& a32 =
e(2,1);
634 const T_Scalar& a13 =
e(0,2);
635 const T_Scalar& a23 =
e(1,2);
636 const T_Scalar& a33 =
e(2,2);
638 T_Scalar A = a22*a33 - a32*a23;
639 T_Scalar B = a23*a31 - a33*a21;
640 T_Scalar C = a21*a32 - a31*a22;
642 T_Scalar det = a11*A + a12*B + a13*C;
648 B, a11*a33 - a31*a13, a13*a21 - a23*a11,
649 C, a12*a31 - a32*a11, a11*a22 - a21*a12) / det;
664 #if VL_PIPELINE_PRECISION == 2 Matrix3 getTransposed() const
Matrix3 & operator/=(T_Scalar d)
bool operator!=(const Matrix3 &m) const
Matrix3 & rotate(T_Scalar degrees)
Vector2< T_Scalar > getX() const
Matrix3 & operator-=(T_Scalar d)
Vector2< T_Scalar > getY() const
bool operator==(const Matrix3 &m) const
Matrix3 operator-(T_Scalar d) const
Matrix3 & preMultiply(const Matrix3 &m)
Matrix3(T_Scalar e00, T_Scalar e01, T_Scalar e02, T_Scalar e10, T_Scalar e11, T_Scalar e12, T_Scalar e20, T_Scalar e21, T_Scalar e22)
static Matrix3 getRotation(T_Scalar degrees)
Matrix3(const Matrix3< T > &m)
Matrix3 & invert(T_Scalar *determinant=NULL)
const T_Scalar & z() const
Matrix2< T_Scalar > get2x2() const
Matrix3 & fill(T_Scalar val)
static Matrix3 getScaling(const Vector2< T_Scalar > &v)
Matrix3 & translate(T_Scalar x, T_Scalar y)
Matrix3< unsigned int > umat3
A 3x3 matrix using unsigned int precision.
static Matrix3 getScaling(T_Scalar x, T_Scalar y)
Matrix3 & operator*=(const Matrix3 &m)
static Matrix3 getTranslation(const Vector2< T_Scalar > &v)
The Matrix2 class is a template class that implements a generic 2x2 matrix, see also vl::dmat2...
T_Scalar getInverse(Matrix3 &dest) const
Vector2< T_Scalar > getT() const
static Matrix3 & multiply(Matrix3 &out, const Matrix3 &p, const Matrix3 &q)
Matrix3 & operator+=(T_Scalar d)
const T_Scalar & e(int i, int j) const
Matrix3 & setY(const Vector2< T_Scalar > &v)
Matrix3 & operator+=(const Matrix3 &m)
Matrix3 operator+(T_Scalar d) const
Matrix3 operator-() const
Matrix3 operator+(const Matrix3 &m) const
Visualization Library main namespace.
const double dDEG_TO_RAD
Constant to convert degree into radian using double precision.
static Matrix3 & getScaling(Matrix3 &out, const Vector2< T_Scalar > &v)
Matrix3 & translate(const Vector2< T_Scalar > &v)
The Matrix3 class is a template class that implements a generic 3x3 matrix, see also vl::dmat3...
void set2x2(const Matrix2< T_Scalar > &m)
This writes only on the upper 2x2 part of the matrix without touching the last row and column...
The Vector3 class is a template class that implements a generic 3 components vector, see also vl::fvec3, vl::dvec3, vl::uvec3, vl::ivec3, vl::svec3, vl::usvec3, vl::bvec3, vl::ubvec3.
T_Scalar diff(const Matrix3 &other) const
Matrix3 operator*(T_Scalar d) const
Matrix3< double > dmat3
A 3x3 matrix using double precision.
const T_Scalar & e(int i, int j) const
static Matrix3 getTranslation(T_Scalar x, T_Scalar y)
const T_Scalar * ptr() const
static Matrix3 & getScaling(Matrix3 &out, T_Scalar x, T_Scalar y)
static Matrix3 & getNull(Matrix3 &out)
const T_Scalar & y() const
Matrix3< int > imat3
A 3x3 matrix using int precision.
static Matrix3 & getTranslation(Matrix3 &out, const Vector2< T_Scalar > &v)
Matrix3 & setT(const Vector2< T_Scalar > &v)
static Matrix3 & getTranslation(Matrix3 &out, T_Scalar x, T_Scalar y)
Matrix3 operator/(T_Scalar d) const
Matrix3(const Matrix3 &other)
Matrix3 & operator-=(const Matrix3 &m)
Vector3< T_Scalar > mVec[3]
The Vector2 class is a template class that implements a generic 2 components vector, see also vl::fvec2, vl::dvec2, vl::uvec2, vl::ivec2, vl::svec2, vl::usvec2, vl::bvec2, vl::ubvec2.
Matrix3< float > fmat3
A 3x3 matrix using float precision.
static Matrix3 getIdentity()
Matrix3 & scale(T_Scalar x, T_Scalar y)
Matrix3 getInverse(T_Scalar *determinant=NULL) const
fmat3 mat3
Defined as: 'typedef fmat3 mat3'. See also VL_PIPELINE_PRECISION.
const T_Scalar & x() const
Matrix3 & scale(const Vector2< T_Scalar > &v)
const T_Scalar & x() const
Matrix3 & operator=(const Matrix3 &m)
T_Scalar & e(int i, int j)
const T_Scalar & y() const
Matrix3 & operator*=(T_Scalar d)
Matrix3 & postMultiply(const Matrix3 &m)
Matrix3 operator-(const Matrix3 &m) const
static Matrix3 & getIdentity(Matrix3 &out)
Matrix3 & setX(const Vector2< T_Scalar > &v)
Matrix3 & getTransposed(Matrix3 &dest) const