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);
69 e(0,0) =
e(1,1) =
e(2,2) = n;
72 explicit Matrix3(T_Scalar e00, T_Scalar e01, T_Scalar e02,
73 T_Scalar e10, T_Scalar e11, T_Scalar e12,
74 T_Scalar e20, T_Scalar e21, T_Scalar e22)
76 e(0,0) = e00;
e(0,1) = e01;
e(0,2) = e02;
77 e(1,0) = e10;
e(1,1) = e11;
e(1,2) = e12;
78 e(2,0) = e20;
e(2,1) = e21;
e(2,2) = e22;
83 e(0,0) =
e(1,0) =
e(2,0) =
84 e(0,1) =
e(1,1) =
e(2,1) =
85 e(0,2) =
e(1,2) =
e(2,2) = val;
92 for(
int i=0; i<3; ++i)
93 for(
int j=0; j<3; ++j)
94 if (
e(j,i) > other.
e(j,i))
95 err +=
e(j,i) - other.
e(j,i);
97 err += other.
e(j,i) -
e(j,i);
148 return memcmp(m.
mVec,
mVec,
sizeof(T_Scalar)*9) == 0;
158 memcpy(
mVec, m.
mVec,
sizeof(T_Scalar)*9);
165 for(
int i=0; i<3; ++i)
166 for(
int j=0; j<3; ++j)
167 t.
e(j,i) =
e(j,i) + m.
e(j,i);
173 for(
int i=0; i<3; ++i)
174 for(
int j=0; j<3; ++j)
182 for(
int i=0; i<3; ++i)
183 for(
int j=0; j<3; ++j)
184 t.
e(j,i) =
e(j,i) - m.
e(j,i);
190 for(
int i=0; i<3; ++i)
191 for(
int j=0; j<3; ++j)
204 for(
int i=0; i<3; ++i)
205 for(
int j=0; j<3; ++j)
213 for(
int i=0; i<3; ++i)
214 for(
int j=0; j<3; ++j)
215 t.
e(j,i) =
e(j,i) + d;
221 for(
int i=0; i<3; ++i)
222 for(
int j=0; j<3; ++j)
230 for(
int i=0; i<3; ++i)
231 for(
int j=0; j<3; ++j)
232 t.
e(j,i) =
e(j,i) - d;
238 for(
int i=0; i<3; ++i)
239 for(
int j=0; j<3; ++j)
247 for(
int i=0; i<3; ++i)
248 for(
int j=0; j<3; ++j)
249 t.
e(j,i) =
e(j,i) * d;
255 for(
int i=0; i<3; ++i)
256 for(
int j=0; j<3; ++j)
265 for(
int i=0; i<3; ++i)
266 for(
int j=0; j<3; ++j)
267 t.
e(j,i) =
e(j,i) * d;
274 for(
int i=0; i<3; ++i)
275 for(
int j=0; j<3; ++j)
283 return memcmp(
ptr(), i.
ptr(),
sizeof(T_Scalar)*9) == 0;
289 t.
e(0,0) =
e(0,0); t.
e(1,0) =
e(1,0);
290 t.
e(0,1) =
e(0,1); t.
e(1,1) =
e(1,1);
297 e(0,0) = m.
e(0,0);
e(1,0) = m.
e(1,0);
298 e(0,1) = m.
e(0,1);
e(1,1) = m.
e(1,1);
306 const T_Scalar*
ptr()
const 314 for(
int i=0; i<3; ++i)
316 for(
int j=i; j<3; ++j)
329 for(
int i=0; i<3; ++i)
330 for(
int j=0; j<3; ++j)
337 for(
int i=0; i<3; ++i)
338 for(
int j=0; j<3; ++j)
339 dest.
e(j,i) =
e(i,j);
345 for(
int i=0; i<3; ++i)
346 for(
int j=0; j<3; ++j)
371 static const T_Scalar I3d[] =
373 (T_Scalar)1, (T_Scalar)0, (T_Scalar)0,
374 (T_Scalar)0, (T_Scalar)1, (T_Scalar)0,
375 (T_Scalar)0, (T_Scalar)0, (T_Scalar)1,
377 memcpy(
mVec, I3d,
sizeof(T_Scalar)*9);
491 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);
492 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);
493 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);
495 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);
496 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);
497 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);
499 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);
500 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);
501 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);
509 return *
this =
multiply(t, *
this, m);
515 return *
this =
multiply(t, m, *
this);
519 const T_Scalar&
e(
int i,
int j)
const {
return mVec[j][i]; }
520 T_Scalar&
e(
int i,
int j) {
return mVec[j][i]; }
533 template<
typename T_Scalar>
541 template<
typename T_Scalar>
547 template<
typename T_Scalar>
554 template<
typename T_Scalar>
558 t.
x() = v.
x()*m.
e(0,0) + v.
y()*m.
e(0,1) + v.
z()*m.
e(0,2);
559 t.
y() = v.
x()*m.
e(1,0) + v.
y()*m.
e(1,1) + v.
z()*m.
e(1,2);
560 t.
z() = v.
x()*m.
e(2,0) + v.
y()*m.
e(2,1) + v.
z()*m.
e(2,2);
566 template<
typename T_Scalar>
570 t.
x() = v.
x()*m.
e(0,0) + v.
y()*m.
e(0,1) ;
571 t.
y() = v.
x()*m.
e(1,0) + v.
y()*m.
e(1,1) ;
576 template<
typename T_Scalar>
580 t.
x() = v.
x()*m.
e(0,0) + v.
y()*m.
e(1,0) + v.
z()*m.
e(2,0);
581 t.
y() = v.
x()*m.
e(0,1) + v.
y()*m.
e(1,1) + v.
z()*m.
e(2,1);
582 t.
z() = v.
x()*m.
e(0,2) + v.
y()*m.
e(1,2) + v.
z()*m.
e(2,2);
588 template<
typename T_Scalar>
592 t.
x() = v.
x()*m.
e(0,0) + v.
y()*m.
e(1,0) ;
593 t.
y() = v.
x()*m.
e(0,1) + v.
y()*m.
e(1,1) ;
597 template<
typename T_Scalar>
602 T_Scalar s = (T_Scalar)
sin(degrees);
603 T_Scalar c = (T_Scalar)
cos(degrees);
604 rot.
e(0,0) = (T_Scalar)c;
605 rot.
e(1,1) = (T_Scalar)c;
606 rot.
e(1,0) = (T_Scalar)s;
607 rot.
e(0,1) = -(T_Scalar)s;
611 template<
typename T_Scalar>
623 const T_Scalar& a11 =
e(0,0);
624 const T_Scalar& a21 =
e(1,0);
625 const T_Scalar& a31 =
e(2,0);
626 const T_Scalar& a12 =
e(0,1);
627 const T_Scalar& a22 =
e(1,1);
628 const T_Scalar& a32 =
e(2,1);
629 const T_Scalar& a13 =
e(0,2);
630 const T_Scalar& a23 =
e(1,2);
631 const T_Scalar& a33 =
e(2,2);
633 T_Scalar A = a22*a33 - a32*a23;
634 T_Scalar B = a23*a31 - a33*a21;
635 T_Scalar C = a21*a32 - a31*a22;
637 T_Scalar det = a11*A + a12*B + a13*C;
643 B, a11*a33 - a31*a13, a13*a21 - a23*a11,
644 C, a12*a31 - a32*a11, a11*a22 - a21*a12) / det;
659 #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 & 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