[nnm] No Nonsense Math 0.5.0
A No-Nonsense, C++ 17, single-header-only Math library geared towards graphics programming.
Loading...
Searching...
No Matches
nnm::Transform3< Real > Class Template Reference

#include <nnm.hpp>

Public Member Functions

constexpr Transform3 ()
template<typename Other>
constexpr Transform3 (const Transform3< Other > &transform)
constexpr Transform3 (const Matrix4< Real > &matrix)
constexpr Real trace () const
constexpr Real determinant () const
constexpr Transform3 unchecked_inverse () const
constexpr std::optional< Transform3inverse () const
constexpr bool valid () const
constexpr bool affine () const
constexpr Basis3< Real > basis () const
constexpr Vector3< Real > translation () const
constexpr Transform3 translate (const Vector3< Real > &offset) const
constexpr Transform3 translate_local (const Vector3< Real > &offset) const
Transform3 rotate_axis_angle (const Vector3< Real > &axis, const Real angle) const
Transform3 rotate_axis_angle_local (const Vector3< Real > &axis, const Real angle) const
constexpr Transform3 rotate_quaternion (const Quaternion< Real > &quaternion) const
constexpr Transform3 rotate_quaternion_local (const Quaternion< Real > &quaternion) const
constexpr Transform3 scale (const Vector3< Real > &factor) const
constexpr Transform3 scale_local (const Vector3< Real > &factor) const
constexpr Transform3 shear_x (const Real factor_y, const Real factor_z) const
constexpr Transform3 shear_x_local (const Real factor_y, const Real factor_z) const
constexpr Transform3 shear_y (const Real factor_x, const Real factor_z) const
constexpr Transform3 shear_y_local (const Real factor_x, const Real factor_z) const
constexpr Transform3 shear_z (const Real factor_x, const Real factor_y) const
constexpr Transform3 shear_z_local (const Real factor_x, const Real factor_y) const
constexpr Transform3 transform (const Transform3 &by) const
constexpr Transform3 transform_local (const Transform3 &by) const
constexpr bool approx_equal (const Transform3 &other) const
constexpr const Vector4< Real > & at (const uint8_t column) const
constexpr Vector4< Real > & at (const uint8_t column)
constexpr const Real & at (const uint8_t column, const uint8_t row) const
constexpr Real & at (const uint8_t column, const uint8_t row)
constexpr const Vector4< Real > & operator[] (const uint8_t column) const
constexpr Vector4< Real > & operator[] (const uint8_t column)
constexpr bool operator== (const Transform3 &other) const
constexpr bool operator!= (const Transform3 &other) const
constexpr bool operator< (const Transform3 &other) const

Static Public Member Functions

static constexpr Transform3 from_basis_translation (const Basis3< Real > &basis, const Vector3< Real > &translation)
static constexpr Transform3 from_basis (const Basis3< Real > &basis)
static constexpr Transform3 from_translation (const Vector3< Real > &translation)
static Transform3 from_rotation_axis_angle (const Vector3< Real > &axis, const Real angle)
static constexpr Transform3 from_rotation_quaternion (const Quaternion< Real > &quaternion)
static constexpr Transform3 from_scale (const Vector3< Real > &factor)
static constexpr Transform3 from_shear_x (const Real factor_y, const Real factor_z)
static constexpr Transform3 from_shear_y (const Real factor_x, const Real factor_z)
static constexpr Transform3 from_shear_z (const Real factor_x, const Real factor_y)
static Transform3 from_perspective_left_hand_neg1to1 (const Real fov, const Real aspect_ratio, const Real near_clip, const Real far_clip)
static Transform3 from_perspective_left_hand_0to1 (const Real fov, const Real aspect_ratio, const Real near_clip, const Real far_clip)
static Transform3 from_perspective_right_hand_neg1to1 (const Real fov, const Real aspect_ratio, const Real near_clip, const Real far_clip)
static Transform3 from_perspective_right_hand_0to1 (const Real fov, const Real aspect_ratio, const Real near_clip, const Real far_clip)
static constexpr Transform3 from_orthographic_left_hand_neg1to1 (const Real left, const Real right, const Real bottom, const Real top, const Real near_clip, const Real far_clip)
static constexpr Transform3 from_orthographic_left_hand_0to1 (const Real left, const Real right, const Real bottom, const Real top, const Real near_clip, const Real far_clip)
static constexpr Transform3 from_orthographic_right_hand_neg1to1 (const Real left, const Real right, const Real bottom, const Real top, const Real near_clip, const Real far_clip)
static constexpr Transform3 from_orthographic_right_hand_0to1 (const Real left, const Real right, const Real bottom, const Real top, const Real near_clip, const Real far_clip)

