gVirtualXRay  2.0.10
VirtualX-RayImagingLibraryonGPU
Public Member Functions | Static Public Member Functions | Protected Attributes
gVirtualXRay::Matrix4x4< T > Class Template Reference

Matrix4x4 is a template class to handle a 4 by 4 matrix. More...

#include <Matrix4x4.h>

Collaboration diagram for gVirtualXRay::Matrix4x4< T >:
Collaboration graph

Public Member Functions

 Matrix4x4 (const T &a1=1.0f, const T &a2=0.0f, const T &a3=0.0f, const T &a4=0.0f, const T &a5=0.0f, const T &a6=1.0f, const T &a7=0.0f, const T &a8=0.0f, const T &a9=0.0f, const T &a10=0.0f, const T &a11=1.0f, const T &a12=0.0f, const T &a13=0.0f, const T &a14=0.0f, const T &a15=0.0f, const T &a16=1.0f)
 Default Constructor (create an identity matrix). More...
 
 Matrix4x4 (const Matrix4x4 &aMatrix)
 Copy Constructor. More...
 
 Matrix4x4 (const Matrix4x4 *apMatrix)
 Copy Constructor. More...
 
 Matrix4x4 (const T *apMatrix)
 Copy Constructor. More...
 
 Matrix4x4 (const std::vector< double > &apMatrix)
 Copy Constructor. More...
 
void loadIdentity ()
 Load identity matrix. More...
 
void setFromVector (const std::vector< double > &apMatrix)
 Load the matrix. More...
 
void rotate (const double anAngle, const Vec3< T > &aVector)
 Multiply the current matrix by a rotation matrix. More...
 
void yawPitchRollRotate (double yaw, double pitch, double roll)
 Multiply the current matrix by a yaw, pitch, roll rotation matrix. More...
 
void translate (const Vec3< T > &aVector)
 Multiply the current matrix by a translation matrix. More...
 
void translate (T x, T y, T z)
 Multiply the current matrix by a translation matrix. More...
 
void scale (T x, T y, T z)
 Multiply the current matrix by a scaling matrix. More...
 
Matrix4x4 getTranspose () const
 Get the transpose of the current matrix. More...
 
determinant () const
 Compute the determinant of the current matrix. More...
 
Matrix4x4 getInverse () const
 Get the inverse of the current matrix. More...
 
Matrix4x4operator= (const Matrix4x4 &aMatrix)
 Copy operator. More...
 
const T * get () const
 Accessor on the 4x4 matrix data. More...
 
const T * get4x4 () const
 Accessor on the 4x4 matrix data. More...
 
const T * get3x3 ()
 Accessor on the 3x3 matrix data. More...
 
std::vector< double > getAsVector () const
 Accessor on the 4x4 matrix data. More...
 
Vec3< T > operator* (const Vec3< T > &aVector) const
 Operator * to multiply the current matrix by a vector. More...
 
Matrix4x4 operator* (const Matrix4x4 &aMatrix) const
 Operator * to multiply the current matrix by another matrix. More...
 
Matrix4x4operator*= (const Matrix4x4 &aMatrix)
 
void print () const
 Print the matrix in the console. More...
 
void print (std::ostream &anOutputStream) const
 Print the matrix in the console. More...
 

Static Public Member Functions

static Matrix4x4 buildIdentityMatrix ()
 Build an identity matrix. More...
 
static Matrix4x4 buildTranslationMatrix (const Vec3< T > &aVector)
 Build a tranlation matrix. More...
 
static Matrix4x4 buildRotationMatrix (T anAngle, T x, T y, T z)
 Build a rotation matrix. More...
 
static Matrix4x4 buildYawPitchRollRotationMatrix (T yaw, T pitch, T roll)
 Build a rotation matrix. More...
 
static Matrix4x4 buildScaleMatrix (const Vec3< T > &aVector)
 Build a scale matrix. More...
 
static Matrix4x4 buildScaleMatrix (T x, T y, T z)
 Build a scale matrix. More...
 
static Matrix4x4 buildRotationMatrix (T anAngle, const Vec3< T > &aVector)
 Build a rotation matrix. More...
 
static Matrix4x4 buildTranslationMatrix (T x, T y, T z)
 Build a rotation matrix. More...
 

Protected Attributes

m_p_4x4_data [4 *4]
 the matrix data More...
 
m_p_3x3_data [3 *3]
 the matrix data More...
 
