ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
ccIndexedTransformation Class Reference

#include <ecvIndexedTransformation.h>

Inheritance diagram for ccIndexedTransformation:
Collaboration diagram for ccIndexedTransformation:

Public Member Functions

 ccIndexedTransformation ()
 Default constructor. More...
 
 ccIndexedTransformation (const ccGLMatrix &matrix)
 Constructor from a transformation matrix. More...
 
 ccIndexedTransformation (const ccGLMatrix &matrix, double index)
 Constructor from a transformation matrix and an index. More...
 
 ccIndexedTransformation (const ccIndexedTransformation &trans)
 Copy constructor. More...
 
double getIndex () const
 Returns associated index (e.g. timestamp) More...
 
void setIndex (double index)
 Sets associated index (e.g. timestamp) More...
 
ccIndexedTransformation operator* (const ccGLMatrix &mat) const
 Multiplication by a ccGLMatrix operator. More...
 
ccIndexedTransformationoperator*= (const ccGLMatrix &mat)
 (in place) Multiplication by a ccGLMatrix operator More...
 
ccIndexedTransformationoperator+= (const CCVector3 &T)
 (in place) Translation operator More...
 
ccIndexedTransformationoperator-= (const CCVector3 &T)
 (in place) Translation operator More...
 
ccIndexedTransformation transposed () const
 Returns transposed transformation. More...
 
ccIndexedTransformation inverse () const
 Returns inverse transformation. 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...
 
bool isSerializable () const override
 Returns whether object is serializable of not. More...
 
bool toFile (QFile &out, short dataVersion) const override
 Saves data to binary stream. More...
 
short minimumFileVersion () const override
 Returns the minimum file version required to save this instance. More...
 
bool fromFile (QFile &in, short dataVersion, int flags, LoadedIDMap &oldToNewIDMap) override
 Loads data from binary stream. More...
 
- Public Member Functions inherited from ccGLMatrix
 ccGLMatrix ()
 Default constructor. More...
 
 ccGLMatrix (const ccGLMatrixTpl< float > &mat)
 Copy constructor from a ccGLMatrixTpl. More...
 
 ccGLMatrix (const float *mat16f)
 Constructor from a float GL matrix array. More...
 
 ccGLMatrix (const double *mat16d)
 Constructor from a double GL matrix array. More...
 
 ccGLMatrix (const Vector3Tpl< float > &X, const Vector3Tpl< float > &Y, const Vector3Tpl< float > &Z, const Vector3Tpl< float > &Tr)
 Constructor from 4 columns (X,Y,Z,Tr) More...
 
- Public Member Functions inherited from ccGLMatrixTpl< float >
 ccGLMatrixTpl (const Eigen::Matrix< float, 4, 4 > &mat)
 Copy Function. More...
 
 ccGLMatrixTpl (const Eigen::Matrix< double, 4, 4 > &mat)
 
 ccGLMatrixTpl (const Eigen::Matrix< float, 3, 3 > &mat)
 
 ccGLMatrixTpl (const Eigen::Matrix< double, 3, 3 > &mat)
 
 ccGLMatrixTpl ()
 Default constructor. More...
 
 ccGLMatrixTpl (const ccGLMatrixTpl< float > &mat)
 Copy constructor. More...
 
 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< float > &X, const Vector3Tpl< float > &Y, const Vector3Tpl< float > &Z, const Vector3Tpl< float > &Tr)
 Constructor from 4 columns (X,Y,Z,T) More...
 
ccGLMatrixTpl< float > & operator= (const Eigen::Matrix< float, 4, 4 > &mat)
 Assignment Function. More...
 
ccGLMatrixTpl< float > & operator= (const Eigen::Matrix< double, 4, 4 > &mat)
 
ccGLMatrixTpl< float > & operator= (const Eigen::Matrix< float, 3, 3 > &mat)
 
ccGLMatrixTpl< float > & operator= (const Eigen::Matrix< double, 3, 3 > &mat)
 
ccGLMatrixTpl< float > & operator= (const ccGLMatrixTpl< float > &mat)
 Copy assignment operator. More...
 