Public Attributes

Matrix4< Real > matrix

Detailed Description

template<typename Real>
class nnm::Transform3< Real >

Three-dimensional transformation matrix.

Template Parameters
RealFloating-point type.

Constructor & Destructor Documentation

◆ Transform3() [1/3]

template<typename Real>
nnm::Transform3< Real >::Transform3 ( )
inlineconstexpr

Initialize with identity.

◆ Transform3() [2/3]

template<typename Real>
template<typename Other>
nnm::Transform3< Real >::Transform3 ( const Transform3< Other > & transform)
inlineexplicitconstexpr

Cast from other transform.

Template Parameters
OtherOther type.
Parameters
transformOther transform.

◆ Transform3() [3/3]

template<typename Real>
nnm::Transform3< Real >::Transform3 ( const Matrix4< Real > & matrix)
inlineexplicitconstexpr

Initialize from a 4x4 matrix. No validation/checks are done.

Parameters
matrixMatrix.

Member Function Documentation

◆ affine()

template<typename Real>
bool nnm::Transform3< Real >::affine ( ) const
inlinenodiscardconstexpr

Determines if transform is affine. Affine means that the transform preserves parallel lines.

Returns
True if affine, false otherwise.

◆ approx_equal()

template<typename Real>
bool nnm::Transform3< Real >::approx_equal ( const Transform3< Real > & other) const
inlinenodiscardconstexpr

Determines if approximately equal to another transform.

Parameters
otherOther transform.
Returns
True if all elements are approximately equal, false otherwise.

◆ at() [1/4]

template<typename Real>
Vector4< Real > & nnm::Transform3< Real >::at ( const uint8_t column)
inlineconstexpr

Reference to column at index.

Parameters
columnIndex of column.
Returns
Reference to column.

◆ at() [2/4]

template<typename Real>
const Vector4< Real > & nnm::Transform3< Real >::at ( const uint8_t column) const
inlinenodiscardconstexpr

Constant reference to column at index.

Parameters
columnIndex of column.
Returns
Constant reference to column.

◆ at() [3/4]

template<typename Real>
Real & nnm::Transform3< Real >::at ( const uint8_t column,
const uint8_t row )
inlineconstexpr

Reference to element at column and row index.

Parameters
columnIndex of column.
rowIndex of row.
Returns
Reference to element.

◆ at() [4/4]

template<typename Real>
const Real & nnm::Transform3< Real >::at ( const uint8_t column,
const uint8_t row ) const
inlinenodiscardconstexpr

Constant reference to element at column and row index.

Parameters
columnIndex of column.
rowIndex of row.
Returns
Constant reference to element.

◆ basis()

template<typename Real>
Basis3< Real > nnm::Transform3< Real >::basis ( ) const
inlinenodiscardconstexpr

Basis of the transform.

Returns
Result.

◆ determinant()

template<typename Real>
Real nnm::Transform3< Real >::determinant ( ) const
inlinenodiscardconstexpr

Determinant of the matrix.

Returns
Result.

◆ from_basis()

template<typename Real>
constexpr Transform3 nnm::Transform3< Real >::from_basis ( const Basis3< Real > & basis)
inlinestaticconstexpr

Transform from a 3D basis and no translation.

Parameters
basis3D Basis.
Returns
Result.

◆ from_basis_translation()

template<typename Real>
constexpr Transform3 nnm::Transform3< Real >::from_basis_translation ( const Basis3< Real > & basis,
const Vector3< Real > & translation )
inlinestaticconstexpr

Transform from a 3D basis and 3D translation.

Parameters
basis3D basis.
translation3D translation vector.
Returns
Result.

◆ from_orthographic_left_hand_0to1()

template<typename Real>
constexpr Transform3 nnm::Transform3< Real >::from_orthographic_left_hand_0to1 ( const Real left,
const Real right,
const Real bottom,
const Real top,
const Real near_clip,
const Real far_clip )
inlinestaticconstexpr

Transform with orthographic projection with left-handed coordinate system and normalized from 0 to 1.

Parameters
leftLeft distance.
rightRight distance.
bottomBottom distance.
topTop distance.
near_clipNear clipping plane distance.
far_clipFar clipping plane distance.
Returns
Result.

◆ from_orthographic_left_hand_neg1to1()

