Easy3D 2.5.3
Mat3< T > Class Template Reference

3x3 matrix. Extends Mat with 3D-specific functionality and constructors. More...

#include <easy3d/core/mat.h>

Inheritance diagram for Mat3< T >:
Mat< 3, 3, T >

Public Member Functions

 Mat3 ()=default
 Default constructor. More...
 
 Mat3 (T s)
 Initialized with diagonal as s and others zeros.
 
 Mat3 (const Mat< 3, 3, T > &rhs)
 Copy constructor. This provides compatibility with generic operations implemented by Mat.
 
 Mat3 (const Mat< 4, 4, T > &rhs)
 Copies the top-left corner of rhs. This provides compatibility with generic operations implemented by Mat.
 
 Mat3 (T s00, T s01, T s02, T s10, T s11, T s12, T s20, T s21, T s22)
 Initialize elements from individual scalars. The digits following s in the parameter names indicate the row/column of the element being set.
 
 Mat3 (const T *m)
 
 Mat3 (const Vec< 3, T > &x, const Vec< 3, T > &y, const Vec< 3, T > &z)
 Initialize elements from three vectors. If MATRIX_ROW_MAJOR is defined, x, y and z specify rows of the matrix, else columns.
 
 Mat3 (const Mat< 2, 2, T > &rhs)
 
Mat2< T > sub () const
 the upper-left 2x2 sub-matrix.
 
- Public Member Functions inherited from Mat< 3, 3, T >
 Mat ()=default
 Default constructor. More...
 
 Mat (T s)
 Initialized with diagonal as s and others zeros.
 
 Mat (const Mat< rN, rM, T > &rhs)
 Copy constructor for rN >= N, rM >= M. For smaller incoming matrices (i.e, rN < N, rM < M ) specialization is required in order to fill the remaining elements with appropriate values (usually 0 or 1). rN: Number of rows in rhs. rM: Number of columns in rhs. rhs: rN by rM matrix of type T to copy. NOTE: This is explicit to prevent 'accidental' assignment of differently-sized matrices. TODO: Can this ever actually get called? A templated constructor for a templated class seems dodgy!
 
 Mat (const T *m)
 Initialize elements from an array of type T.
 
size_t num_rows () const
 Return the number of rows.
 
size_t num_columns () const
 Return the number of columns.
 
Vec< M, T > row (size_t r) const
 Return row r as a vector.
 
Vec< N, T > col (size_t c) const
 Return col c as a vector.
 
const T & operator() (size_t r, size_t c) const
 Const row/column access to elements.
 
T & operator() (size_t r, size_t c)
 Non-const row/column access to elements.
 
 operator const T * () const
 const array/low-level access to elements.
 
 operator T* ()
 Non-const array/low-level access to elements.
 
void load_zero ()
 Set all elements 0.
 
void load_identity (T s=T(1))
 Set diagonal elements s and others 0.
 
void set_row (size_t r, const Vec< vN, T > &v)
 Set row r from vector v. This copies the first M components from v, so vN must be >= M. vN: Dimension (number of components) of v.
 
void set_col (size_t c, const Vec< vN, T > &v)
 Set col c from vector v. This copies the first N components from v, so vN must be >= N. vN: Dimension (number of components) in v.
 
void swap_rows (size_t a, size_t b)
 Swaps row a with row b.
 
void swap_cols (size_t a, size_t b)
 Swaps col a with col b.
 
bool operator== (const Mat< N, M, T > &rhs) const
 Equality test.
 
bool operator!= (const Mat< N, M, T > &rhs) const
 Inequality test.
 
Mat< N, rM, T > operator* (const Mat< M, rM, T > &rhs) const
 Matrix-matrix multiplication. rhs must have the same number of rows as this matrix has columns. rM: Columns in rhs. return Matrix of dimensions N x rM.
 
Vec< N, T > operator* (const Vec< M, T > &rhs) const
 Matrix-vector multiplication. rhs must have the same number of elements as this matrix has columns. return vec of size N.
 
Mat< N, M, T > operator* (T rhs) const
 Component-wise matrix-scalar multiplication.
 
Mat< N, M, T > operator+ (const Mat< N, M, T > &rhs) const
 Component-wise matrix-matrix addition.
 
Mat< N, M, T > operator- (const Mat< N, M, T > &rhs) const
 Component-wise matrix-matrix subtraction.
 
Mat< N, M, T > operator- () const
 Component-wise matrix negation.
 
Mat< N, M, T > operator/ (T rhs) const
 Component-wise matrix-scalar division.
 
Mat< N, M, T > & operator*= (const Mat< N, M, T > &rhs)
 Matrix-matrix multiplication/assignment.
 
Mat< N, M, T > & operator*= (T rhs)
 Component-wise matrix-scalar multiplication/assignment.
 