void toQuaternion (float q[]) const
 Converts to a quaternion from a rotation matrix. More...
 
void toAngleAxis (float &alpha_rad, Vector3Tpl< float > &axis3D) const
 Returns equivalent parameters: a rotation axis and an angle. More...
 
void toEulerAngle (float &rz, float &ry, float &rx) const
 Returns equivalent parameters: 3 rotation angles. More...
 
QString toString (int precision=12, QChar separator=' ') const
 Returns matrix as a string. More...
 
ccGLMatrixTpl< float > xRotation () const
 Returns the rotation component around X only. More...
 
ccGLMatrixTpl< float > yRotation () const
 Returns the rotation component around Y only. More...
 
ccGLMatrixTpl< float > zRotation () const
 Returns the rotation component around Z only. More...
 
virtual void toZero ()
 Clears matrix. More...
 
virtual void toIdentity ()
 Sets matrix to identity. More...
 
virtual bool isIdentity () const
 Returns whether this matrix is equal to identity. More...
 
void clearTranslation ()
 Clears translation. More...
 
void initFromParameters (float alpha_rad, const Vector3Tpl< float > &axis3D, const Vector3Tpl< float > &t3D)
 Inits transformation from a rotation axis, an angle and a translation. More...
 
void initFromParameters (float phi_rad, float theta_rad, float psi_rad, const Vector3Tpl< float > &t3D)
 Inits transformation from 3 rotation angles and a translation. More...
 
void getParameters (float &alpha_rad, Vector3Tpl< float > &axis3D, Vector3Tpl< float > &t3D) const
 
void getParameters (float &phi_rad, float &theta_rad, float &psi_rad, Vector3Tpl< float > &t3D) const
 Returns equivalent parameters: 3 rotation angles and a translation. More...
 
float * data ()
 Returns a pointer to internal data. More...
 
const float * data () const
 Returns a const pointer to internal data. More...
 
float * getTranslation ()
 Retruns a pointer to internal translation. More...
 
const float * getTranslation () const
 Retruns a const pointer to internal translation. More...
 
Vector3Tpl< float > 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...
 
void setRotation (const float Rt[9])
 Sets Rotation from a float array. More...
 
void setRotation (const double Rt[9])
 Sets Rotation from a double array. More...
 
float * getColumn (unsigned index)
 Returns a pointer to a given column. More...
 
const float * getColumn (unsigned index) const
 Returns a const pointer to a given column. More...
 
Vector3Tpl< float > getColumnAsVec3D (unsigned index) const
 Returns a copy of a given column as a CCVector3. More...
 
void setColumn (unsigned index, const Vector3Tpl< float > &v)
 Sets the content of a given column. More...
 
void setColumn (unsigned index, const Tuple4Tpl< float > &v)
 Sets the content of a given column. More...
 
ccGLMatrixTpl< float > operator* (const ccGLMatrixTpl< float > &mat) const
 Multiplication by a matrix operator. More...
 
Vector3Tpl< float > operator* (const Vector3Tpl< float > &vec) const
 Multiplication by a vector operator (float version) More...
 
Vector3Tpl< double > operator* (const Vector3Tpl< double > &vec) const
 Multiplication by a vector operator (double version) More...
 
Tuple4Tpl< float > operator* (const Tuple4Tpl< float > &vec) const
 Multiplication by a 4D vector operator (float version) More...
 
Tuple4Tpl< double > operator* (const Tuple4Tpl< double > &vec) const
 Multiplication by a 4D vector operator (double version) More...
 
ccGLMatrixTpl< float > & operator+= (const ccGLMatrixTpl< float > &mat)
 (in place) Addition operator More...
 
ccGLMatrixTpl< float > & operator+= (const Vector3Tpl< float > &Tr)
 (in place) Forward translation operator (float version) More...
 
ccGLMatrixTpl< float > & operator+= (const Vector3Tpl< double > &Tr)
 (in place) Forward translation operator (double version) More...
 
ccGLMatrixTpl< float > & operator-= (const ccGLMatrixTpl< float > &mat)
 (in place) Difference operator More...
 
