qCC_db version 2.13.alpha (Qt) - 31 May 2022
CloudCompare 3D entities
|
A 4x4 'transformation' matrix (column major order) More...
#include <ccGLMatrixTpl.h>
Public Member Functions | |
ccGLMatrixTpl () | |
Default constructor. More... | |
ccGLMatrixTpl (const ccGLMatrixTpl< T > &mat) | |
Copy constructor. | |
ccGLMatrixTpl (const float *mat16f) | |
Constructor from a float GL matrix array. More... | |
ccGLMatrixTpl (const double *mat16d) | |
Constructor from a double GL matrix array. More... | |
ccGLMatrixTpl (const Vector3Tpl< T > &X, const Vector3Tpl< T > &Y, const Vector3Tpl< T > &Z, const Vector3Tpl< T > &Tr) | |
Constructor from 4 columns (X,Y,Z,T) More... | |
QString | toString (int precision=12, QChar separator=' ') const |
Returns matrix as a string. More... | |
virtual bool | toAsciiFile (QString filename, int precision=12) const |
Saves matrix to an ASCII file. More... | |
virtual bool | fromAsciiFile (QString filename) |
Loads matrix from an ASCII file. More... | |
ccGLMatrixTpl< T > | xRotation () const |
Returns the rotation component around X only. | |
ccGLMatrixTpl< T > | yRotation () const |
Returns the rotation component around Y only. | |
ccGLMatrixTpl< T > | zRotation () const |
Returns the rotation component around Z only. | |
virtual void | toZero () |
Clears matrix. More... | |
virtual void | toIdentity () |
Sets matrix to identity. | |
void | clearTranslation () |
Clears translation. More... | |
void | initFromParameters (T alpha_rad, const Vector3Tpl< T > &axis3D, const Vector3Tpl< T > &t3D) |
Inits transformation from a rotation axis, an angle and a translation. More... | |
void | initFromParameters (T phi_rad, T theta_rad, T psi_rad, const Vector3Tpl< T > &t3D) |
Inits transformation from 3 rotation angles and a translation. More... | |
void | getParameters (T &alpha_rad, Vector3Tpl< T > &axis3D, Vector3Tpl< T > &t3D) const |
Returns equivalent parameters: a rotation axis, an angle and a translation. More... | |
void | getParameters (T &phi_rad, T &theta_rad, T &psi_rad, Vector3Tpl< T > &t3D) const |
Returns equivalent parameters: 3 rotation angles and a translation. More... | |
T * | data () |
Returns a pointer to internal data. | |
const T * | data () const |
Returns a const pointer to internal data. | |
T * | getTranslation () |
Returns a pointer to internal translation. More... | |
const T * | getTranslation () const |
Returns a const pointer to internal translation. More... | |
Vector3Tpl< T > | getTranslationAsVec3D () const |
Returns a copy of the translation as a CCVector3. More... | |
void | setTranslation (const Vector3Tpl< float > &Tr) |
Sets translation (float version) More... | |
void | setTranslation (const Vector3Tpl< double > &Tr) |
Sets translation (double version) More... | |
void | setTranslation (const float Tr[3]) |
Sets translation from a float array. More... | |
void | setTranslation (const double Tr[3]) |
Sets translation from a double array. More... | |
T * | getColumn (unsigned index) |
Returns a pointer to a given column. More... | |
const T * | getColumn (unsigned index) const |
Returns a const pointer to a given column. More... | |
Vector3Tpl< T > | getColumnAsVec3D (unsigned index) const |
Returns a copy of a given column as a CCVector3. More... | |
void | setColumn (unsigned index, const Vector3Tpl< T > &v) |
Sets the content of a given column. More... | |
void | setColumn (unsigned index, const Tuple4Tpl< T > &v) |
Sets the content of a given column. More... | |
ccGLMatrixTpl< T > | operator* (const ccGLMatrixTpl< T > &mat) const |
Multiplication by a matrix operator. | |
Vector3Tpl< float > | operator* (const Vector3Tpl< float > &vec) const |
Multiplication by a vector operator (float version) | |
Vector3Tpl< double > | operator* (const Vector3Tpl< double > &vec) const |
Multiplication by a vector operator (double version) | |
Tuple4Tpl< float > | operator* (const Tuple4Tpl< float > &vec) const |
Multiplication by a 4D vector operator (float version) | |
Tuple4Tpl< double > | operator* (const Tuple4Tpl< double > &vec) const |
Multiplication by a 4D vector operator (double version) | |
ccGLMatrixTpl< T > & | operator+= (const ccGLMatrixTpl< T > &mat) |
(in place) Addition operator | |
ccGLMatrixTpl< T > & | operator-= (const ccGLMatrixTpl< T > &mat) |
(in place) Difference operator | |
ccGLMatrixTpl< T > & | operator*= (const ccGLMatrixTpl< T > &mat) |
(in place) Multiplication operator | |
ccGLMatrixTpl< T > & | operator+= (const Vector3Tpl< float > &Tr) |
(in place) Forward translation operator (float version) | |
ccGLMatrixTpl< T > & | operator+= (const Vector3Tpl< double > &Tr) |
(in place) Forward translation operator (double version) | |
ccGLMatrixTpl< T > & | operator-= (const Vector3Tpl< float > &Tr) |
(in place) Backward translation operator (float version) | |
ccGLMatrixTpl< T > & | operator-= (const Vector3Tpl< double > &Tr) |
(in place) Backward translation operator (double version) | |
T | operator() (unsigned row, unsigned col) const |
Returns the value at a given position. | |
void | apply (Vector3Tpl< float > &vec) const |
Applies transformation to a 3D vector (in place) - float version. More... | |
void | apply (Vector3Tpl< double > &vec) const |
Applies transformation to a 3D vector (in place) - double version. More... | |
void | apply (Tuple4Tpl< float > &vec) const |
Applies transformation to a 4D vector (in place) - float version. More... | |
void | apply (Tuple4Tpl< double > &vec) const |
Applies transformation to a 3D vector (in place) - double version. More... | |
float | applyX (const Vector3Tpl< float > &vec) const |
Get the resulting transformation along X dimension (float version) | |
double | applyX (const Vector3Tpl< double > &vec) const |
Get the resulting transformation along X dimension (double version) | |
float | applyY (const Vector3Tpl< float > &vec) const |
Get the resulting transformation along Y dimension (float version) | |
double | applyY (const Vector3Tpl< double > &vec) const |
Get the resulting transformation along Y dimension (double version) | |
float | applyZ (const Vector3Tpl< float > &vec) const |
Get the resulting transformation along Z dimension (float version) | |
double | applyZ (const Vector3Tpl< double > &vec) const |
Get the resulting transformation along Z dimension (double version) | |
float | applyX (const Tuple4Tpl< float > &vec) const |
Get the resulting transformation along X dimension (float version) | |
double | applyX (const Tuple4Tpl< double > &vec) const |
Get the resulting transformation along X dimension (double version) | |
float | applyY (const Tuple4Tpl< float > &vec) const |
Get the resulting transformation along Y dimension (float version) | |
double | applyY (const Tuple4Tpl< double > &vec) const |
Get the resulting transformation along Y dimension (double version) | |
float | applyZ (const Tuple4Tpl< float > &vec) const |
Get the resulting transformation along Z dimension (float version) | |
double | applyZ (const Tuple4Tpl< double > &vec) const |
Get the resulting transformation along Z dimension (double version) | |
float | applyW (const Tuple4Tpl< float > &vec) const |
Get the resulting transformation along the 4th dimension (float version) | |
double | applyW (const Tuple4Tpl< double > &vec) const |
Get the resulting transformation along the 4th dimension (double version) | |
void | applyRotation (Vector3Tpl< float > &vec) const |
Applies rotation only to a 3D vector (in place) - float version. More... | |
void | applyRotation (Vector3Tpl< double > &vec) const |
Applies rotation only to a 3D vector (in place) - double version. More... | |
void | applyRotation (float vec[3]) const |
Applies rotation only to a 3D vector (in place) - float version. More... | |
void | applyRotation (double vec[3]) const |
Applies rotation only to a 3D vector (in place) - float version. More... | |
void | shiftRotationCenter (const Vector3Tpl< T > &vec) |
Shifts rotation center. More... | |
void | transpose () |
Transposes matrix (in place) | |
ccGLMatrixTpl< T > | transposed () const |
Returns transposed matrix. | |
void | invert () |
Inverts transformation. | |
ccGLMatrixTpl< T > | inverse () const |
Returns inverse transformation. | |
void | scaleRotation (T coef) |
Scales the rotation part of the matrix. More... | |
void | scaleRow (unsigned rowIndex, T coef) |
Scales one row of the matrix. More... | |
void | scaleColumn (unsigned colIndex, T coef) |
Scales one column of the matrix. More... | |
bool | isSerializable () const override |
Returns whether object is serializable of not. More... | |
bool | toFile (QFile &out) const override |
Saves data to binary stream. More... | |
bool | fromFile (QFile &in, short dataVersion, int flags, LoadedIDMap &oldToNewIDMap) override |
Loads data from binary stream. More... | |
Public Member Functions inherited from ccSerializableObject | |
virtual | ~ccSerializableObject ()=default |
Destructor. | |
virtual bool | isSerializable () const |
Returns whether object is serializable of not. More... | |
virtual bool | toFile (QFile &out) const |
Saves data to binary stream. More... | |
virtual bool | fromFile (QFile &in, short dataVersion, int flags, LoadedIDMap &oldToNewIDMap) |
Loads data from binary stream. More... | |
Static Public Member Functions | |
static ccGLMatrixTpl | Interpolate (T coef, const ccGLMatrixTpl< T > &glMat1, const ccGLMatrixTpl< T > &glMat2) |
Interpolates two matrices at relative position 'coef'. More... | |
static ccGLMatrixTpl< T > | FromToRotation (const Vector3Tpl< T > &from, const Vector3Tpl< T > &to) |
Creates a transformation matrix that rotates a vector to another. More... | |
template<class Tq > | |
static ccGLMatrixTpl< T > | FromQuaternion (const Tq q[]) |
Converts a quaternion to a rotation matrix. More... | |
static ccGLMatrixTpl< T > | FromViewDirAndUpDir (const Vector3Tpl< T > &forward, const Vector3Tpl< T > &up) |
Generates a 'viewing' matrix from a looking vector and a 'up' direction. More... | |
static ccGLMatrixTpl< T > | FromString (const QString &matText, bool &success) |
Converts a 'text' matrix to a ccGLMatrix. More... | |
Static Public Member Functions inherited from ccSerializableObject | |
static bool | WriteError () |
Sends a custom error message (write error) and returns 'false'. More... | |
static bool | ReadError () |
Sends a custom error message (read error) and returns 'false'. More... | |
static bool | MemoryError () |
Sends a custom error message (not enough memory) and returns 'false'. More... | |
static bool | CorruptError () |
Sends a custom error message (corrupted file) and returns 'false'. More... | |
Protected Member Functions | |
void | internalRescale () |
Transfers the homogenous coordinate (scale) to the whole matrix. | |
Protected Attributes | |
T | m_mat [OPENGL_MATRIX_SIZE] |
Internal 4x4 GL-style matrix data. | |
Additional Inherited Members | |
Public Types inherited from ccSerializableObject | |
enum | DeserializationFlags { DF_POINT_COORDS_64_BITS = 1 , DF_SCALAR_VAL_32_BITS = 2 } |
Deserialization flags (bit-field) More... | |
typedef QMultiMap< unsigned, unsigned > | LoadedIDMap |
Map of loaded unique IDs (old ID --> new ID) | |
A 4x4 'transformation' matrix (column major order)
Transformation (M) is composed by a rotation (R) and a translation (T): M*X = R*X + T
|
inline |
Default constructor.
Matrix is set to identity (see toIdentity) by default.
|
inlineexplicit |
Constructor from a float GL matrix array.
mat16f | a 16 elements array (column major order) |
|
inlineexplicit |
Constructor from a double GL matrix array.
mat16d | a 16 elements array (column major order) |
|
inline |
Constructor from 4 columns (X,Y,Z,T)
X | 3 first elements of the 1st column (last one is 0) |
Y | 3 first elements of the 2nd column (last one is 0) |
Z | 3 first elements of the 3rd column (last one is 0) |
Tr | 3 first elements of the last column (last one is 1) |
|
inline |
Applies transformation to a 3D vector (in place) - double version.
Input vector is directly modified after calling this method
|
inline |
Applies transformation to a 4D vector (in place) - float version.
Input vector is directly modified after calling this method
|
inline |
Applies transformation to a 3D vector (in place) - double version.
Input vector is directly modified after calling this method
|
inline |
Applies transformation to a 3D vector (in place) - float version.
Input vector is directly modified after calling this method
|
inline |
Applies rotation only to a 3D vector (in place) - float version.
Input array is directly modified after calling this method
|
inline |
Applies rotation only to a 3D vector (in place) - float version.
Input array is directly modified after calling this method
|
inline |
Applies rotation only to a 3D vector (in place) - double version.
Input vector is directly modified after calling this method
|
inline |
Applies rotation only to a 3D vector (in place) - float version.
Input vector is directly modified after calling this method
|
inline |
Clears translation.
Translation is set to (0,0,0).
|
inlinevirtual |
Loads matrix from an ASCII file.
filename | input file name |
Reimplemented in ccIndexedTransformation.
|
inlineoverridevirtual |
Loads data from binary stream.
in | input file (already opened) |
dataVersion | file version |
flags | deserialization flags (see ccSerializableObject::DeserializationFlags) |
oldToNewIDMap | map to link old IDs with new IDs |
Reimplemented from ccSerializableObject.
|
inlinestatic |
Converts a quaternion to a rotation matrix.
q | quaternion (4 values: w,x,y,z) |
|
inlinestatic |
Converts a 'text' matrix to a ccGLMatrix.
[in] | matText | matrix text |
[out] | success | whether input matrix text is valid or not |
|
inlinestatic |
Creates a transformation matrix that rotates a vector to another.
Adapted from "Efficiently Building a Matrix to Rotate One Vector to Another" By Tomas Möller, John Hughes, Journal of Graphics Tools, 4(4):1-4, 1999
from | normalized non-zero source vector |
to | normalized non-zero destination vector |
|
inlinestatic |
Generates a 'viewing' matrix from a looking vector and a 'up' direction.
forward | forward 'view' vector |
up | up vector |
|
inline |
Returns a pointer to a given column.
index | column index (between 0 and 3) |
|
inline |
Returns a const pointer to a given column.
index | column index (between 0 and 3) |
|
inline |
Returns a copy of a given column as a CCVector3.
4th value is ignored.
index | column index (between 0 and 3) |
|
inline |
Returns equivalent parameters: a rotation axis, an angle and a translation.
[out] | alpha_rad | rotation angle in radians (in [0;pi]) |
[out] | axis3D | unit rotation axis |
[out] | t3D | translation |
|
inline |
Returns equivalent parameters: 3 rotation angles and a translation.
See http://en.wikipedia.org/wiki/Euler_angles (Tait-Bryan Z1Y2X3)
[out] | phi_rad | Phi angle (in radians) |
[out] | theta_rad | Theta angle (in radians) |
[out] | psi_rad | Psi angle (in radians) |
[out] | t3D | translation |
|
inline |
Returns a pointer to internal translation.
Translation corresponds to the beginning of the third column of the matrix.
|
inline |
Returns a const pointer to internal translation.
Translation corresponds to the beginning of the third column of the matrix.
|
inline |
Returns a copy of the translation as a CCVector3.
|
inline |
Inits transformation from a rotation axis, an angle and a translation.
[in] | alpha_rad | rotation angle (in radians) |
[in] | axis3D | rotation axis |
[in] | t3D | translation |
|
inline |
Inits transformation from 3 rotation angles and a translation.
See http://en.wikipedia.org/wiki/Euler_angles (Tait-Bryan Z1Y2X3)
[in] | phi_rad | Phi angle (in radians) |
[in] | theta_rad | Theta angle (in radians) |
[in] | psi_rad | Psi angle (in radians) |
[in] | t3D | translation |
|
inlinestatic |
Interpolates two matrices at relative position 'coef'.
coef | interpolation position (should be between 0 and 1). |
glMat1 | 'left' matrix |
glMat2 | 'right' matrix |
|
inlineoverridevirtual |
Returns whether object is serializable of not.
Reimplemented from ccSerializableObject.
|
inline |
Scales one column of the matrix.
colIndex | column index (0-3) |
coef | scaling coef. |
|
inline |
Scales the rotation part of the matrix.
coef | scaling coef. |
|
inline |
Scales one row of the matrix.
rowIndex | tow index (0-3) |
coef | scaling coef. |
|
inline |
Sets the content of a given column.
index | column index (between 0 and 3) |
v | new column values |
|
inline |
Sets the content of a given column.
index | column index (between 0 and 3) |
v | new column values |
|
inline |
Sets translation from a double array.
Tr | 3D vector as a double array |
|
inline |
Sets translation from a float array.
Tr | 3D vector as a float array |
|
inline |
Sets translation (double version)
Tr | 3D vector |
|
inline |
Sets translation (float version)
Tr | 3D vector |
|
inline |
Shifts rotation center.
Warning, this method only applies a shift (i.e. relatively to the current rotation center). This is not a way to set an absolute rotation center 'directly'.
|
inlinevirtual |
Saves matrix to an ASCII file.
filename | output file name |
precision | output digits precision |
Reimplemented in ccIndexedTransformation.
|
inlineoverridevirtual |
Saves data to binary stream.
out | output file (already opened) |
Reimplemented from ccSerializableObject.
|
inline |
Returns matrix as a string.
precision | numerical precision |
separator | separator |
|
inlinevirtual |
Clears matrix.
Matrix is set to 0.