Regina 7.4 Calculation Engine
regina::Matrix3D< Real > Class Template Reference

Represents a linear transformation in three-dimensional space, as represented by a real 3-by-3 matrix. More...

#include <maths/3d.h>

Public Member Functions

 Matrix3D ()=default
 Creates the identity matrix.
 
constexpr Matrix3D (const Matrix3D &)=default
 Creates a new copy of the given matrix.
 
constexpr Matrix3D (Real m00, Real m01, Real m02, Real m10, Real m11, Real m12, Real m20, Real m21, Real m22)
 Creates a new matrix containin the given entries.
 
Matrix3Doperator= (const Matrix3D &)=default
 Sets this to be a copy of the given matrix.
 
std::array< Real, 3 > & operator[] (int row)
 Gives read-write access to a single row of this matrix.
 
constexpr const std::array< Real, 3 > & operator[] (int row) const
 Gives read-only access to a single row of this matrix.
 
constexpr bool operator== (const Matrix3D &other) const
 Determines if this and the given matrix are equal.
 
constexpr Matrix3D operator* (const Matrix3D &rhs) const
 Returns the composition of this and the given transformation.
 
Matrix3Doperator*= (const Matrix3D &rhs)
 Composes this with the given transformation, which is to be applied first.
 
constexpr Vector3D< Real > operator* (const Vector3D< Real > &vector) const
 Returns the image of the given vector under this transformation.
 
constexpr Matrix3D inverse () const
 Returns the inverse of this transformation.
 

Detailed Description

template<typename Real = double>
class regina::Matrix3D< Real >

Represents a linear transformation in three-dimensional space, as represented by a real 3-by-3 matrix.

These matrices act on column vectors. Specifically, a transformation represented by the 3-by-3 matrix M will transform the column vector v into the vector M * v.

If you are interested specifically in rotations, then you should use the Rotation3D class instead, which uses a more compact and numerically stable representation (quaternions).

This class is designed specifically to work with transformations, and so it focuses more on operations such as composition and inverse, and less on other more general matrix operations. For a general numerical matrix class you can always use Matrix<double> (or MatrixReal in Python) instead.

See Regina's notes on 3-D geometry for important information, including the inexact floating-point nature of the Vector3D class, and the right-handedness of Regina's coordinate system.

These objects are small enough to pass by value and swap with std::swap(), with no need for any specialised move operations or swap functions.

Python
The template parameter Real is double.
Template Parameters
Realthe floating-point type to use for all storage and computation.

Constructor & Destructor Documentation

◆ Matrix3D() [1/3]

template<typename Real = double>
regina::Matrix3D< Real >::Matrix3D ( )
default

Creates the identity matrix.

◆ Matrix3D() [2/3]

template<typename Real = double>
regina::Matrix3D< Real >::Matrix3D ( const Matrix3D< Real > & )
constexprdefault

Creates a new copy of the given matrix.

◆ Matrix3D() [3/3]

template<typename Real = double>
regina::Matrix3D< Real >::Matrix3D ( Real m00,
Real m01,
Real m02,
Real m10,
Real m11,
Real m12,
Real m20,
Real m21,
Real m22 )
inlineconstexpr

Creates a new matrix containin the given entries.

Parameters
m00the entry in row 0, column 0.
m01the entry in row 0, column 1.
m02the entry in row 0, column 2.
m10the entry in row 1, column 0.
m11the entry in row 1, column 1.
m12the entry in row 1, column 2.
m20the entry in row 2, column 0.
m21the entry in row 2, column 1.
m22the entry in row 2, column 2.

Member Function Documentation

◆ inverse()

template<typename Real = double>
Matrix3D regina::Matrix3D< Real >::inverse ( ) const
inlineconstexpr

Returns the inverse of this transformation.

Precondition
This transformation is invertible; that is, the underlying 3-by-3 matrix does not have determinant zero.
Returns
the inverse transformation.

◆ operator*() [1/2]

template<typename Real = double>
Matrix3D regina::Matrix3D< Real >::operator* ( const Matrix3D< Real > & rhs) const
inlineconstexpr

Returns the composition of this and the given transformation.

Composition of transformations is not commutative. Here we follow the same convention as used elsewhere in Regina (e.g., by Regina's permutation classes): the product s * t indicates that we should apply transformation t first, followed by transformation s. This is also consistent with the order in which we multiply the underlying 3-by-3 matrices.

Parameters
rhsthe transformation to apply before this.
Returns
the composition of this and the given transformation.

◆ operator*() [2/2]

template<typename Real = double>
Vector3D< Real > regina::Matrix3D< Real >::operator* ( const Vector3D< Real > & vector) const
inlineconstexpr

Returns the image of the given vector under this transformation.

Recall that vectors are treated as column vectors. That is, if this transformation has matrix M and the given vector represents the column vector v, then the result will be the column vector M * v.

Parameters
vectorthe 3-D vector to rotate.
Returns
the result of applying this transformation to the given vector.

◆ operator*=()

template<typename Real = double>
Matrix3D & regina::Matrix3D< Real >::operator*= ( const Matrix3D< Real > & rhs)
inline

Composes this with the given transformation, which is to be applied first.

This transformation will be changed directly.

Composition of transformations is not commutative. Here we follow the same convention as used elsewhere in Regina (e.g., by Regina's permutation classes): writing s *= t indicates that we should apply transformation t first, followed by transformation s, and then change s to store the resulting composition. This is consistent with the order in which we multiply the underlying 3-by-3 matrices.

Parameters
rhsthe transformation to apply before this.
Returns
a reference to this transformation.

◆ operator=()

template<typename Real = double>
Matrix3D & regina::Matrix3D< Real >::operator= ( const Matrix3D< Real > & )
default

Sets this to be a copy of the given matrix.

Returns
a reference to this matrix.

◆ operator==()

template<typename Real = double>
bool regina::Matrix3D< Real >::operator== ( const Matrix3D< Real > & other) const
inlineconstexpr

Determines if this and the given matrix are equal.

Warning
Equality and inequailty testing, while supported, is extremely fragile, since it relies on floating-point comparisons.
Parameters
otherthe matrix to compare with this.
Returns
true if and only if the two matrices are equal.

◆ operator[]() [1/2]

template<typename Real = double>
std::array< Real, 3 > & regina::Matrix3D< Real >::operator[] ( int row)
inline

Gives read-write access to a single row of this matrix.

This means that the entry in row r, column c can be accessed as matrix[r][c] (where r and c are each 0, 1 or 2).

Parameters
rowthe index of the requested row; this must be 0, 1 or 2.
Returns
a reference to the three-element array containing the elements of the requested row.

◆ operator[]() [2/2]

template<typename Real = double>
const std::array< Real, 3 > & regina::Matrix3D< Real >::operator[] ( int row) const
inlineconstexpr

Gives read-only access to a single row of this matrix.

This means that the entry in row r, column c can be accessed as matrix[r][c] (where r and c are each 0, 1 or 2).

Parameters
rowthe index of the requested row; this must be 0, 1 or 2.
Returns
a three-element array containing the elements of the requested row.

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