OpenVSP API Documentation 3.41.0
 
Loading...
Searching...
No Matches
Matrix4d Class Reference

#include <Matrix4d.h>

Public Member Functions

void loadIdentity ()
 
void translatef (const double &x, const double &y, const double &z)
 
void translatev (const vec3d &v)
 
void rotateX (const double &ang)
 
void rotateY (const double &ang)
 
void rotateZ (const double &ang)
 
void rotate (const double &angle, const vec3d &axis)
 
void rotatealongX (const vec3d &dir1)
 
void zeroTranslations ()
 
void affineInverse ()
 
void scale (const double &scale)
 
void scalex (const double &scalex)
 
void scaley (const double &scaley)
 
void scalez (const double &scalez)
 
void flipx ()
 
void getMat (double *m) const
 
void matMult (const double *m)
 
void postMult (const double *m)
 
void matMult (const Matrix4d &m)
 
void postMult (const Matrix4d &m)
 
void initMat (const double *m)
 
void initMat (const Matrix4d &m)
 
void mult (const double in[4], double out[4]) const
 
double * data ()
 
void loadXZRef ()
 
void loadXYRef ()
 
void loadYZRef ()
 
vec3d xform (const vec3d &in) const
 
void xformvec (std::vector< vec3d > &in) const
 
void xformmat (std::vector< std::vector< vec3d > > &in) const
 
vec3d xformnorm (const vec3d &in) const
 
void xformnormvec (std::vector< vec3d > &in) const
 
void xformnormmat (std::vector< std::vector< vec3d > > &in) const
 
vec3d getAngles () const
 
vec3d getTranslation () const
 
void buildXForm (const vec3d &pos, const vec3d &rot, const vec3d &cent_rot)
 
void getBasis (vec3d &xdir, vec3d &ydir, vec3d &zdir)
 
void setBasis (const vec3d &xdir, const vec3d &ydir, const vec3d &zdir)
 
void toQuat (double &qw, double &qx, double &qy, double &qz, double &tx, double &ty, double &tz) const
 

Static Public Member Functions

static void setIdentity (double *m)
 

Private Attributes

double mat [16]
 

Detailed Description

Matrix4d is typically used to perform rotations, translations, scaling, projections, and other transformations in 3D space.

Definition at line 19 of file Matrix4d.h.

Member Function Documentation

◆ affineInverse()

void Matrix4d::affineInverse ( )

Perform an affine transform on the Matrix4d

//==== Test Matrix4d ====//
Matrix4d m(); // Default Constructor
m.loadIdentity();
m.rotateY( 10.0 );
m.rotateX( 20.0 );
m.rotateZ( 30.0 );
vec3d c = m.xform( vec3d( 1.0, 1.0, 1.0 ) );
m.affineInverse();
Definition Vec3d.h:235

◆ buildXForm()

void Matrix4d::buildXForm ( const vec3d & pos,
const vec3d & rot,
const vec3d & cent_rot )

Translate the Matrix4d to a given position and rotate it a about a given center of rotation

Parameters
[in]posPosition to translate to
[in]rotAngle of rotation (degrees)
[in]cent_rotCenter of rotation

◆ data()

double * Matrix4d::data ( )
inline

Definition at line 284 of file Matrix4d.h.

◆ getAngles()

vec3d Matrix4d::getAngles ( ) const

Calculate the Matrix4d's angles between the X, Y and Z axes

float PI = 3.14;
m.rotate( PI / 4, vec3d( 0.0, 0.0, 1.0 ) ); // Radians
vec3d angles = mat.getAngles();
vec3d getAngles() const
void loadIdentity()
Returns
Angle measurement between each axis (degrees)

◆ loadIdentity()

void Matrix4d::loadIdentity ( )

Create a 4x4 identity matrix

//==== Test Matrix4d ====//
Matrix4d m(); // Default Constructor
m.loadIdentity();
Returns
Identity Matrix4d

◆ loadXYRef()

void Matrix4d::loadXYRef ( )

Load an identy Matrix4d and set the Z coordinate of the diagonal (index 10) to -1

//==== Test Matrix4d ====//
Matrix4d m(); // Default Constructor
m.loadXYRef();
vec3d b = m.xform( vec3d( 1, 2, 3 ) );

◆ loadXZRef()

void Matrix4d::loadXZRef ( )

Load an identy Matrix4d and set the Y coordinate of the diagonal (index 5) to -1

//==== Test Matrix4d ====//
Matrix4d m(); // Default Constructor
m.loadXZRef();
vec3d b = m.xform( vec3d( 1, 2, 3 ) );

◆ loadYZRef()

void Matrix4d::loadYZRef ( )

Load an identy Matrix4d and set the X coordinate of the diagonal (index 0) to -1

//==== Test Matrix4d ====//
Matrix4d m(); // Default Constructor
m.loadYZRef();
vec3d b = m.xform( vec3d( 1, 2, 3 ) );

◆ rotate()

void Matrix4d::rotate ( const double & angle,
const vec3d & axis )

Rotate the Matrix4d about an arbitrary axis

//==== Test Matrix4d ====//
Matrix4d m(); // Default Constructor
float PI = 3.14;
m.loadIdentity();
m.rotate( PI / 4, vec3d( 0.0, 0.0, 1.0 ) ); // Radians
Parameters
[in]angAngle of rotation (rad)
[in]axisVector to rotate about

◆ rotateX()

void Matrix4d::rotateX ( const double & ang)

Rotate the Matrix4d about the X axis

//==== Test Matrix4d ====//
Matrix4d m(); // Default Constructor
m.loadIdentity();
m.rotateX( 90.0 );
Parameters
[in]angAngle of rotation (degrees)

◆ rotateY()

void Matrix4d::rotateY ( const double & ang)

Rotate the Matrix4d about the Y axis

//==== Test Matrix4d ====//
Matrix4d m(); // Default Constructor
m.loadIdentity();
m.rotateY( 90.0 );
Parameters
[in]angAngle of rotation (degrees)

◆ rotateZ()

void Matrix4d::rotateZ ( const double & ang)

Rotate the Matrix4d about the Z axis

//==== Test Matrix4d ====//
Matrix4d m(); // Default Constructor
m.loadIdentity();
m.rotateZ( 90.0 );
Parameters
[in]angAngle of rotation (degrees)

◆ scale()

void Matrix4d::scale ( const double & scale)

Multiply the Matrix4d by a scalar value

//==== Test Matrix4d ====//
Matrix4d m(); // Default Constructor
m.loadXZRef();
m.scale( 10.0 );
Parameters
[in]scaleValue to scale by

◆ translatef()

void Matrix4d::translatef ( const double & x,
const double & y,
const double & z )

Translate the Matrix4d along the given axes values

//==== Test Matrix4d ====//
Matrix4d m(); // Default Constructor
m.loadIdentity();
m.translatef( 1.0, 0.0, 0.0 );
Parameters
[in]xTranslation along the X axis
[in]yTranslation along the Y axis
[in]zTranslation along the Z axis
Returns
Translated Matrix4d

◆ xform()

vec3d Matrix4d::xform ( const vec3d & in) const

Transform the Matrix4d by the given vector

//==== Test Matrix4d ====//
Matrix4d m(); // Default Constructor
m.loadIdentity();
vec3d a = m.xform( vec3d( 1.0, 2.0, 3.0 ) );
Parameters
[in]vTransformation vector

Member Data Documentation

◆ mat

double Matrix4d::mat[16]
private

Definition at line 456 of file Matrix4d.h.


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