bool m_small_matrix_up_to_date
 

Detailed Description

template<typename T>
class gVirtualXRay::Matrix4x4< T >

Matrix4x4 is a template class to handle a 4 by 4 matrix.

Definition at line 89 of file Matrix4x4.h.

Constructor & Destructor Documentation

◆ Matrix4x4() [1/5]

template<typename T>
gVirtualXRay::Matrix4x4< T >::Matrix4x4 ( const T &  a1 = 1.0f,
const T &  a2 = 0.0f,
const T &  a3 = 0.0f,
const T &  a4 = 0.0f,
const T &  a5 = 0.0f,
const T &  a6 = 1.0f,
const T &  a7 = 0.0f,
const T &  a8 = 0.0f,
const T &  a9 = 0.0f,
const T &  a10 = 0.0f,
const T &  a11 = 1.0f,
const T &  a12 = 0.0f,
const T &  a13 = 0.0f,
const T &  a14 = 0.0f,
const T &  a15 = 0.0f,
const T &  a16 = 1.0f 
)

Default Constructor (create an identity matrix).

Parameters
a1the 1st element of the matrix
a2the 2nd element of the matrix
a3the 3rd element of the matrix
a4the 4th element of the matrix
a5the 5th element of the matrix
a6the 6th element of the matrix
a7the 7th element of the matrix
a8the 8th element of the matrix
a9the 9th element of the matrix
a10the 10th element of the matrix
a11the 11th element of the matrix
a12the 12th element of the matrix
a13the 13th element of the matrix
a14the 14th element of the matrix
a15the 15th element of the matrix
a16the 16th element of the matrix

Definition at line 87 of file Matrix4x4.inl.

◆ Matrix4x4() [2/5]

template<typename T>
gVirtualXRay::Matrix4x4< T >::Matrix4x4 ( const Matrix4x4< T > &  aMatrix)

Copy Constructor.

Parameters
aMatrixthe matrix to copy

Definition at line 115 of file Matrix4x4.inl.

◆ Matrix4x4() [3/5]

template<typename T>
gVirtualXRay::Matrix4x4< T >::Matrix4x4 ( const Matrix4x4< T > *  apMatrix)

Copy Constructor.

Parameters
apMatrixthe matrix to copy

◆ Matrix4x4() [4/5]

template<typename T>
gVirtualXRay::Matrix4x4< T >::Matrix4x4 ( const T *  apMatrix)

Copy Constructor.

Parameters
apMatrixthe matrix to copy

Definition at line 125 of file Matrix4x4.inl.

◆ Matrix4x4() [5/5]

template<typename T>
gVirtualXRay::Matrix4x4< T >::Matrix4x4 ( const std::vector< double > &  apMatrix)

Copy Constructor.

Parameters
apMatrixthe matrix to copy

Definition at line 135 of file Matrix4x4.inl.

Member Function Documentation

◆ buildIdentityMatrix()

template<typename T >
Matrix4x4< T > gVirtualXRay::Matrix4x4< T >::buildIdentityMatrix ( )
static

Build an identity matrix.

Returns
the identity matrix

Definition at line 237 of file Matrix4x4.inl.

◆ buildRotationMatrix() [1/2]

template<typename T>
Matrix4x4< T > gVirtualXRay::Matrix4x4< T >::buildRotationMatrix ( anAngle,
x,
y,
z 
)
static

Build a rotation matrix.

Parameters
anAnglethe angle of rotation in degrees
xthe x-component of the axis of rotation
ythe y-component of the axis of rotation
zthe z-component of the axis of rotation
Returns
the corresponding rotation matrix

Definition at line 307 of file Matrix4x4.inl.

◆ buildRotationMatrix() [2/2]

template<typename T>
Matrix4x4< T > gVirtualXRay::Matrix4x4< T >::buildRotationMatrix ( anAngle,
const Vec3< T > &  aVector 
)
static

Build a rotation matrix.

Parameters
anAnglethe angle of rotation in degrees
aVectorthe axis of rotation
Returns
the corresponding translation matrix

Definition at line 298 of file Matrix4x4.inl.

◆ buildScaleMatrix() [1/2]

template<typename T>
Matrix4x4< T > gVirtualXRay::Matrix4x4< T >::buildScaleMatrix ( const Vec3< T > &  aVector)
static

Build a scale matrix.