template<typename Real>
constexpr Transform3 nnm::Transform3< Real >::from_orthographic_left_hand_neg1to1 ( const Real left,
const Real right,
const Real bottom,
const Real top,
const Real near_clip,
const Real far_clip )
inlinestaticconstexpr

Transform with orthographic projection with left-handed coordinate system and normalized from -1 to 1.

Parameters
leftLeft distance.
rightRight distance.
bottomBottom distance.
topTop distance.
near_clipNear clipping plane distance.
far_clipFar clipping plane distance.
Returns
Result.

◆ from_orthographic_right_hand_0to1()

template<typename Real>
constexpr Transform3 nnm::Transform3< Real >::from_orthographic_right_hand_0to1 ( const Real left,
const Real right,
const Real bottom,
const Real top,
const Real near_clip,
const Real far_clip )
inlinestaticconstexpr

Transform with orthographic projection with right-handed coordinate system and normalized from 0 to 1.

Parameters
leftLeft distance.
rightRight distance.
bottomBottom distance.
topTop distance.
near_clipNear clipping plane distance.
far_clipFar clipping plane distance.
Returns
Result.

◆ from_orthographic_right_hand_neg1to1()

template<typename Real>
constexpr Transform3 nnm::Transform3< Real >::from_orthographic_right_hand_neg1to1 ( const Real left,
const Real right,
const Real bottom,
const Real top,
const Real near_clip,
const Real far_clip )
inlinestaticconstexpr

Transform with orthographic projection with right-handed coordinate system and normalized from -1 to 1.

Parameters
leftLeft distance.
rightRight distance.
bottomBottom distance.
topTop distance.
near_clipNear clipping plane distance.
far_clipFar clipping plane distance.
Returns
Result.

◆ from_perspective_left_hand_0to1()

template<typename Real>
Transform3 nnm::Transform3< Real >::from_perspective_left_hand_0to1 ( const Real fov,
const Real aspect_ratio,
const Real near_clip,
const Real far_clip )
inlinestatic

Transform with perspective projection with left-handed coordinate system and normalized from 0 to 1.

Parameters
fovField-of-view in radians.
aspect_ratioAspect ratio.
near_clipNear clipping plane distance.
far_clipFar clipping plane distance.
Returns
Result.

◆ from_perspective_left_hand_neg1to1()

template<typename Real>
Transform3 nnm::Transform3< Real >::from_perspective_left_hand_neg1to1 ( const Real fov,
const Real aspect_ratio,
const Real near_clip,
const Real far_clip )
inlinestatic

Transform with perspective projection with left-handed coordinate system and normalized from -1 to 1.

Parameters
fovField-of-view in radians.
aspect_ratioAspect ratio.
near_clipNear clipping plane distance.
far_clipFar clipping plane distance.
Returns
Result.

◆ from_perspective_right_hand_0to1()

template<typename Real>
Transform3 nnm::Transform3< Real >::from_perspective_right_hand_0to1 ( const Real fov,
const Real aspect_ratio,
const Real near_clip,
const Real far_clip )
inlinestatic

Transform with perspective projection with right-handed coordinate system and normalized from 0 to 1.

Parameters
fovField-of-view in radians.
aspect_ratioAspect ratio.
near_clipNear clipping plane distance.
far_clipFar clipping plane distance.
Returns
Result.

◆ from_perspective_right_hand_neg1to1()

template<typename Real>
Transform3 nnm::Transform3< Real >::from_perspective_right_hand_neg1to1 ( const Real fov,
const Real aspect_ratio,
const Real near_clip,
const Real far_clip )
inlinestatic

Transform with perspective projection with right-handed coordinate system and normalized from -1 to 1.

Parameters
fovField-of-view in radians.
aspect_ratioAspect ratio.
near_clipNear clipping plane distance.
far_clipFar clipping plane distance.
Returns
Result.

◆ from_rotation_axis_angle()

template<typename Real>
Transform3 nnm::Transform3< Real >::from_rotation_axis_angle ( const Vector3< Real > & axis,
const Real angle )
inlinestatic

Transform rotated about a normalized axis and angle.

Parameters
axisNormalized 3D axis vector.
angleAngle in radians.
Returns
Result.

◆ from_rotation_quaternion()

template<typename Real>
constexpr Transform3 nnm::Transform3< Real >::from_rotation_quaternion ( const Quaternion< Real > & quaternion)
inlinestaticconstexpr

Transform rotated by quaternion.

