OpenVSP API Documentation 3.52.0
Loading...
Searching...
No Matches
Matrix4d Functions

API functions that utilize the Matrix4d class are grouped here. For details of the class, including member functions, see Matrix4d. Click here to return to the main page. More...

Classes

class  Matrix4d

Functions

void Matrix4d::loadIdentity ()
void Matrix4d::translatef (const double &x, const double &y, const double &z)
void Matrix4d::translatev (const vec3d &v)
void Matrix4d::rotateX (const double &ang)
void Matrix4d::rotateY (const double &ang)
void Matrix4d::rotateZ (const double &ang)
void Matrix4d::rotate (const double &angle, const vec3d &axis)
void Matrix4d::rotatealongX (const vec3d &dir1)
void Matrix4d::zeroTranslations ()
void Matrix4d::affineInverse ()
void Matrix4d::scale (const double &scale)
void Matrix4d::scalex (const double &scalex)
void Matrix4d::scaley (const double &scaley)
void Matrix4d::scalez (const double &scalez)
void Matrix4d::flipx ()
void Matrix4d::matMult (const Matrix4d &m)
void Matrix4d::postMult (const Matrix4d &m)
void Matrix4d::initMat (const Matrix4d &m)
void Matrix4d::loadXZRef ()
void Matrix4d::loadXYRef ()
void Matrix4d::loadYZRef ()
void Matrix4d::mirrory ()
vec3d Matrix4d::xform (const vec3d &in) const
void Matrix4d::xformvec (std::vector< vec3d > &in) const
void Matrix4d::xformmat (std::vector< std::vector< vec3d > > &in) const
vec3d Matrix4d::xformnorm (const vec3d &in) const
void Matrix4d::xformnormvec (std::vector< vec3d > &in) const
void Matrix4d::xformnormmat (std::vector< std::vector< vec3d > > &in) const
vec3d Matrix4d::getAngles () const
vec3d Matrix4d::getArcballAngles () const
vec3d Matrix4d::getTranslation () const
void Matrix4d::buildXForm (const vec3d &pos, const vec3d &rot, const vec3d &cent_rot)
void Matrix4d::getBasis (vec3d &xdir, vec3d &ydir, vec3d &zdir) const
void Matrix4d::setBasis (const vec3d &xdir, const vec3d &ydir, const vec3d &zdir)
void Matrix4d::getRotationAxis (vec3d &axis_dir, vec3d &axis_pnt, double &angle_out) const
void Matrix4d::toQuat (double &qw_out, double &qx_out, double &qy_out, double &qz_out, double &tx_out, double &ty_out, double &tz_out) const

Detailed Description


Class Documentation

◆ Matrix4d

class Matrix4d

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

Definition at line 22 of file Matrix4d.h.

Public Member Functions

void loadIdentity ()
void print (const std::string &header="")
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 ()
const double * const_data () const
void loadXZRef ()
void loadXYRef ()
void loadYZRef ()
void mirrory ()
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 getArcballAngles () const
vec3d getTranslation () const
void buildXForm (const vec3d &pos, const vec3d &rot, const vec3d &cent_rot)
void getBasis (vec3d &xdir, vec3d &ydir, vec3d &zdir) const
void setBasis (const vec3d &xdir, const vec3d &ydir, const vec3d &zdir)
void getRotationAxis (vec3d &axis_dir, vec3d &axis_pnt, double &angle_out) const
void toQuat (double &qw_out, double &qx_out, double &qy_out, double &qz_out, double &tx_out, double &ty_out, double &tz_out) const

Static Public Member Functions

static void setIdentity (double *m)

Private Attributes

double mat [16]

Member Function Documentation

◆ const_data()

const double * Matrix4d::const_data ( ) const
inline

Definition at line 590 of file Matrix4d.h.

◆ data()

double * Matrix4d::data ( )
inline

Definition at line 585 of file Matrix4d.h.

Member Data Documentation

◆ mat

double Matrix4d::mat[16]
private

Definition at line 1134 of file Matrix4d.h.

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:238

