molecular
Public Member Functions | Static Public Member Functions | List of all members
molecular::util::Matrix4 Class Reference

A 4x4 matrix. More...

#include <Matrix4.h>

Inheritance diagram for molecular::util::Matrix4:
molecular::util::Matrix< 4, 4 >

Public Member Functions

 Matrix4 ()
 Construct identity matrix. More...
 
 Matrix4 (const float values[16])
 Construct from array. More...
 
 Matrix4 (const Matrix< 4, 4 > &mat)
 Construct from base class. More...
 
 Matrix4 (const Matrix< 3, 4 > &mat)
 Construct from 3x4 matrix. More...
 
 Matrix4 (const Matrix< 3, 3 > &mat)
 Construct from 3x3 matrix. More...
 
 Matrix4 (float m00, float m10, float m20, float m30, float m01, float m11, float m21, float m31, float m02, float m12, float m22, float m32, float m03, float m13, float m23, float m33)
 Construct from individual components. More...
 
Vector4 operator* (const Vector4 &v) const
 
Vector3 GetTranslation () const
 Extract translation. More...
 
Matrix3 GetUpperLeft3x3 () const
 Extract upper left 3x3 matrix. More...
 
Vector4 GetRow (int row) const
 Get row of matrix. More...
 
- Public Member Functions inherited from molecular::util::Matrix< 4, 4 >
 Matrix ()=default
 Default constructor. More...
 
 Matrix (const floatvalues[rows *cols])
 Construct matrix from an array in row-major order. More...
 
 Matrix (const floatvalues[rows][cols])
 Construct matrix from two-dimensional array. More...
 
 Matrix (std::initializer_list< float > init)
 
 Matrix (const Eigen::MatrixBase< OtherDerived > &other)
 Construct from Eigen expression. More...
 
Matrixoperator= (const Eigen::MatrixBase< OtherDerived > &other)
 Assign from Eigen expression. More...
 
const float * Get () const
 Returns array of matrix elements in row-major order. More...
 
float * operator[] (int row)
 
const float * operator[] (int row) const
 
float operator() (int row, int col) const
 
float & operator() (int row, int col)
 
auto ToEigen ()
 
auto ToEigen () const
 
Matrix< rows, M::kCols, float > operator* (const M &mat) const
 Matrix-matrix multiplication. More...
 
Matrix operator* (ValueType s) const
 Matrix-scalar multiplication. More...
 
Matrix operator+ (const Matrix &mat) const
 
Matrixoperator+= (const Matrix &mat)
 
Matrixoperator*= (const Matrix &mat)
 
Matrixoperator*= (ValueType s)
 
Matrixoperator/= (ValueType s)
 
void SetIdentity ()
 
Matrix< M::kRows, M::kCols+cols, float > Augmented (const M &mat) const
 Returns the matrix with mat concatenated to the right side. More...
 
Matrix< rows, newcols, float > SubMatrixRight () const
 Returns the right portion of the matrix with the given width. More...
 
Matrix< rows, newcols, float > SubMatrixLeft () const
 Returns the left portion of the matrix with the given width. More...
 
void Print () const
 
Matrix< rows, cols, float > Inverse () const
 Returns the inverse of the matrix. More...
 
Matrix< cols, rows, float > Transposed () const
 Returns the transposed of the matrix. More...
 
float Trace () const
 Returns the sum of the diagonal elements. More...
 

Static Public Member Functions

static Matrix4 ProjectionPerspective (float fieldOfView, float aspectRatio, float near, float far)
 Create perspective projection matrix. More...
 
static Matrix4 ProjectionOrthographic (float width, float height, float nearPlane, float farPlane)
 Create orthographic projection matrix. More...
 
static Matrix4 RotationX (float a)
 Create transform matrix representing a rotation around X. More...
 
static Matrix4 RotationY (float a)
 Create transform matrix representing a rotation around Y. More...
 
static Matrix4 RotationZ (float a)
 Create transform matrix representing a rotation around Z. More...
 
static Matrix4 Translation (float x, float y, float z)
 Create transform matrix representing a translation. More...
 
