Correlation 4.10.0
An Analysis Tool for Liquids and for Amorphous Solids
Loading...
Searching...
No Matches
correlation::render3d::Matrix4< T > Class Template Reference

4x4 column-major transformation matrix. More...

#include <Math3D.hpp>

Public Types

using value_type = T

Public Member Functions

constexpr Matrix4 () noexcept=default
 Default constructor. Initializes to zero matrix.
constexpr Matrix4 (const std::array< T, 16 > &raw) noexcept
 Constructs matrix from column-major elements array.
constexpr T & operator() (std::size_t row_idx, std::size_t col_idx) noexcept
 Element accessor by (row, column).
constexpr const T & operator() (std::size_t row_idx, std::size_t col_idx) const noexcept
constexpr const std::array< T, 16 > & data () const noexcept
constexpr std::array< T, 16 > & data () noexcept
constexpr Vector4< T > operator* (const Vector4< T > &vec) const noexcept
 Matrix-vector multiplication.
constexpr Matrix4 operator* (const Matrix4 &rhs) const noexcept
 Matrix-matrix multiplication.
constexpr math::Vector3< T > transformPoint (const math::Vector3< T > &point) const noexcept
 Transforms a 3D point (w = 1) with perspective division.
constexpr math::Vector3< T > transformDirection (const math::Vector3< T > &direction) const noexcept
 Transforms a 3D direction vector (w = 0).
constexpr Matrix4 transpose () const noexcept
 Transposes the matrix.

Static Public Member Functions

static constexpr Matrix4 identity () noexcept
 Creates a 4x4 identity matrix.
static constexpr Matrix4 translation (T offset_x, T offset_y, T offset_z) noexcept
 Creates a translation matrix.
static constexpr Matrix4 translation (const math::Vector3< T > &offset) noexcept
static constexpr Matrix4 scaling (T scale_x, T scale_y, T scale_z) noexcept
 Creates a non-uniform scaling matrix.
static constexpr Matrix4 scaling (T uniform_scale) noexcept
static Matrix4 lookAt (const math::Vector3< T > &eye, const math::Vector3< T > &target, const math::Vector3< T > &up_direction)
 Generates a Look-At view matrix (Right-Handed).
static Matrix4 perspective (T fov_y_rad, T aspect, T z_near, T z_far)
 Generates perspective projection matrix (RH, depth in [0, 1] suitable for Vulkan/Software).
static Matrix4 orthographic (T left, T right, T bottom, T top, T z_near, T z_far)
 Generates orthographic projection matrix (RH, depth in [0, 1]).

Private Attributes

std::array< T, 16 > data_ {}

Detailed Description

template<typename T = float>
requires std::is_floating_point_v<T>
class correlation::render3d::Matrix4< T >

4x4 column-major transformation matrix.

Template Parameters
TFloating-point scalar type.

Member Typedef Documentation

◆ value_type

template<typename T = float>
using correlation::render3d::Matrix4< T >::value_type = T

Constructor & Destructor Documentation

◆ Matrix4() [1/2]

template<typename T = float>
correlation::render3d::Matrix4< T >::Matrix4 ( )
constexprdefaultnoexcept

Default constructor. Initializes to zero matrix.

Here is the caller graph for this function:

◆ Matrix4() [2/2]

template<typename T = float>
correlation::render3d::Matrix4< T >::Matrix4 ( const std::array< T, 16 > & raw)
inlineexplicitconstexprnoexcept

Constructs matrix from column-major elements array.

Parameters
raw16-element array in column-major order.
Here is the call graph for this function:

Member Function Documentation

◆ data() [1/2]

template<typename T = float>
const std::array< T, 16 > & correlation::render3d::Matrix4< T >::data ( ) const
inlinenodiscardconstexprnoexcept

◆ data() [2/2]

template<typename T = float>
std::array< T, 16 > & correlation::render3d::Matrix4< T >::data ( )
inlinenodiscardconstexprnoexcept

◆ identity()

template<typename T = float>
constexpr Matrix4 correlation::render3d::Matrix4< T >::identity ( )
inlinestaticnodiscardconstexprnoexcept

Creates a 4x4 identity matrix.

Returns
Identity matrix.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ lookAt()

template<typename T = float>
Matrix4 correlation::render3d::Matrix4< T >::lookAt ( const math::Vector3< T > & eye,
const math::Vector3< T > & target,
const math::Vector3< T > & up_direction )
inlinestaticnodiscard

Generates a Look-At view matrix (Right-Handed).

Parameters
eyeCamera eye position.
targetTarget look-at point.
up_directionWorld up vector.
Returns
View matrix.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator()() [1/2]

