Code_TYMPAN  4.4.0
Industrial site acoustic simulation
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
OMatrix Class Reference

The 4x4 matrix class. More...

#include <3d.h>

Public Member Functions

 OMatrix ()
 Default constructor. More...
 
 OMatrix (const OMatrix &matrix)
 Copy constructor. More...
 
 OMatrix (double matrix[4][4])
 
virtual ~OMatrix ()
 Destructor. More...
 
OMatrixoperator= (const OMatrix &matrix)
 operators More...
 
bool operator== (const OMatrix &matrix) const
 
bool operator!= (const OMatrix &matrix) const
 
OMatrix operator+ (const OMatrix &matrix) const
 
OMatrix operator- (const OMatrix &matrix) const
 
OMatrix operator* (const OMatrix &matrix) const
 
OVector3D multNormal (const OVector3D &normal) const
 Multiplication with a normal (the translation is removed). More...
 
void show ()
 Print a matrix (debug). More...
 
void reset ()
 Set the matrix elements to zero. More...
 
void unite ()
 Initialize the matrix to the identity matrix. More...
 
int setTranslation (double x, double y, double z)
 Update a translation matrix. More...
 
int setScale (double x, double y, double z)
 Update a zoom matrix. More...
 
int setRotationOx (double a)
 Update a rotation matrix (Ox axis). More...
 
int setRotationOy (double a)
 Update a rotation matrix (Oy axis). More...
 
int setRotationOz (double a)
 Update a rotation matrix (Oz axis). More...
 
int aligneVecteurSurOx (const OVector3D &vector)
 Mise a jour d'une matrice d'alignement d'un vecteur quelconque avec l'axe des x. More...
 
int aligneVecteurSurOy (const OVector3D &vector)
 Mise a jour d'une matrice d'alignement d'un vecteur quelconque avec l'axe des y. More...
 
int invert ()
 Matrix inversion. More...
 
OMatrix getInvert (int *ok=0) const
 Return the inverse matrix of this matrix. More...
 
void adjoint ()
 Calculate the adjoint matrix from this matrix. More...
 
OMatrix getAdjoint ()
 Return the adjoint matrix. More...
 
double determinant ()
 Compute the matrix determinant. More...
 
OCoord3D dot (const OCoord3D &coord) const
 Multiplication with a 3D coordinate. More...
 
OCoord3D scale (const OCoord3D &coord) const
 

Static Public Member Functions

static double mat2x2Det (double a, double b, double c, double d)
 Compute a 2 x 2 matrix determinant. More...
 
static double mat3x3Det (double a1, double a2, double a3, double b1, double b2, double b3, double c1, double c2, double c3)
 Compute a 3 x 3 matrix determinant. More...
 

Public Attributes

double _m [4][4]
 The 4x4 matrix array. More...
 

Detailed Description

The 4x4 matrix class.

Definition at line 624 of file 3d.h.

Constructor & Destructor Documentation

◆ OMatrix() [1/3]

OMatrix::OMatrix ( )

Default constructor.

Definition at line 439 of file 3d.cpp.

Here is the call graph for this function:

◆ OMatrix() [2/3]

OMatrix::OMatrix ( const OMatrix matrix)

Copy constructor.

Definition at line 444 of file 3d.cpp.

◆ OMatrix() [3/3]

OMatrix::OMatrix ( double  matrix[4][4])

Definition at line 449 of file 3d.cpp.

◆ ~OMatrix()

OMatrix::~OMatrix ( )
virtual

Destructor.

Definition at line 461 of file 3d.cpp.

Member Function Documentation

◆ adjoint()

void OMatrix::adjoint ( )

Calculate the adjoint matrix from this matrix.

Remarque : Algorithm by Richard Carling, from Graphic Gems I.

Principe :

   Calculate the adjoint of a 4x4 matrix:
     Let  a   denotes the minor determinant of matrix A obtained by
          ij

     deleting the ith row and jth column from A.

                   i+j
    Let  b   = (-1)    a
         ij            ji

   The matrix B = (b  ) is the adjoint of A.
                    ij

Definition at line 824 of file 3d.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ aligneVecteurSurOx()

int OMatrix::aligneVecteurSurOx ( const OVector3D vector)