◆ 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

Matrix4d m;
m.buildXForm( vec3d( 1.0, 0.0, 0.0 ), vec3d( 0.0, 0.0, 90.0 ), vec3d( 0.0, 0.0, 0.0 ) );
vec3d p = m.xform( vec3d( 1.0, 0.0, 0.0 ) );
if ( abs( p.y() - 1.0 ) > 1e-9 ) { Print( "ERROR: buildXForm" ); __failure++; }
if ( abs( p.x() - 1.0 ) > 1e-9 ) { Print( "ERROR: buildXForm" ); __failure++; }
vec3d xform(const vec3d &in) const
void buildXForm(const vec3d &pos, const vec3d &rot, const vec3d &cent_rot)
void loadIdentity()
double y() const
Definition Vec3d.h:563
double x() const
Definition Vec3d.h:531
See also
translatev, rotate
Parameters
[in]posPosition to translate to
[in]rotAngle of rotation (degrees)
[in]cent_rotCenter of rotation

◆ flipx()

void Matrix4d::flipx ( )

Flip the matrix about the YZ plane, negating X.

See also
loadYZRef

◆ getAngles()

vec3d Matrix4d::getAngles ( ) const

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

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

◆ getArcballAngles()

vec3d Matrix4d::getArcballAngles ( ) const

Get the rotation as the arcball angles the GUI trackball uses.

See also
getAngles
Returns
vec3d Arcball angles

◆ getBasis()

void Matrix4d::getBasis ( vec3d & xdir,
vec3d & ydir,
vec3d & zdir ) const

Get the three axis directions of the matrix. The vec3d passed in are filled in rather than returned.

See also
setBasis
Parameters
[out]xdirvec3d X axis direction
[out]ydirvec3d Y axis direction
[out]zdirvec3d Z axis direction

◆ getRotationAxis()

void Matrix4d::getRotationAxis ( vec3d & axis_dir,
vec3d & axis_pnt,
double & angle_out ) const

Reduce the matrix to a single rotation about an axis: the direction of the axis, a point on it, and the angle turned through in radians.

See also
toQuat, getAngles
Parameters
[out]axis_dirvec3d Direction of the rotation axis
[out]axis_pntvec3d A point on the rotation axis
[out]angle_outdouble Angle turned through, in radians

◆ getTranslation()

vec3d Matrix4d::getTranslation ( ) const

Get the translation part of the matrix.

See also
translatev, zeroTranslations
Returns
vec3d Translation

◆ initMat()

void Matrix4d::initMat ( const Matrix4d & m)

Copy another matrix into this one, replacing whatever was here.

See also
matMult, postMult
Parameters
[in]mMatrix4d Matrix to copy

◆ loadIdentity()

void Matrix4d::loadIdentity ( )

Create a 4x4 identity matrix

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

◆ 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 ) );

◆ matMult()

void Matrix4d::matMult ( const Matrix4d & m)

Multiply this matrix by another, this * m, and keep the result.

See also
postMult, initMat
Parameters
[in]mMatrix4d Matrix to multiply by

◆ mirrory()

void Matrix4d::mirrory ( )

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 ) );

◆ postMult()

void Matrix4d::postMult ( const Matrix4d & m)

Multiply another matrix by this one, m * this, and keep the result. The other order from matMult.

See also
matMult, initMat
Parameters
[in]mMatrix4d Matrix to multiply by

◆ 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]angleAngle of rotation (rad)
[in]axisVector to rotate about
Here is the call graph for this function:

◆ rotatealongX()

void Matrix4d::rotatealongX ( const vec3d & dir1)

Rotate the matrix so that its X axis points along a given direction.

Parameters
[in]dir1vec3d Direction the X axis should point along

◆ 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
Here is the call graph for this function:
Here is the caller graph for this function:

◆ scalex()

void Matrix4d::scalex ( const double & scalex)

Scale the matrix along X alone. Unlike scale, which scales all three axes together.