ccGLMatrixTpl< float > & operator-= (const Vector3Tpl< float > &Tr)
 (in place) Backward translation operator (float version) More...
 
ccGLMatrixTpl< float > & operator-= (const Vector3Tpl< double > &Tr)
 (in place) Backward translation operator (double version) More...
 
ccGLMatrixTpl< float > & operator*= (const ccGLMatrixTpl< float > &mat)
 (in place) Multiplication operator More...
 
float operator() (unsigned row, unsigned col) const
 Returns the value at a given position. More...
 
void apply (float vec[3]) const
 Applies transformation to a 3D vector (in place) - float version. More...
 
void apply (double vec[3]) const
 Applies transformation to a 3D vector (in place) - double version. More...
 
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) More...
 
double applyX (const Vector3Tpl< double > &vec) const
 Get the resulting transformation along X dimension (double version) More...
 
float applyX (const Tuple4Tpl< float > &vec) const
 Get the resulting transformation along X dimension (float version) More...
 
double applyX (const Tuple4Tpl< double > &vec) const
 Get the resulting transformation along X dimension (double version) More...
 
float applyY (const Vector3Tpl< float > &vec) const
 Get the resulting transformation along Y dimension (float version) More...
 
double applyY (const Vector3Tpl< double > &vec) const
 Get the resulting transformation along Y dimension (double version) More...
 
float applyY (const Tuple4Tpl< float > &vec) const
 Get the resulting transformation along Y dimension (float version) More...
 
double applyY (const Tuple4Tpl< double > &vec) const
 Get the resulting transformation along Y dimension (double version) More...
 
float applyZ (const Vector3Tpl< float > &vec) const
 Get the resulting transformation along Z dimension (float version) More...
 
double applyZ (const Vector3Tpl< double > &vec) const
 Get the resulting transformation along Z dimension (double version) More...
 
float applyZ (const Tuple4Tpl< float > &vec) const
 Get the resulting transformation along Z dimension (float version) More...
 
double applyZ (const Tuple4Tpl< double > &vec) const
 Get the resulting transformation along Z dimension (double version) More...
 
float applyW (const Tuple4Tpl< float > &vec) const
 Get the resulting transformation along the 4th dimension (float version) More...
 
double applyW (const Tuple4Tpl< double > &vec) const
 
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< float > &vec)
 Shifts rotation center. More...
 
void transpose ()
 Transposes matrix (in place) More...
 
ccGLMatrixTpl< float > transposed () const
 Returns transposed matrix. More...
 
void invert ()
 Inverts transformation. More...
 
ccGLMatrixTpl< float > inverse () const
 Returns inverse transformation. More...
 
void scale (float coef)
 Scales the whole matrix. More...
 
void scaleLine (unsigned lineIndex, float coef)
 Scales one line of the matrix. More...
 
void scaleRotation (float coef)
 Scales the rotation part of the matrix. More...
 
void scaleRow (unsigned rowIndex, float coef)
 Scales one row of the matrix. More...
 
void scaleColumn (unsigned colIndex, float coef)
 Scales one column of the matrix. More...
 
bool isSerializable () const override
 Returns whether object is serializable of not. More...
 
bool toFile (QFile &out, short dataVersion) const override
 Saves data to binary stream. More...
 
short minimumFileVersion () const override
 Returns the minimum file version required to save this instance. 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. More...
 

Static Public Member Functions

static ccIndexedTransformation Interpolate (double interpIndex, const ccIndexedTransformation &trans1, const ccIndexedTransformation &trans2)
 Interpolates two transformations at an absolute position (index) More...
 
- Static Public Member Functions inherited from ccGLMatrixTpl< float >
static ccGLMatrixTpl< float > FromEigenMatrix (const Eigen::Matrix< double, 4, 4 > &mat)
 
static ccGLMatrixTpl< float > FromEigenMatrix3 (const Eigen::Matrix< float, 3, 3 > &mat)
 
static Eigen::Matrix< float, 4, 4 > ToEigenMatrix4 (const ccGLMatrixTpl< float > &mat)
 