template<typename T = float>
const T & correlation::render3d::Matrix4< T >::operator() ( std::size_t row_idx,
std::size_t col_idx ) const
inlinenodiscardconstexprnoexcept

◆ operator()() [2/2]

template<typename T = float>
T & correlation::render3d::Matrix4< T >::operator() ( std::size_t row_idx,
std::size_t col_idx )
inlinenodiscardconstexprnoexcept

Element accessor by (row, column).

Parameters
row_idxRow index in [0, 3].
col_idxColumn index in [0, 3].
Returns
Element reference.

◆ operator*() [1/2]

template<typename T = float>
Matrix4 correlation::render3d::Matrix4< T >::operator* ( const Matrix4< T > & rhs) const
inlinenodiscardconstexprnoexcept

Matrix-matrix multiplication.

Parameters
rhsRight-hand side matrix.
Returns
Product matrix.
Here is the call graph for this function:

◆ operator*() [2/2]

template<typename T = float>
Vector4< T > correlation::render3d::Matrix4< T >::operator* ( const Vector4< T > & vec) const
inlinenodiscardconstexprnoexcept

Matrix-vector multiplication.

Parameters
vec4D vector.
Returns
Transformed vector.

◆ orthographic()

template<typename T = float>
Matrix4 correlation::render3d::Matrix4< T >::orthographic ( T left,
T right,
T bottom,
T top,
T z_near,
T z_far )
inlinestaticnodiscard

Generates orthographic projection matrix (RH, depth in [0, 1]).

Parameters
leftLeft boundary.
rightRight boundary.
bottomBottom boundary.
topTop boundary.
z_nearNear plane.
z_farFar plane.
Returns
Orthographic matrix.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ perspective()

template<typename T = float>
Matrix4 correlation::render3d::Matrix4< T >::perspective ( T fov_y_rad,
T aspect,
T z_near,
T z_far )
inlinestaticnodiscard

Generates perspective projection matrix (RH, depth in [0, 1] suitable for Vulkan/Software).

Parameters
fov_y_radVertical field of view in radians.
aspectViewport aspect ratio (width / height).
z_nearNear clipping plane distance (> 0).
z_farFar clipping plane distance (> z_near).
Returns
Perspective projection matrix.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ scaling() [1/2]

template<typename T = float>
constexpr Matrix4 correlation::render3d::Matrix4< T >::scaling ( T scale_x,
T scale_y,
T scale_z )
inlinestaticnodiscardconstexprnoexcept

Creates a non-uniform scaling matrix.

Parameters
scale_xScale in X.
scale_yScale in Y.
scale_zScale in Z.
Returns
Scaling matrix.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ scaling() [2/2]

template<typename T = float>
constexpr Matrix4 correlation::render3d::Matrix4< T >::scaling ( T uniform_scale)
inlinestaticnodiscardconstexprnoexcept
Here is the call graph for this function:

◆ transformDirection()

template<typename T = float>
math::Vector3< T > correlation::render3d::Matrix4< T >::transformDirection ( const math::Vector3< T > & direction) const
inlinenodiscardconstexprnoexcept

Transforms a 3D direction vector (w = 0).

Parameters
direction3D direction.
Returns
Transformed direction.
Here is the call graph for this function:

◆ transformPoint()

template<typename T = float>
math::Vector3< T > correlation::render3d::Matrix4< T >::transformPoint ( const math::Vector3< T > & point) const
inlinenodiscardconstexprnoexcept

Transforms a 3D point (w = 1) with perspective division.

Parameters
point3D point.
Returns
Projected 3D point.
Here is the call graph for this function:

◆ translation() [1/2]

template<typename T = float>
constexpr Matrix4 correlation::render3d::Matrix4< T >::translation ( const math::Vector3< T > & offset)
inlinestaticnodiscardconstexprnoexcept
Here is the call graph for this function:

◆ translation() [2/2]

template<typename T = float>
constexpr Matrix4 correlation::render3d::Matrix4< T >::translation ( T offset_x,
T offset_y,
T offset_z )
inlinestaticnodiscardconstexprnoexcept

Creates a translation matrix.

Parameters
offset_xTranslation in X.
offset_yTranslation in Y.
offset_zTranslation in Z.
Returns
Translation matrix.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ transpose()

template<typename T = float>
Matrix4 correlation::render3d::Matrix4< T >::transpose ( ) const
inlinenodiscardconstexprnoexcept

Transposes the matrix.

Returns
Transposed matrix.
Here is the call graph for this function:

Member Data Documentation

◆ data_

template<typename T = float>
std::array<T, 16> correlation::render3d::Matrix4< T >::data_ {}
private

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