See also
scale
Parameters
[in]scalexdouble Scale factor for X
Here is the call graph for this function:
Here is the caller graph for this function:

◆ scaley()

void Matrix4d::scaley ( const double & scaley)

Scale the matrix along Y alone. Unlike scale, which scales all three axes together.

See also
scale
Parameters
[in]scaleydouble Scale factor for Y
Here is the call graph for this function:
Here is the caller graph for this function:

◆ scalez()

void Matrix4d::scalez ( const double & scalez)

Scale the matrix along Z alone. Unlike scale, which scales all three axes together.

See also
scale
Parameters
[in]scalezdouble Scale factor for Z
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setBasis()

void Matrix4d::setBasis ( const vec3d & xdir,
const vec3d & ydir,
const vec3d & zdir )

Set the rotation of the matrix from three axis directions.

See also
getBasis
Parameters
[in]xdirvec3d X axis direction
[in]ydirvec3d Y axis direction
[in]zdirvec3d Z axis direction

◆ toQuat()

void Matrix4d::toQuat ( double & qw_out,
double & qx_out,
double & qy_out,
double & qz_out,
double & tx_out,
double & ty_out,
double & tz_out ) const

Decompose the matrix into a rotation quaternion and a translation.

See also
getRotationAxis
Parameters
[out]qw_outdouble Scalar part of the rotation quaternion
[out]qx_outdouble X part of the rotation quaternion
[out]qy_outdouble Y part of the rotation quaternion
[out]qz_outdouble Z part of the rotation quaternion
[out]tx_outdouble X translation
[out]ty_outdouble Y translation
[out]tz_outdouble Z translation

◆ 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

◆ translatev()

void Matrix4d::translatev ( const vec3d & v)

Translate the matrix by a vec3d. The vec3d counterpart of translatef.

See also
translatef, getTranslation
Parameters
[in]vvec3d Translation to apply

◆ xform()

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

Transform a point by the matrix, applying the rotation, the scaling and the translation.

Matrix4d m;
m.translatef( 1.0, 2.0, 3.0 );
vec3d p = m.xform( vec3d( 0.0, 0.0, 0.0 ) );
if ( abs( p.x() - 1.0 ) > 1e-12 ) { Print( "ERROR: xform" ); __failure++; }
void translatef(const double &x, const double &y, const double &z)
See also
xformnorm, xformvec
Parameters
[in]invec3d Point to transform
Returns
vec3d Transformed point

◆ xformmat()

void Matrix4d::xformmat ( std::vector< std::vector< vec3d > > & in) const

Transform a grid of points by the matrix, in place. The two dimensional counterpart of xformvec.

See also
xformvec
Parameters
[in,out]invector<vector<vec3d>> Grid of points to transform, replaced by the result

◆ xformnorm()

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

Transform a normal vector by the matrix. Unlike xform this leaves the translation out, since a direction has no position.

See also
xform, xformnormvec
Parameters
[in]invec3d Direction to transform
Returns
vec3d Transformed direction

◆ xformnormmat()

void Matrix4d::xformnormmat ( std::vector< std::vector< vec3d > > & in) const

Transform a grid of normals by the matrix, in place. The two dimensional counterpart of xformnormvec.

See also
xformnormvec
Parameters
[in,out]invector<vector<vec3d>> Grid of directions to transform, replaced by the result

◆ xformnormvec()

void Matrix4d::xformnormvec ( std::vector< vec3d > & in) const

Transform a whole vector of normals by the matrix, in place, leaving the translation out.

See also
xformnorm, xformnormmat
Parameters
[in,out]invector<vec3d> Directions to transform, replaced by the result

◆ xformvec()

void Matrix4d::xformvec ( std::vector< vec3d > & in) const

Transform a whole vector of points by the matrix, in place.

See also
xform, xformmat
Parameters
[in,out]invector<vec3d> Points to transform, replaced by the result

◆ zeroTranslations()

void Matrix4d::zeroTranslations ( )

Clear the translation part of the matrix, leaving the rotation and scaling alone.

See also
getTranslation, translatev