OpenVSPAPI  3.21.1 Matrix4d Class Reference

A class for representing 4x4 matricies. More...

#include <openvsp_as.h>

## Public Member Functions

void translatef (const double &in x, const double &in y, const double &in z)

void rotateX (const double &in ang)

void rotateY (const double &in ang)

void rotateZ (const double &in ang)

void rotate (const double &in ang, const vec3d &in axis)

void scale (const double &in scale)

vec3d xform (const vec3d &in v)

vec3d getAngles ()

void affineInverse ()

void buildXForm (const vec3d &in pos, const vec3d &in rot, const vec3d &in cent_rot)

## Detailed Description

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

Definition at line 789 of file openvsp_as.h.

## ◆ affineInverse()

 void Matrix4d::affineInverse ( )

Perform an affine transform on the Matrix4d

//==== Test Matrix4d ====//
Matrix4d m(); // Default Constructor
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();

## ◆ buildXForm()

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

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

Parameters
 [in] pos Position to translate to [in] rot Angle of rotation (degrees) [in] cent_rot Center of rotation

## ◆ getAngles()

 vec3d Matrix4d::getAngles ( )

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

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

Create a 4x4 indentity matrix

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

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

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

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

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

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

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

## ◆ rotate()

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

Rotate the Matrix4d about an arbitrary axis

//==== Test Matrix4d ====//
Matrix4d m(); // Default Constructor
m.rotate( PI / 4, vec3d( 0.0, 0.0, 1.0 ) ); // Radians
Parameters
 [in] ang Angle of rotation (rad) [in] axis Vector to rotate about

## ◆ rotateX()

 void Matrix4d::rotateX ( const double &in ang )

Rotate the Matrix4d about the X axis

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

## ◆ rotateY()

 void Matrix4d::rotateY ( const double &in ang )

Rotate the Matrix4d about the Y axis

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

## ◆ rotateZ()

 void Matrix4d::rotateZ ( const double &in ang )

Rotate the Matrix4d about the Z axis

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

## ◆ scale()

 void Matrix4d::scale ( const double &in scale )

Multiply the Matrix4d by a scalar value

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

## ◆ translatef()

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

Translate the Matrix4d along the given axes values

//==== Test Matrix4d ====//
Matrix4d m(); // Default Constructor
m.translatef( 1.0, 0.0, 0.0 );
Parameters
 [in] x Translation along the X axis [in] y Translation along the Y axis [in] z Translation along the Z axis
Returns
Translated Matrix4d

## ◆ xform()

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

Transform the Matrix4d by the given vector

//==== Test Matrix4d ====//
Matrix4d m(); // Default Constructor