static Matrix4 Translation (const Vector3 &xyz)
 Create transform matrix representing a translation. More...
 
static Matrix4 Scale (float x, float y, float z)
 Create transform matrix representing a scale operation. More...
 
static Matrix4 Scale (float xyz)
 Create transform matrix representing a scale operation. More...
 
- Static Public Member Functions inherited from molecular::util::Matrix< 4, 4 >
static Matrix Identity ()
 
static Matrix Zeros ()
 

Additional Inherited Members

- Public Types inherited from molecular::util::Matrix< 4, 4 >
using ValueType = float
 
- Static Public Attributes inherited from molecular::util::Matrix< 4, 4 >
static const int kRows
 
static const int kCols
 
- Protected Attributes inherited from molecular::util::Matrix< 4, 4 >
float m [rows][cols]
 

Detailed Description

A 4x4 matrix.

Specialized type used for 3D transformations.

Constructor & Destructor Documentation

molecular::util::Matrix4::Matrix4 ( )
inline

Construct identity matrix.

molecular::util::Matrix4::Matrix4 ( const float  values[16])
inline

Construct from array.

Intentionally not explicit.

molecular::util::Matrix4::Matrix4 ( const Matrix< 4, 4 > &  mat)
inline

Construct from base class.

Intentionally not explicit.

molecular::util::Matrix4::Matrix4 ( const Matrix< 3, 4 > &  mat)
inline

Construct from 3x4 matrix.

Rest is filled with identity. Intentionally not explicit.

molecular::util::Matrix4::Matrix4 ( const Matrix< 3, 3 > &  mat)
inline

Construct from 3x3 matrix.

Rest is filled with identity. Intentionally not explicit.

molecular::util::Matrix4::Matrix4 ( float  m00,
float  m10,
float  m20,
float  m30,
float  m01,
float  m11,
float  m21,
float  m31,
float  m02,
float  m12,
float  m22,
float  m32,
float  m03,
float  m13,
float  m23,
float  m33 
)
inline

Construct from individual components.

Column-major ordering.

Member Function Documentation

Vector4 molecular::util::Matrix4::GetRow ( int  row) const
inline

Get row of matrix.

Parameters
rowRow to get. Must be between 0 and 3.
Vector3 molecular::util::Matrix4::GetTranslation ( ) const
inline

Extract translation.

Matrix3 molecular::util::Matrix4::GetUpperLeft3x3 ( ) const
inline

Extract upper left 3x3 matrix.

Contains rotation and scale.

Vector4 molecular::util::Matrix4::operator* ( const Vector4 v) const
inline
Matrix4 molecular::util::Matrix4::ProjectionOrthographic ( float  width,
float  height,
float  nearPlane,
float  farPlane 
)
inlinestatic

Create orthographic projection matrix.

Matrix4 molecular::util::Matrix4::ProjectionPerspective ( float  fieldOfView,
float  aspectRatio,
float  near,
float  far 
)
inlinestatic

Create perspective projection matrix.

Matrix4 molecular::util::Matrix4::RotationX ( float  a)
inlinestatic

Create transform matrix representing a rotation around X.

Matrix4 molecular::util::Matrix4::RotationY ( float  a)
inlinestatic

Create transform matrix representing a rotation around Y.

Matrix4 molecular::util::Matrix4::RotationZ ( float  a)
inlinestatic

Create transform matrix representing a rotation around Z.

Matrix4 molecular::util::Matrix4::Scale ( float  x,
float  y,
float  z 
)
inlinestatic

Create transform matrix representing a scale operation.

With individual scale factors for X, Y and Z.

static Matrix4 molecular::util::Matrix4::Scale ( float  xyz)
inlinestatic

Create transform matrix representing a scale operation.

With single scale factor for X, Y and Z.

Matrix4 molecular::util::Matrix4::Translation ( float  x,
float  y,
float  z 
)
inlinestatic

Create transform matrix representing a translation.

static Matrix4 molecular::util::Matrix4::Translation ( const Vector3 xyz)
inlinestatic

Create transform matrix representing a translation.


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