Mat< N, M, T > & operator+= (const Mat< N, M, T > &rhs)
 Component-wise matrix-matrix addition/assignment.
 
Mat< N, M, T > & operator+= (T rhs)
 Component-wise matrix-scalar addition/assignment.
 
Mat< N, M, T > & operator-= (const Mat< N, M, T > &rhs)
 Component-wise matrix-matrix subtraction/assignment.
 
Mat< N, M, T > & operator-= (T rhs)
 Component-wise matrix-scalar subtraction/assignment.
 
Mat< N, M, T > & operator/= (T rhs)
 Component-wise matrix-scalar division/assignment.
 

Static Public Member Functions

static Mat3< T > scale (T s)
 Static constructor returning a 3D uniform scale matrix. More...
 
static Mat3< T > scale (T x, T y, T z)
 Static constructor returning a 3D non-uniform scale matrix. More...
 
static Mat3< T > rotation (const Vec< 3, T > &axis, T angle)
 Static constructor returning a 3D rotation matrix defined by its axis and angle. More...
 
static Mat3< T > rotation (const Vec< 3, T > &axis_angle)
 Static constructor returning a 3D rotation matrix defined by the axis–angle representation. Both the axis and the angle are represented by a vector codirectional with the rotation axis whose length is the rotation angle. More...
 
static Mat3< T > rotation (const Quat< T > &q)
 Static constructor return a 3D rotation matrix defined by a quaternion. More...
 
static Mat3< T > rotation (T x, T y, T z, int order=312)
 Static constructor returning a 3D rotation matrix defined by Euler angles. The three rotations are applied successively. More...
 
- Static Public Member Functions inherited from Mat< 3, 3, T >
static Mat< N, M, T > identity ()
 Static constructor return an N x M identity matrix. see also load_identity()
 

Detailed Description

template<typename T>
class easy3d::Mat3< T >

3x3 matrix. Extends Mat with 3D-specific functionality and constructors.

Template Parameters
TThe scalar type for vector elements.
See also
Mat.
Examples
Tutorial_207_RealCamera.

Constructor & Destructor Documentation

◆ Mat3() [1/3]

Mat3 ( )
default

Default constructor.

Note
The matrix elements are intentionally not initialized. This is efficient if the user assigns their values from subsequent computations. Use Mat3(T s) to initialize the elements during construction.

◆ Mat3() [2/3]

Mat3 ( const T *  m)
inlineexplicit

Initialize elements from an array of type T.

◆ Mat3() [3/3]

Mat3 ( const Mat< 2, 2, T > &  rhs)
inlineexplicit

Initialize from a 2D matrix. rhs forms the upper-left 2x2 sub-matrix, other elements are initialized as the identity.

Member Function Documentation

◆ rotation() [1/4]

Mat3< T > rotation ( const Quat< T > &  q)
inlinestatic

Static constructor return a 3D rotation matrix defined by a quaternion.

Note
q is a unit quaternion representing a rotation.

◆ rotation() [2/4]

Mat3< T > rotation ( const Vec< 3, T > &  axis,
angle 
)
inlinestatic

Static constructor returning a 3D rotation matrix defined by its axis and angle.

Parameters
axisAxis of rotation. This MUST be normalized.
angleAngle of rotation in radians. Positive values of angle rotate counter-clockwise about axis as per the right-hand rule.
Note
The axis defines only the direction of the rotation axis, i.e., the rotation is about the axis passing through the origin.

◆ rotation() [3/4]

Mat3< T > rotation ( const Vec< 3, T > &  axis_angle)
inlinestatic

Static constructor returning a 3D rotation matrix defined by the axis–angle representation. Both the axis and the angle are represented by a vector codirectional with the rotation axis whose length is the rotation angle.

Parameters
axis_angledirection is the axis and length is the angle (in radian)
Note
The axis defines only the direction of the rotation axis, i.e., the rotation is about the axis passing through the origin.

◆ rotation() [4/4]

Mat3< T > rotation ( x,
y,
z,
int  order = 312 
)
inlinestatic

Static constructor returning a 3D rotation matrix defined by Euler angles. The three rotations are applied successively.

Parameters
x,y,zthe rotation angles (in radians) around X, Y, and Z axes respectively.
orderthe order of the rotations to be applied. 1 first and 3 for last.
Note
Using a different order yields different results. The default order is first Y, then Z, then X.

◆ scale() [1/2]

Mat3< T > scale ( s)
inlinestatic

Static constructor returning a 3D uniform scale matrix.

Parameters
sx, y, z scale (uniform).

◆ scale() [2/2]

Mat3< T > scale ( x,
y,
z 
)
inlinestatic

Static constructor returning a 3D non-uniform scale matrix.

Parameters
xx scale.
yy scale.
zz scale.

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