static Eigen::Matrix< float, 4, 4 > ToEigenMatrix4 (const ccGLMatrixTpl< double > &mat)
 
static Eigen::Matrix< float, 3, 3 > ToEigenMatrix3 (const ccGLMatrixTpl< float > &mat)
 
static Eigen::Matrix< float, 3, 3 > ToEigenMatrix3 (const ccGLMatrixTpl< double > &mat)
 
static ccGLMatrixTpl Interpolate (float coef, const ccGLMatrixTpl< float > &glMat1, const ccGLMatrixTpl< float > &glMat2)
 Interpolates two matrices at relative position 'coef'. More...
 
static ccGLMatrixTpl< float > FromToRotation (const Vector3Tpl< float > &from, const Vector3Tpl< float > &to)
 Creates a transformation matrix that rotates a vector to another. More...
 
static ccGLMatrixTpl< float > FromQuaternion (const Tq q[])
 Converts a quaternion to a rotation matrix. More...
 
static Eigen::Matrix< float, 3, 3 > QuaternionToRotationMatrix (const Eigen::Matrix< float, 4, 1 > &qvec)
 Converts a quaternion to a rotation matrix. More...
 
static ccGLMatrixTpl< float > QuaternionToRotationMatrix (const Tuple4Tpl< float > &qvec)
 Converts a quaternion to a rotation matrix. More...
 
static Eigen::Matrix< float, 4, 1 > NormalizeQuaternion (const Eigen::Matrix< float, 4, 1 > &qvec)
 Converts a quaternion to a rotation matrix. More...
 
static ccGLMatrixTpl< float > FromViewDirAndUpDir (const Vector3Tpl< float > &forward, const Vector3Tpl< float > &up)
 Generates a 'viewing' matrix from a looking vector and a 'up' direction. More...
 
static ccGLMatrixTpl< float > 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 Attributes

double m_index
 Associated index (e.g. timestamp) More...
 
- Protected Attributes inherited from ccGLMatrixTpl< float >
float m_mat [OPENGL_MATRIX_SIZE]
 Internal 4x4 GL-style matrix data. More...
 

Additional Inherited Members

- Public Types inherited from ccSerializableObject
enum  DeserializationFlags { DF_POINT_COORDS_64_BITS , 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) More...
 

Detailed Description

A 4x4 'transformation' matrix (column major order) associated to an index (typically a timestamp)

Definition at line 15 of file ecvIndexedTransformation.h.

Constructor & Destructor Documentation

◆ ccIndexedTransformation() [1/4]

ccIndexedTransformation::ccIndexedTransformation ( )

Default constructor.

Matrix is set to identity (see ccGLMatrix::toIdentity) by default. Index is set to zero by default.

◆ ccIndexedTransformation() [2/4]

ccIndexedTransformation::ccIndexedTransformation ( const ccGLMatrix matrix)

Constructor from a transformation matrix.

Index is set to zero by default.

Parameters
matrixtransformation matrix

◆ ccIndexedTransformation() [3/4]

ccIndexedTransformation::ccIndexedTransformation ( const ccGLMatrix matrix,
double  index 
)

Constructor from a transformation matrix and an index.

Parameters
matrixtransformation matrix
indexassociated index (e.g. timestamp)

◆ ccIndexedTransformation() [4/4]

ccIndexedTransformation::ccIndexedTransformation ( const ccIndexedTransformation trans)

Copy constructor.

Member Function Documentation

◆ fromAsciiFile()

virtual bool ccIndexedTransformation::fromAsciiFile ( QString  filename)
virtual

Loads matrix from an ASCII file.

Parameters
filenameinput file name

Reimplemented from ccGLMatrixTpl< float >.

◆ fromFile()

bool ccIndexedTransformation::fromFile ( QFile &  in,
short  dataVersion,
int  flags,
LoadedIDMap oldToNewIDMap 
)
overridevirtual

Loads data from binary stream.