Parameters
aVectorthe scale vector
Returns
the corresponding scale matrix

Definition at line 268 of file Matrix4x4.inl.

◆ buildScaleMatrix() [2/2]

template<typename T>
Matrix4x4< T > gVirtualXRay::Matrix4x4< T >::buildScaleMatrix ( x,
y,
z 
)
static

Build a scale matrix.

Parameters
xthe x-component of the axis of scale
ythe y-component of the axis of scale
zthe z-component of the axis of scale
Returns
the corresponding scale matrix

Definition at line 276 of file Matrix4x4.inl.

◆ buildTranslationMatrix() [1/2]

template<typename T>
Matrix4x4< T > gVirtualXRay::Matrix4x4< T >::buildTranslationMatrix ( const Vec3< T > &  aVector)
static

Build a tranlation matrix.

Parameters
aVectorthe translation vector
Returns
the corresponding translation matrix

Definition at line 249 of file Matrix4x4.inl.

◆ buildTranslationMatrix() [2/2]

template<typename T>
Matrix4x4< T > gVirtualXRay::Matrix4x4< T >::buildTranslationMatrix ( x,
y,
z 
)
static

Build a rotation matrix.

Parameters
xthe x-component of the translation vector
ythe y-component of the translation vector
zthe z-component of the translation vector
Returns
the corresponding translation matrix

Definition at line 257 of file Matrix4x4.inl.

◆ buildYawPitchRollRotationMatrix()

template<typename T>
Matrix4x4< T > gVirtualXRay::Matrix4x4< T >::buildYawPitchRollRotationMatrix ( yaw,
pitch,
roll 
)
static

Build a rotation matrix.

Parameters
yawa counterclockwise rotation of yaw degrees about the z-axis
pitcha counterclockwise rotation of yaw degrees about the y-axis
rolla counterclockwise rotation of yaw degrees about the x-axis
Returns
the corresponding rotation matrix

Definition at line 356 of file Matrix4x4.inl.

◆ determinant()

template<typename T >
T gVirtualXRay::Matrix4x4< T >::determinant ( ) const

Compute the determinant of the current matrix.

Returns
the determinant

Definition at line 436 of file Matrix4x4.inl.

◆ get()

template<typename T >
const T * gVirtualXRay::Matrix4x4< T >::get ( ) const

Accessor on the 4x4 matrix data.

Returns
the matrix raw data

Definition at line 548 of file Matrix4x4.inl.

◆ get3x3()

template<typename T >
const T * gVirtualXRay::Matrix4x4< T >::get3x3 ( )

Accessor on the 3x3 matrix data.

Returns
the matrix raw data

Definition at line 564 of file Matrix4x4.inl.

◆ get4x4()

template<typename T >
const T * gVirtualXRay::Matrix4x4< T >::get4x4 ( ) const

Accessor on the 4x4 matrix data.

Returns
the matrix raw data

Definition at line 556 of file Matrix4x4.inl.

◆ getAsVector()

template<typename T >
std::vector< double > gVirtualXRay::Matrix4x4< T >::getAsVector ( ) const

Accessor on the 4x4 matrix data.

Returns
the matrix raw data

Definition at line 590 of file Matrix4x4.inl.

◆ getInverse()

template<typename T >
Matrix4x4< T > gVirtualXRay::Matrix4x4< T >::getInverse ( ) const

Get the inverse of the current matrix.

Returns
the inverse matrix

Definition at line 450 of file Matrix4x4.inl.

◆ getTranspose()

template<typename T >
Matrix4x4< T > gVirtualXRay::Matrix4x4< T >::getTranspose ( ) const

Get the transpose of the current matrix.

Returns
the transpose matrix

Definition at line 424 of file Matrix4x4.inl.

◆ loadIdentity()

template<typename T >
void gVirtualXRay::Matrix4x4< T >::loadIdentity ( )

Load identity matrix.

Definition at line 151 of file Matrix4x4.inl.

◆ operator*() [1/2]

template<typename T>
Vec3< T > gVirtualXRay::Matrix4x4< T >::operator* ( const Vec3< T > &  aVector) const

Operator * to multiply the current matrix by a vector.

Parameters
aVectorthe vector to transform
Returns
the transformed vector

Definition at line 493 of file Matrix4x4.inl.

◆ operator*() [2/2]

template<typename T>
Matrix4x4< T > gVirtualXRay::Matrix4x4< T >::operator* ( const Matrix4x4< T > &  aMatrix) const