Mise a jour d'une matrice d'alignement d'un vecteur quelconque avec l'axe des x.

Remarque :

  • En raison d'erreur d'arrondi, le fonctionnement de cette fonction peut etre perturbe dans le cas de vecteur enorme.

Principe :

  • Rotation de V autour de Oz pour le placer dans le plan xOz == rotation de -a1 avec a1 = angle entre Ox et la projection de V dans le plan xOy sin(a1) = Vy/sqrt(Vx**2+Vy**2) cos(a1) = Vx/sqrt(Vx**2+Vy**2) => M1 = cos1 sin1 0 0 -sin1 cos1 0 0 0 0 1 0 0 0 0 1

    => on obtient V1

  • Rotation de V1 autour de Oy afin de l'aligner avec Ox == rotation de -a2 avec a2 = angle entre Ox et V1 sin(a2) = Vz/sqrt(Vx**2+Vy**2+Vz**2) cos(a2) = sqrt(Vx**2+Vy**2)/sqrt(Vx**2+Vy**2+Vz**2) => M2 = cos2 0 sin2 0 0 1 0 0 -sin2 0 cos2 0 0 0 0 1
  • Traiter le cas particulier de sqrt(Vx**2+Vy**2) = 0 Cas ou V est // a Oz == rotation de +-PI/2 autour de Oy et donc a1 = 0 ety a2 = +-PI/2
  • Calcul de la matrice finale : M = M2 . M1

Definition at line 700 of file 3d.cpp.

Here is the call graph for this function:

◆ aligneVecteurSurOy()

int OMatrix::aligneVecteurSurOy ( const OVector3D vector)

Mise a jour d'une matrice d'alignement d'un vecteur quelconque avec l'axe des y.

Remarque :

  • En raison d'erreur d'arrondi, le fonctionnement de cette fonction peut etre perturbe dans le cas de vecteur enorme.

Principe :

  • Rotation de V autour de Oz pour le placer dans le plan yOz == rotation de a1 avec a1 = angle entre Oy et la projection de V dans le plan xOy sin(a1) = Vx/sqrt(Vx**2+Vy**2) cos(a1) = Vy/sqrt(Vx**2+Vy**2) => M1 = cos1 -sin1 0 0 sin1 cos1 0 0 0 0 1 0 0 0 0 1

    => on obtient V1

  • Rotation de V1 autour de Ox afin de l'aligner avec Oy == rotation de -a2 avec a2 = angle entre Oy et V1 sin(a2) = Vz/sqrt(Vx**2+Vy**2+Vz**2) cos(a2) = sqrt(Vx**2+Vy**2)/sqrt(Vx**2+Vy**2+Vz**2) => M2 = 1 0 0 0 0 cos2 sin2 0 0 -sin2 cos2 0 0 0 0 1
  • Traiter le cas particulier de sqrt(Vx**2+Vy**2) = 0 Cas ou V est // a Oz == rotation de +-PI/2 autour de Ox et donc a1 = 0 ety a2 = +-PI/2
  • Calcul de la matrice finale : M = M2 . M1

Definition at line 743 of file 3d.cpp.

Here is the call graph for this function:

◆ determinant()

double OMatrix::determinant ( )

Compute the matrix determinant.

Note : Algorithm from Richard Carling, extracted from Graphic Gems I.

Definition at line 873 of file 3d.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ dot()

OCoord3D OMatrix::dot ( const OCoord3D coord) const

Multiplication with a 3D coordinate.

Parameters
coordThe reference object with which this matrix is multiplied.

Definition at line 545 of file 3d.cpp.

Here is the caller graph for this function:

◆ getAdjoint()

OMatrix OMatrix::getAdjoint ( )

Return the adjoint matrix.

See also
adjoint()

Definition at line 865 of file 3d.cpp.

Here is the call graph for this function:

◆ getInvert()

OMatrix OMatrix::getInvert ( int *  ok = 0) const

Return the inverse matrix of this matrix.

See also
invert()
Parameters
okFlag to indicate if the inversion was a success (1) or not (0).

Definition at line 813 of file 3d.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ invert()

int OMatrix::invert ( )

Matrix inversion.

Note : Algorithm by Richard Carling, from Graphic Gems I.

Principle :

      -1
     A  = ___1__ adjoint A
           det A
Returns
Indicate if the inversion succeeds or not (0 or 1).

Definition at line 792 of file 3d.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mat2x2Det()

static double OMatrix::mat2x2Det ( double  a,
double  b,
double  c,
double  d 
)
static

Compute a 2 x 2 matrix determinant.

Definition at line 901 of file 3d.cpp.

Here is the caller graph for this function:

◆ mat3x3Det()

static double OMatrix::mat3x3Det ( double  a1,
double  a2,
double  a3,
double  b1,
double  b2,
double  b3,
double  c1,
double  c2,
double  c3 
)
static

Compute a 3 x 3 matrix determinant.

Definition at line 906 of file 3d.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ multNormal()

OVector3D OMatrix::multNormal ( const OVector3D normal) const

Multiplication with a normal (the translation is removed).

Parameters
normalThe normal vector with which this object is multiplied.

Definition at line 585 of file 3d.cpp.

Here is the call graph for this function:

◆ operator!=()

bool OMatrix::operator!= ( const OMatrix matrix) const

Definition at line 496 of file 3d.cpp.

Here is the call graph for this function:

◆ operator*()

OMatrix OMatrix::operator* ( const OMatrix matrix) const

Definition at line 527 of file 3d.cpp.

◆ operator+()

OMatrix OMatrix::operator+ ( const OMatrix matrix) const

Definition at line 501 of file 3d.cpp.

◆ operator-()

OMatrix OMatrix::operator- ( const OMatrix matrix) const

Definition at line 514 of file 3d.cpp.

◆ operator=()

OMatrix & OMatrix::operator= ( const OMatrix matrix)

operators

Definition at line 463 of file 3d.cpp.

◆ operator==()

bool OMatrix::operator== ( const OMatrix matrix) const

Definition at line 478 of file 3d.cpp.

Here is the caller graph for this function:

◆ reset()

void OMatrix::reset ( )

Set the matrix elements to zero.

 0   0   0   0
 0   0   0   0
 0   0   0   0
 0   0   0   0

Definition at line 622 of file 3d.cpp.

◆ scale()

OCoord3D OMatrix::scale ( const OCoord3D coord) const

Definition at line 554 of file 3d.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setRotationOx()

int OMatrix::setRotationOx ( double  a)

Update a rotation matrix (Ox axis).

 1   0   0    0
 0   cos -sin 0
 0   sin cos  0
 0   0   0    1

Definition at line 664 of file 3d.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setRotationOy()

int OMatrix::setRotationOy ( double  a)

Update a rotation matrix (Oy axis).

 cos  0  sin 0
 0    1  0   0
 -sin 0  cos 0
 0    0  0   1

Definition at line 676 of file 3d.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setRotationOz()

int OMatrix::setRotationOz ( double  a)

Update a rotation matrix (Oz axis).

 cos -sin 0  0
 sin cos  0  0
 0   0    1  0
 0   0    0  1

Definition at line 688 of file 3d.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setScale()

int OMatrix::setScale ( double  x,
double  y,
double  z 
)

Update a zoom matrix.

Zoom Z(x, y, z) :

 x   0   0   0
 0   y   0   0
 0   0   z   0
 0   0   0   1

Definition at line 655 of file 3d.cpp.

Here is the call graph for this function:

◆ setTranslation()

int OMatrix::setTranslation ( double  x,
double  y,
double  z 
)

Update a translation matrix.

Translation T(x, y, z) :

 1   0   0   x
 0   1   0   y
 0   0   1   z
 0   0   0   1

Definition at line 646 of file 3d.cpp.

Here is the call graph for this function:

◆ show()

void OMatrix::show ( )

Print a matrix (debug).

Definition at line 609 of file 3d.cpp.

◆ unite()

void OMatrix::unite ( )

Initialize the matrix to the identity matrix.

 1   0   0   0
 0   1   0   0
 0   0   1   0
 0   0   0   1

Definition at line 634 of file 3d.cpp.

Here is the caller graph for this function:

Member Data Documentation

◆ _m

double OMatrix::_m[4][4]

The 4x4 matrix array.

Definition at line 922 of file 3d.h.


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