Parameters
ininput file (already opened)
dataVersionfile version (for version-specific deserialization)
flagsdeserialization flags (see ccSerializableObject::DeserializationFlags)
oldToNewIDMapmap to link old IDs with new IDs
Returns
success
Note: When implementing, use dataVersion checks to handle different
versions:
  • if (dataVersion >= X) { read new field } else { use default value } This ensures forward compatibility with older file formats.

Reimplemented from ccSerializableObject.

◆ getIndex()

double ccIndexedTransformation::getIndex ( ) const
inline

Returns associated index (e.g. timestamp)

Definition at line 39 of file ecvIndexedTransformation.h.

Referenced by define_ccIndexedTransformation().

◆ Interpolate()

static ccIndexedTransformation ccIndexedTransformation::Interpolate ( double  interpIndex,
const ccIndexedTransformation trans1,
const ccIndexedTransformation trans2 
)
static

Interpolates two transformations at an absolute position (index)

Warning: interpolation index must lie between the two input matrices indexes!

Parameters
interpIndexinterpolation position (should be between trans1 and trans2 indexes).
trans1first transformation
trans2second transformation

Referenced by define_ccIndexedTransformation().

◆ inverse()

ccIndexedTransformation ccIndexedTransformation::inverse ( ) const

Returns inverse transformation.

Warning: index is not modified by this operation.

Referenced by define_ccIndexedTransformation().

◆ isSerializable()

bool ccIndexedTransformation::isSerializable ( ) const
inlineoverridevirtual

Returns whether object is serializable of not.

Reimplemented from ccSerializableObject.

Definition at line 87 of file ecvIndexedTransformation.h.

◆ minimumFileVersion()

short ccIndexedTransformation::minimumFileVersion ( ) const
overridevirtual

Returns the minimum file version required to save this instance.

To be overridden by subclasses to indicate their minimum required version. This enables the system to determine:

  • Forward compatibility: newer software can read older files (dataVersion check in fromFile)
  • Backward compatibility: determine minimum version needed to save current data
    Returns
    minimum file version required for this object

Implements ccSerializableObject.

◆ operator*()

ccIndexedTransformation ccIndexedTransformation::operator* ( const ccGLMatrix mat) const

Multiplication by a ccGLMatrix operator.

◆ operator*=()

ccIndexedTransformation& ccIndexedTransformation::operator*= ( const ccGLMatrix mat)

(in place) Multiplication by a ccGLMatrix operator

Warning: index is not modified by this operation.

◆ operator+=()

ccIndexedTransformation& ccIndexedTransformation::operator+= ( const CCVector3 T)

(in place) Translation operator

Warning: index is not modified by this operation.

◆ operator-=()

ccIndexedTransformation& ccIndexedTransformation::operator-= ( const CCVector3 T)

(in place) Translation operator

Warning: index is not modified by this operation.

◆ setIndex()

void ccIndexedTransformation::setIndex ( double  index)
inline

Sets associated index (e.g. timestamp)

Definition at line 42 of file ecvIndexedTransformation.h.

Referenced by define_ccIndexedTransformation().

◆ toAsciiFile()

virtual bool ccIndexedTransformation::toAsciiFile ( QString  filename,
int  precision = 12 
) const
virtual

Saves matrix to an ASCII file.

Parameters
filenameoutput file name
precisionoutput digits precision

Reimplemented from ccGLMatrixTpl< float >.

◆ toFile()

bool ccIndexedTransformation::toFile ( QFile &  out,
short  dataVersion 
) const
overridevirtual

Saves data to binary stream.

Parameters
outoutput file (already opened)
dataVersiontarget file version (for forward/backward compatibility)
Returns
success

Reimplemented from ccSerializableObject.

◆ transposed()

ccIndexedTransformation ccIndexedTransformation::transposed ( ) const

Returns transposed transformation.

Warning: index is not modified by this operation.

Referenced by define_ccIndexedTransformation().

Member Data Documentation

◆ m_index

double ccIndexedTransformation::m_index
protected

Associated index (e.g. timestamp)

Definition at line 97 of file ecvIndexedTransformation.h.


The documentation for this class was generated from the following file: