65 Tmat4(
const double in00,
const double in01,
const double in02,
const double in03,
66 const double in10,
const double in11,
const double in12,
const double in13,
67 const double in20,
const double in21,
const double in22,
const double in23,
68 const double in30,
const double in31,
const double in32,
const double in33);
99 #if ML_DEPRECATED_SINCE(3,5,0)
106 targetVec = transformPoint(sourceVec);
151 template <
class IDX_TYP>
155 return det3(this->v[1][col1], this->v[1][col2], this->v[1][col3],
156 this->v[2][col1], this->v[2][col2], this->v[2][col3],
157 this->v[3][col1], this->v[3][col2], this->v[3][col3]);
193 this->v[0] = this->v[1] = this->v[2] = this->v[3] =
Tvec4<DT>(0);
200 this->v[0][0] = this->v[1][1] = this->v[2][2] = this->v[3][3] = diagValue;
201 this->v[1][0] = this->v[2][0] = this->v[3][0] = this->v[2][1] = this->v[3][1] = this->v[3][2] = 0;
202 this->v[0][1] = this->v[0][2] = this->v[0][3] = this->v[1][2] = this->v[1][3] = this->v[2][3] = 0;
219 this->v[0] = mat.
v[0];
220 this->v[1] = mat.
v[1];
221 this->v[2] = mat.
v[2];
222 this->v[3] = mat.
v[3];
255 matrix[0][3] = matrix[1][3] = matrix[2][3] = 0;
260 for (i = 0; i < 3; i++)
262 for (j = 0; j < 3; j++)
264 dirVec[j] = matrix[j][i];
267 for (j = 0; j < 3; j++)
269 matrix[j][i] = dirVec[j];
279 this->v[0] = this->v[1] = this->v[2] = this->v[3] =
Tvec4<DT>(val);
299 this->v[0] += m.
v[0];
300 this->v[1] += m.
v[1];
301 this->v[2] += m.
v[2];
302 this->v[3] += m.
v[3];
310 this->v[0] -= m.
v[0];
311 this->v[1] -= m.
v[1];
312 this->v[2] -= m.
v[2];
313 this->v[3] -= m.
v[3];
343 this->v[0].apply(fct);
344 this->v[1].apply(fct);
345 this->v[2].apply(fct);
346 this->v[3].apply(fct);
356 #define _ML_MAT4_RC(i, j) a[i][0]*b[0][j] + a[i][1]*b[1][j] + \
357 a[i][2]*b[2][j] + a[i][3]*b[3][j]
380 return ((a[0] == b[0]) &&
483 Tmat4<DT>::Tmat4(
const double in00,
const double in01,
const double in02,
const double in03,
484 const double in10,
const double in11,
const double in12,
const double in13,
485 const double in20,
const double in21,
const double in22,
const double in23,
486 const double in30,
const double in31,
const double in32,
const double in33)
488 this->v[0][0]=
static_cast<DT>(in00); this->v[0][1]=
static_cast<DT>(in01); this->v[0][2]=
static_cast<DT>(in02); this->v[0][3]=
static_cast<DT>(in03);
489 this->v[1][0]=
static_cast<DT>(in10); this->v[1][1]=
static_cast<DT>(in11); this->v[1][2]=
static_cast<DT>(in12); this->v[1][3]=
static_cast<DT>(in13);
490 this->v[2][0]=
static_cast<DT>(in20); this->v[2][1]=
static_cast<DT>(in21); this->v[2][2]=
static_cast<DT>(in22); this->v[2][3]=
static_cast<DT>(in23);
491 this->v[3][0]=
static_cast<DT>(in30); this->v[3][1]=
static_cast<DT>(in31); this->v[3][2]=
static_cast<DT>(in32); this->v[3][3]=
static_cast<DT>(in33);
500 this->v[0][0] = mat[ 0]; this->v[0][1] = mat[ 1]; this->v[0][2] = mat[ 2]; this->v[0][3] = mat[ 3];
501 this->v[1][0] = mat[ 4]; this->v[1][1] = mat[ 5]; this->v[1][2] = mat[ 6]; this->v[1][3] = mat[ 7];
502 this->v[2][0] = mat[ 8]; this->v[2][1] = mat[ 9]; this->v[2][2] = mat[10]; this->v[2][3] = mat[11];
503 this->v[3][0] = mat[12]; this->v[3][1] = mat[13]; this->v[3][2] = mat[14]; this->v[3][3] = mat[15];
514 mat[ 0] =
static_cast<float>(this->v[0][0]); mat[ 1] =
static_cast<float>(this->v[0][1]); mat[ 2] =
static_cast<float>(this->v[0][2]); mat[ 3] =
static_cast<float>(this->v[0][3]);
515 mat[ 4] =
static_cast<float>(this->v[1][0]); mat[ 5] =
static_cast<float>(this->v[1][1]); mat[ 6] =
static_cast<float>(this->v[1][2]); mat[ 7] =
static_cast<float>(this->v[1][3]);
516 mat[ 8] =
static_cast<float>(this->v[2][0]); mat[ 9] =
static_cast<float>(this->v[2][1]); mat[10] =
static_cast<float>(this->v[2][2]); mat[11] =
static_cast<float>(this->v[2][3]);
517 mat[12] =
static_cast<float>(this->v[3][0]); mat[13] =
static_cast<float>(this->v[3][1]); mat[14] =
static_cast<float>(this->v[3][2]); mat[15] =
static_cast<float>(this->v[3][3]);
526 this->v[0][0] =
static_cast<DT>(mat[ 0]); this->v[0][1] =
static_cast<DT>(mat[ 1]); this->v[0][2] =
static_cast<DT>(mat[ 2]); this->v[0][3] =
static_cast<DT>(mat[ 3]);
527 this->v[1][0] =
static_cast<DT>(mat[ 4]); this->v[1][1] =
static_cast<DT>(mat[ 5]); this->v[1][2] =
static_cast<DT>(mat[ 6]); this->v[1][3] =
static_cast<DT>(mat[ 7]);
528 this->v[2][0] =
static_cast<DT>(mat[ 8]); this->v[2][1] =
static_cast<DT>(mat[ 9]); this->v[2][2] =
static_cast<DT>(mat[10]); this->v[2][3] =
static_cast<DT>(mat[11]);
529 this->v[3][0] =
static_cast<DT>(mat[12]); this->v[3][1] =
static_cast<DT>(mat[13]); this->v[3][2] =
static_cast<DT>(mat[14]); this->v[3][3] =
static_cast<DT>(mat[15]);
540 mat[ 0] =
static_cast<double>(this->v[0][0]); mat[ 1] =
static_cast<double>(this->v[0][1]); mat[ 2] =
static_cast<double>(this->v[0][2]); mat[ 3] =
static_cast<double>(this->v[0][3]);
541 mat[ 4] =
static_cast<double>(this->v[1][0]); mat[ 5] =
static_cast<double>(this->v[1][1]); mat[ 6] =
static_cast<double>(this->v[1][2]); mat[ 7] =
static_cast<double>(this->v[1][3]);
542 mat[ 8] =
static_cast<double>(this->v[2][0]); mat[ 9] =
static_cast<double>(this->v[2][1]); mat[10] =
static_cast<double>(this->v[2][2]); mat[11] =
static_cast<double>(this->v[2][3]);
543 mat[12] =
static_cast<double>(this->v[3][0]); mat[13] =
static_cast<double>(this->v[3][1]); mat[14] =
static_cast<double>(this->v[3][2]); mat[15] =
static_cast<double>(this->v[3][3]);
552 this->v[0][0] = scale; this->v[0][1] = 0; this->v[0][2] = 0; this->v[0][3] = 0;
553 this->v[1][0] = 0; this->v[1][1] = scale; this->v[1][2] = 0; this->v[1][3] = 0;
554 this->v[2][0] = 0; this->v[2][1] = 0; this->v[2][2] = scale; this->v[2][3] = 0;
555 this->v[3][0] = 0; this->v[3][1] = 0; this->v[3][2] = 0; this->v[3][3] = scale;
574 return ( this->v[0][0] * determinantLower3(1u, 2u, 3u)
575 - this->v[0][1] * determinantLower3(0u, 2u, 3u)
576 + this->v[0][2] * determinantLower3(0u, 1u, 3u)
577 - this->v[0][3] * determinantLower3(0u, 1u, 2u));
586 return Tmat4<DT>(this->v[0][0], this->v[1][0], this->v[2][0], this->v[3][0],
587 this->v[0][1], this->v[1][1], this->v[2][1], this->v[3][1],
588 this->v[0][2], this->v[1][2], this->v[2][2], this->v[3][2],
589 this->v[0][3], this->v[1][3], this->v[2][3], this->v[3][3]);
636 const DT c = cos(angleRad);
637 const DT s = sin(angleRad);
638 const DT t = 1.0 - c;
663 Tvec4<DT>(0.0, scaleVector[1], 0.0, 0.0),
664 Tvec4<DT>(0.0, 0.0, scaleVector[2], 0.0),
682 retVal[3][2] = 1.0/d;
701 static const DT Epsilon =
static_cast<DT>(10e-14);
707 "Tmat4<DT> Tmat4<DT>::inverse(bool* isInvertible) const, matrix not invertable",
730 #if ML_DEPRECATED_SINCE(3,5,0)
766 inline std::ostream &
operator<<(std::ostream &os,
const ML_LA_NAMESPACE::Tmat4<DT> &m)
768 return os << m[0] <<
'\n' << m[1] <<
'\n' << m[2] <<
'\n' << m[3];
773 inline std::istream &
operator>>(std::istream &
is, ML_LA_NAMESPACE::Tmat4<DT> &m)
775 ML_LA_NAMESPACE::Tmat4<DT> m_tmp;
776 is >> m_tmp[0] >> m_tmp[1] >> m_tmp[2] >> m_tmp[3];
777 if (
is){ m = m_tmp; }
A class to administrate an axis coordinate system drawable in OpenGL.
Base class of all matrix classes which holds the data buffer and provides some general access methods...
VectorT v[size]
The rows constituting the matrix.
FloatingPointVector< T, size, DataContainer > operator/(FloatingPointVector< T, size, DataContainer > lhs, MLdouble rhs)
Component wise division of lhs by specialized rhs of type MLdouble.
T normalize()
Normalizes the buffer and returns the Euclidean length of vector before normalization,...
T operator*(const FloatingPointVector< T, size, DataContainer > &a, const FloatingPointVector< T, size, DataContainer > &b)
Dot product, returns a.dot(b).
FloatingPointVector< T, size, DataContainer > operator+(FloatingPointVector< T, size, DataContainer > lhs, const FloatingPointVector< T, size, DataContainer > &rhs)
Return value is the component wise addition of lhs and rhs.
FloatingPointVector< T, size, DataContainer > operator-(FloatingPointVector< T, size, DataContainer > lhs, const FloatingPointVector< T, size, DataContainer > &rhs)
Return value is the component wise subtraction of rhs from lhs.
A four by four matrix class consisting of 4 row vectors.
Tmat4(const double mat[16])
Constructor from 16 double values in an array given by mat, row by row.
DT determinantLower3(const IDX_TYP col1, const IDX_TYP col2, const IDX_TYP col3) const
void set(const DT val)
Sets all values to double val.
Tmat4< DT > inverse(bool *isInvertible=nullptr) const
Returns the inverse Gauss-Jordan elimination with partial pivoting.
Tmat4(const Tvec3< DT > &n0, const Tvec3< DT > &n1, const Tvec3< DT > &n3, const Tvec3< DT > &t)
Constructs a matrix from three base vectors and translation (as COLUMN vectors)
Tmat4(const Tvec4< DT > &row0, const Tvec4< DT > &row1, const Tvec4< DT > &row2, const Tvec4< DT > &row3)
Composes a matrix from the four vectors row0, row1, row2 and row3.
void getValues(float mat[16]) const
Copies the contents of *this into floating point matrix mat, row by row.
Tvec3< DT > transformPoint(const Tvec3< DT > &sourceVec) const
Transforms the given sourceVec and returns the result vector.
Tmat4(const float mat[16])
Constructor from 16 floating point values in an array given by mat, row by row.
const Tmat4< DT > & operator/=(const DT d)
Divides by an MLdouble constant d. Division by zero is not handled and must be avoided by caller.
static Tmat4< DT > getIdentity()
Returns the identity matrix.
DT det() const
Returns the determinant of *this.
bool operator<(const Tmat4< DT > &) const
Dummy "lesser than operator" which always returns false.
DT det3(DT A, DT B, DT C, DT D, DT E, DT F, DT G, DT H, DT I) const
Determines the determinant of a 3x3 matrix given by A,B,C,D,E,F,G,H,I.
void setValues(const double mat[16])
Copies the contents of mat into *this, row by row.
Tmat4< DT > transpose() const
Returns the transposed *this.
Tmat4(const double in00, const double in01, const double in02, const double in03, const double in10, const double in11, const double in12, const double in13, const double in20, const double in21, const double in22, const double in23, const double in30, const double in31, const double in32, const double in33)
Initializes all matrix elements explicitly with scalars, row by row.
static Tmat4< DT > getMat(const double val)
Returns a matrix filled with values val.
const Tmat4< DT > & operator=(const Tmat4< DT > &m)
Assigns from a Tmat4.
Tmat4(const Tmat4< DT > &mat)
Copy constructor from the Tmat4 mat.
Tmat4< DT > getRotationMatrix() const
Returns the rotational part of the matrix (removes scaling and translation).
void setScaleMatrix(const DT scale)
Sets a diagonal matrix with scale on diagonal.
const Tmat4< DT > & operator+=(const Tmat4< DT > &m)
Increments by a Tmat4.
void setValues(const float mat[16])
Copies the contents of mat into *this, row by row.
const Tmat4< DT > & operator*=(const DT d)
Multiplies by an MLdouble constant d.
Tmat4(const DT diagValue)
const Tmat4< DT > & apply(MLDblFuncPtr fct)
Applies the function fct to all vectors of *this and return the matrix.
void getValues(double mat[16]) const
Copies the contents of *this into mat, row by row.
const Tmat4< DT > & operator-=(const Tmat4< DT > &m)
Decrements by a Tmat4.
DT ComponentType
A typedef to "export" the type of components.
Tmat4()
Constructs a matrix from 16 zero elements.
Forward declarations to resolve header file dependencies.
Tvec4< DT > affinePoint() const
Builds a homogeneous Tvec4 point from *this and return it, i.e.
Forward declarations to resolve header file dependencies.
#define ML_CHECK_FLOAT_THROW(x)
MLEXPORT std::ostream & operator<<(std::ostream &s, const ml::Field &v)
Overloads the operator "<<" for stream output of Field objects.
#define _ML_MAT4_RC(i, j)
Helper macro only locally defined for Tmat4 matrix multiplication.
double(* MLDblFuncPtr)(double)
A function pointer type to a function which returns a double and takes a double as argument.
std::istream & operator>>(std::istream &in, ml::Variant &variant)
void apply(Fnc &&fnc, const std::tuple< Args... > &tuple)
Tmat4< DT > translation3D(const Tvec3< DT > &v)
Returns a 4x4 homogeneous translation matrix with default identity matrix contents and the upper thre...
Tmat4< DT > rotation3D(Tvec3< DT > Axis, const DT angleRad)
Returns a 4x4 homogeneous 3D rotation matrix describing a rotation with angle angleRad around axis Ax...
FloatingPointVector< T, size, DataContainer > & operator/=(FloatingPointVector< T, size, DataContainer > &op1, MLdouble value)
Arithmetic assignment: Component wise division of *this by scalar value.
FloatingPointVector< T, size, DataContainer > & operator-=(FloatingPointVector< T, size, DataContainer > &op1, const FloatingPointVector< T, size, DataContainer > &buffer)
Arithmetic assignment: Component wise subtraction of buffer from *this.
Tmat4< DT > scaling3D(const Tvec3< DT > &scaleVector)
Scaling 3D.
bool operator==(const Tmat4< DT > &a, const Tmat4< DT > &b)
a == b ? Return true if yes.
Tmat4< MLdouble > Matrix4d
A 4x4 matrix of type double.
Tmat4< DT > perspective3D(const DT d)
Creates a 4x4 homogeneous perspective projection matrix with perspective shortening value given by d ...
Tmat4< MLdouble > Matrix4
The standard 4x4 matrix of type double.
bool operator!=(const Tmat4< DT > &a, const Tmat4< DT > &b)
a != b ? Return true if yes.
Tmat4< DT > identity3D()
Returns a 4x4 homogeneous identity3D matrix; synonym for Tmat4<DT>::getIdentity().
Tmat4< MLldouble > Matrix4ld
A 4x4 matrix of type long double.
constexpr Is< T > is(T d)
FloatingPointVector< T, size, DataContainer > & operator+=(FloatingPointVector< T, size, DataContainer > &op1, const FloatingPointVector< T, size, DataContainer > &buffer)
Arithmetic assignment: Component wise addition.
Tmat4< MLfloat > Matrix4f
A 4x4 matrix of type float.
BASE_TYPE MLInverseMatHelper(const BASE_TYPE &origMat, bool *isInvertible, const typename BASE_TYPE::ComponentType, const char *const ZeroDetErrString, const BASE_TYPE &Identity, const size_t Dim)
Computes an N dimensional inverse from given default parameters.
FloatingPointVector< T, size, DataContainer > & operator*=(FloatingPointVector< T, size, DataContainer > &op1, MLdouble value)
Arithmetic assignment: Component wise multiplication *this with specialized MLdouble scalar value.