Operator * to multiply the current matrix by another matrix.

Parameters
aMatrixthe other matrix
Returns
the transformed matrix

Definition at line 506 of file Matrix4x4.inl.

◆ operator*=()

template<typename T >
Matrix4x4< T > & gVirtualXRay::Matrix4x4< T >::operator*= ( const Matrix4x4< T > &  aMatrix)

Operator *= to multiply the current matrix by another matrix, and modify the current matrix.

Parameters
aMatrixthe other matrix
Returns
the transformed matrix

Definition at line 536 of file Matrix4x4.inl.

◆ operator=()

template<typename T >
Matrix4x4< T > & gVirtualXRay::Matrix4x4< T >::operator= ( const Matrix4x4< T > &  aMatrix)

Copy operator.

Parameters
aMatrixthe matrix to copy
Returns
the copied matrix

Definition at line 481 of file Matrix4x4.inl.

◆ print() [1/2]

template<typename T >
void gVirtualXRay::Matrix4x4< T >::print ( ) const

Print the matrix in the console.

Definition at line 605 of file Matrix4x4.inl.

◆ print() [2/2]

template<typename T >
void gVirtualXRay::Matrix4x4< T >::print ( std::ostream &  anOutputStream) const

Print the matrix in the console.

Parameters
anOutputStreamthe stream in which the matrix will be printed

Definition at line 613 of file Matrix4x4.inl.

◆ rotate()

template<typename T>
void gVirtualXRay::Matrix4x4< T >::rotate ( const double  anAngle,
const Vec3< T > &  aVector 
)

Multiply the current matrix by a rotation matrix.

Parameters
anAnglethe angle of rotation in degrees
aVectorthe axis of rotation

Definition at line 195 of file Matrix4x4.inl.

◆ scale()

template<typename T>
void gVirtualXRay::Matrix4x4< T >::scale ( x,
y,
z 
)

Multiply the current matrix by a scaling matrix.

Parameters
xthe scaling factor along the X-axis
ythe scaling factor along the Y-axis
zthe scaling factor along the Z-axis

Definition at line 399 of file Matrix4x4.inl.

◆ setFromVector()

template<typename T >
void gVirtualXRay::Matrix4x4< T >::setFromVector ( const std::vector< double > &  apMatrix)

Load the matrix.

Parameters
apMatrixthe matrix to copy

Definition at line 179 of file Matrix4x4.inl.

◆ translate() [1/2]

template<typename T>
void gVirtualXRay::Matrix4x4< T >::translate ( const Vec3< T > &  aVector)

Multiply the current matrix by a translation matrix.

Parameters
aVectorthe translation vector

Definition at line 217 of file Matrix4x4.inl.

◆ translate() [2/2]

template<typename T>
void gVirtualXRay::Matrix4x4< T >::translate ( x,
y,
z 
)

Multiply the current matrix by a translation matrix.

Parameters
xthe x-component of the translation vector
ythe y-component of the translation vector
zthe z-component of the translation vector

Definition at line 227 of file Matrix4x4.inl.

◆ yawPitchRollRotate()

template<typename T >
void gVirtualXRay::Matrix4x4< T >::yawPitchRollRotate ( double  yaw,
double  pitch,
double  roll 
)

Multiply the current matrix by a yaw, pitch, roll rotation matrix.

Parameters
yawa counterclockwise rotation of yaw degrees about the z-axis
pitcha counterclockwise rotation of yaw degrees about the y-axis
rolla counterclockwise rotation of yaw degrees about the x-axis

Definition at line 205 of file Matrix4x4.inl.

Field Documentation

◆ m_p_3x3_data

template<typename T>
T gVirtualXRay::Matrix4x4< T >::m_p_3x3_data[3 *3]
protected

the matrix data

Definition at line 468 of file Matrix4x4.h.

◆ m_p_4x4_data

template<typename T>
T gVirtualXRay::Matrix4x4< T >::m_p_4x4_data[4 *4]
protected

the matrix data

Definition at line 464 of file Matrix4x4.h.

◆ m_small_matrix_up_to_date

template<typename T>
bool gVirtualXRay::Matrix4x4< T >::m_small_matrix_up_to_date
protected

A flag to check if the 3x3 matrix is up-to-date. It is used for lazy evaluation.

Definition at line 473 of file Matrix4x4.h.


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