Parameters
quaternionQuaternion.
Returns
Result.

◆ from_scale()

template<typename Real>
constexpr Transform3 nnm::Transform3< Real >::from_scale ( const Vector3< Real > & factor)
inlinestaticconstexpr

Transform scaled by per-axis factor.

Parameters
factorScale factor vector.
Returns
Result.

◆ from_shear_x()

template<typename Real>
constexpr Transform3 nnm::Transform3< Real >::from_shear_x ( const Real factor_y,
const Real factor_z )
inlinestaticconstexpr

Transform sheared about the x-axis.

Parameters
factor_yY-Axis factor.
factor_zZ-Axis factor.
Returns
Result.

◆ from_shear_y()

template<typename Real>
constexpr Transform3 nnm::Transform3< Real >::from_shear_y ( const Real factor_x,
const Real factor_z )
inlinestaticconstexpr

Transform sheared about the y-axis.

Parameters
factor_xX-Axis factor.
factor_zZ-Axis factor.
Returns
Result.

◆ from_shear_z()

template<typename Real>
constexpr Transform3 nnm::Transform3< Real >::from_shear_z ( const Real factor_x,
const Real factor_y )
inlinestaticconstexpr

Transform sheared about the z-axis.

Parameters
factor_xX-Axis factor.
factor_yZ-Axis factor.
Returns
Result.

◆ from_translation()

template<typename Real>
constexpr Transform3 nnm::Transform3< Real >::from_translation ( const Vector3< Real > & translation)
inlinestaticconstexpr

Transform with a translation.

Parameters
translation3D translation vector.
Returns
Result.

◆ inverse()

template<typename Real>
std::optional< Transform3 > nnm::Transform3< Real >::inverse ( ) const
inlinenodiscardconstexpr

Inverse of the transform.

Returns
Inverse if one exists, null otherwise.

◆ operator!=()

template<typename Real>
bool nnm::Transform3< Real >::operator!= ( const Transform3< Real > & other) const
inlinenodiscardconstexpr

Element-wise inequality

Parameters
otherOther transform.
Returns
True if any element is not equal, false otherwise.

◆ operator<()

template<typename Real>
bool nnm::Transform3< Real >::operator< ( const Transform3< Real > & other) const
inlinenodiscardconstexpr

Lexicographical comparison.

Parameters
otherOther transform.
Returns
True if less than, false otherwise.

◆ operator==()

template<typename Real>
bool nnm::Transform3< Real >::operator== ( const Transform3< Real > & other) const
inlinenodiscardconstexpr

Element-wise equality.

Parameters
otherOther transform.
Returns
True if all elements are equal, false otherwise.

◆ operator[]() [1/2]

template<typename Real>
Vector4< Real > & nnm::Transform3< Real >::operator[] ( const uint8_t column)
inlineconstexpr

Reference to column at column index.

Parameters
columnIndex of column.
Returns
Reference to column.

◆ operator[]() [2/2]

template<typename Real>
const Vector4< Real > & nnm::Transform3< Real >::operator[] ( const uint8_t column) const
inlinenodiscardconstexpr

Constant reference to column at column index.

Parameters
columnIndex of column.
Returns
Constant reference to column.

◆ rotate_axis_angle()

template<typename Real>
Transform3 nnm::Transform3< Real >::rotate_axis_angle ( const Vector3< Real > & axis,
const Real angle ) const
inlinenodiscard

Rotation about an axis by an angle.

Parameters
axisNormalized 3D vector axis.
angleAngle in radians.
Returns
Result.

◆ rotate_axis_angle_local()

template<typename Real>
Transform3 nnm::Transform3< Real >::rotate_axis_angle_local ( const Vector3< Real > & axis,
const Real angle ) const
inlinenodiscard

Local rotation about an axis by an angle.

Parameters
axisNormalized 3D vector axis.
angleAngle in radians.
Returns
Result.

◆ rotate_quaternion()

template<typename Real>
Transform3 nnm::Transform3< Real >::rotate_quaternion ( const Quaternion< Real > & quaternion) const
inlinenodiscardconstexpr

Rotation by quaternion.

Parameters
quaternionQuaternion.
Returns
Result.

◆ rotate_quaternion_local()

template<typename Real>
Transform3 nnm::Transform3< Real >::rotate_quaternion_local ( const Quaternion< Real > & quaternion) const
inlinenodiscardconstexpr

Location rotation by quaternion.

Parameters
quaternionQuaternion.
Returns
Result.

◆ scale()

template<typename Real>
Transform3 nnm::Transform3< Real >::scale ( const Vector3< Real > & factor) const
inlinenodiscardconstexpr

Per-axis scale by factor.

Parameters
factor3D scale factor vector.
Returns
Result.

◆ scale_local()

template<typename Real>
Transform3 nnm::Transform3< Real >::scale_local ( const Vector3< Real > & factor) const
inlinenodiscardconstexpr

Local per-axis scale by factor.

Parameters
factor3D scale factor vector.
Returns
Result.

◆ shear_x()

template<typename Real>
Transform3 nnm::Transform3< Real >::shear_x ( const Real factor_y,
const Real factor_z ) const
inlinenodiscardconstexpr

Shear about the x-axis.

Parameters
factor_yY-Axis factor.
factor_zZ-Axis factor.
Returns
Result.

◆ shear_x_local()

template<typename Real>
Transform3 nnm::Transform3< Real >::shear_x_local ( const Real factor_y,
const Real factor_z ) const
inlinenodiscardconstexpr

Local shear about the x-axis.

Parameters
factor_yY-Axis factor.
factor_zZ-Axis factor.
Returns
Result.

◆ shear_y()

template<typename Real>
Transform3 nnm::Transform3< Real >::shear_y ( const Real factor_x,
const Real factor_z ) const
inlinenodiscardconstexpr

Shear about the y-axis.

Parameters
factor_xX-Axis factor.
factor_zZ-Axis factor.
Returns
Result.

◆ shear_y_local()

template<typename Real>
Transform3 nnm::Transform3< Real >::shear_y_local ( const Real factor_x,
const Real factor_z ) const
inlinenodiscardconstexpr

Local shear about the y-axis.

Parameters
factor_xX-Axis factor.
factor_zZ-Axis factor.
Returns
Result.

◆ shear_z()

template<typename Real>
Transform3 nnm::Transform3< Real >::shear_z ( const Real factor_x,
const Real factor_y ) const
inlinenodiscardconstexpr

Shear about the z-axis.

Parameters
factor_xX-Axis factor.
factor_yZ-Axis factor.
Returns
Result.

◆ shear_z_local()

template<typename Real>
Transform3 nnm::Transform3< Real >::shear_z_local ( const Real factor_x,
const Real factor_y ) const
inlinenodiscardconstexpr

Local shear about the z-axis.

Parameters
factor_xX-Axis factor.
factor_yZ-Axis factor.
Returns
Result.

◆ trace()

template<typename Real>
Real nnm::Transform3< Real >::trace ( ) const
inlinenodiscardconstexpr

Trace which is the sum of the matrix diagonal.

Returns
Result.

◆ transform()

template<typename Real>
Transform3 nnm::Transform3< Real >::transform ( const Transform3< Real > & by) const
inlinenodiscardconstexpr

Transform by another transform.

Parameters
byOther transform.
Returns
Result.

◆ transform_local()

template<typename Real>
Transform3 nnm::Transform3< Real >::transform_local ( const Transform3< Real > & by) const
inlinenodiscardconstexpr

Local transform by another transform.

Parameters
byOther transform.
Returns
Result.

◆ translate()

template<typename Real>
Transform3 nnm::Transform3< Real >::translate ( const Vector3< Real > & offset) const
inlinenodiscardconstexpr

Translation.

Parameters
offsetOffset vector.
Returns
Result.

◆ translate_local()

template<typename Real>
Transform3 nnm::Transform3< Real >::translate_local ( const Vector3< Real > & offset) const
inlinenodiscardconstexpr

Local translation.

Parameters
offsetOffset vector.
Returns
Result.

◆ translation()

template<typename Real>
Vector3< Real > nnm::Transform3< Real >::translation ( ) const
inlinenodiscardconstexpr

Translation vector of the transform.

Returns
Result.

◆ unchecked_inverse()

template<typename Real>
Transform3 nnm::Transform3< Real >::unchecked_inverse ( ) const
inlinenodiscardconstexpr

Inverse of the transform without checking if a valid inverse is possible.

Returns
Result.

◆ valid()

template<typename Real>
bool nnm::Transform3< Real >::valid ( ) const
inlinenodiscardconstexpr

Determines if transform is valid. Validity is determined based on if the transform's basis is valid.

Returns
True if valid, false otherwise.

Member Data Documentation

◆ matrix

template<typename Real>
Matrix4<Real> nnm::Transform3< Real >::matrix

Matrix of transform


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