![]() |
Raven Engine v0.1
|
Matrix types and operations. More...
Classes | |
| struct | Crux::Matrix< T, Rows, Cols > |
| Generic fixed-size matrix container. More... | |
Typedefs | |
| using | Crux::mat2 = Matrix<float, 2, 2> |
| 2x2 single-precision floating-point matrix. | |
| using | Crux::mat3 = Matrix<float, 3, 3> |
| 3x3 single-precision floating-point matrix. | |
| using | Crux::mat4 = Matrix<float, 4, 4> |
| 4x4 single-precision floating-point matrix. | |
| using | Crux::dmat2 = Matrix<double, 2, 2> |
| 2x2 double-precision floating-point matrix. | |
| using | Crux::dmat3 = Matrix<double, 3, 3> |
| 3x3 double-precision floating-point matrix. | |
| using | Crux::dmat4 = Matrix<double, 4, 4> |
| 4x4 double-precision floating-point matrix. | |
| using | Crux::imat2 = Matrix<int, 2, 2> |
| 2x2 integer matrix. | |
| using | Crux::imat3 = Matrix<int, 3, 3> |
| 3x3 integer matrix. | |
| using | Crux::imat4 = Matrix<int, 4, 4> |
| 4x4 integer matrix. | |
Functions | |
| template<typename T, size_t Rows, size_t Cols> | |
| constexpr Matrix< T, Rows, Cols > | Crux::operator+ (const Matrix< T, Rows, Cols > &a, const Matrix< T, Rows, Cols > &b) |
| Adds two matrices element-wise. | |
| template<typename T, size_t Rows, size_t Cols> | |
| constexpr Matrix< T, Rows, Cols > | Crux::operator- (const Matrix< T, Rows, Cols > &a, const Matrix< T, Rows, Cols > &b) |
| Subtracts two matrices element-wise. | |
| template<typename T, size_t Rows, size_t Cols> | |
| constexpr Matrix< T, Rows, Cols > | Crux::operator* (const Matrix< T, Rows, Cols > &a, const T &scalar) |
| Multiplies each matrix element by a scalar. | |
| template<typename T, size_t Rows, size_t Cols> | |
| constexpr Matrix< T, Rows, Cols > | Crux::operator* (const T &scalar, const Matrix< T, Rows, Cols > &a) |
| Multiplies each matrix element by a scalar. | |
| template<typename T, size_t Rows, size_t Cols> | |
| constexpr Matrix< T, Rows, Cols > | Crux::operator/ (const Matrix< T, Rows, Cols > &a, const T &scalar) |
| Divides each matrix element by a scalar. | |
| template<typename T, size_t RowsA, size_t ColsA, size_t ColsB> | |
| constexpr Matrix< T, RowsA, ColsB > | Crux::operator* (const Matrix< T, RowsA, ColsA > &a, const Matrix< T, ColsA, ColsB > &b) |
| Performs matrix multiplication (dot product). | |
| template<typename T, size_t Rows, size_t Cols> | |
| constexpr Matrix< T, Rows, Cols > | Crux::Zero () |
| Generates a zero matrix of size Rows x Cols. | |
| template<typename T, size_t Rows, size_t Cols> | |
| constexpr Matrix< T, Cols, Rows > | Crux::Transpose (const Matrix< T, Rows, Cols > &a) |
| Transposes the given matrix (rows become columns). | |
| template<typename T> | |
| constexpr Matrix< T, 4, 4 > | Crux::RotateX (T angle) |
| Creates a 4x4 rotation matrix around the X axis. | |
| template<typename T> | |
| constexpr Matrix< T, 4, 4 > | Crux::RotateY (T angle) |
| Creates a 4x4 rotation matrix around the Y axis. | |
| template<typename T> | |
| constexpr Matrix< T, 4, 4 > | Crux::RotateZ (T angle) |
| Creates a 4x4 rotation matrix around the Z axis. | |
| template<typename T> | |
| constexpr Matrix< T, 2, 2 > | Crux::Scale (T tx, T ty) |
| Constructs a 2D scaling matrix. | |
| template<typename T> | |
| constexpr Matrix< T, 4, 4 > | Crux::Scale (T sx, T sy, T sz) |
| Constructs a 4x4 3D non-uniform scaling matrix. | |
| template<typename T> | |
| constexpr Matrix< T, 4, 4 > | Crux::Scale (const Vector< T, 3 > &s) |
| Constructs a 4x4 3D non-uniform scaling matrix from a vector. | |
| template<typename T, size_t N> | |
| constexpr Matrix< T, N, N > | Crux::Scale (T s) |
| Constructs a uniform scaling matrix of size N x N. | |
| template<typename T> | |
| constexpr Matrix< T, 3, 3 > | Crux::Translate (T tx, T ty) |
| Constructs a 3x3 2D translation matrix. | |
| constexpr Matrix< float, 4, 4 > | Crux::Translate (float tx, float ty, float tz) |
| Constructs a 4x4 3D translation matrix. | |
| template<typename T> | |
| constexpr Matrix< T, 4, 4 > | Crux::Translate (const Matrix< T, 4, 4 > &m, const Vector< T, 3 > &v) |
| Applies a 3D translation to a 4x4 matrix using a vector. | |
| template<typename T, size_t N> | |
| constexpr Matrix< T, N, N > | Crux::Identity () |
| Generates an identity matrix of size NxN. | |
| template<typename T, size_t N> | |
| constexpr T | Crux::Trace (const Matrix< T, N, N > &a) |
| Computes the trace (sum of diagonal elements) of a square matrix. | |
| template<typename T, size_t Rows, size_t Cols> | |
| constexpr T | Crux::Norm (const Matrix< T, Rows, Cols > &a) |
| Computes the Frobenius norm of the matrix. | |
| template<typename T, size_t Rows, size_t Cols> | |
| constexpr Matrix< T, Rows, Cols > | Crux::Normalize (const Matrix< T, Rows, Cols > &a) |
| Normalizes the matrix by dividing each element by the Frobenius norm. | |
| template<typename T> | |
| constexpr T | Crux::Determinant (const Matrix< T, 2, 2 > &a) |
| Computes the determinant of a 2x2 matrix. | |
| template<typename T> | |
| constexpr T | Crux::Determinant (const Matrix< T, 3, 3 > &a) |
| Computes the determinant of a 3x3 matrix. | |
| template<typename T> | |
| constexpr T | Crux::Determinant (const Matrix< T, 4, 4 > &a) |
| Computes the determinant of a 4x4 matrix. | |
| template<typename T> | |
| constexpr Matrix< T, 2, 2 > | Crux::Inverse (const Matrix< T, 2, 2 > &a) |
| Computes the inverse of a 2x2 matrix. | |
| template<typename T> | |
| constexpr Matrix< T, 3, 3 > | Crux::Inverse (const Matrix< T, 3, 3 > &a) |
| Computes the inverse of a 3x3 matrix. | |
| template<typename T> | |
| constexpr Matrix< T, 4, 4 > | Crux::Inverse (const Matrix< T, 4, 4 > &a) |
| Computes the inverse of a 4x4 matrix. | |
| template<typename T> | |
| constexpr Matrix< T, 3, 3 > | Crux::ToMat3 (const Matrix< T, 4, 4 > &m) |
| Converts a 4x4 Matrix into a 3x3 Matrix. | |
| template<typename T> | |
| constexpr Matrix< T, 4, 4 > | Crux::LookAt (const Vector< T, 3 > &position, const Vector< T, 3 > &target, const Vector< T, 3 > &up) |
| Creates a look-at view matrix using position, target, and up vectors. | |
Matrix types and operations.
Contains matrix definitions, transformations, and related algorithms.
| using Crux::dmat2 = Matrix<double, 2, 2> |
2x2 double-precision floating-point matrix.
| using Crux::dmat3 = Matrix<double, 3, 3> |
3x3 double-precision floating-point matrix.
| using Crux::dmat4 = Matrix<double, 4, 4> |
4x4 double-precision floating-point matrix.
| using Crux::imat2 = Matrix<int, 2, 2> |
2x2 integer matrix.
| using Crux::imat3 = Matrix<int, 3, 3> |
3x3 integer matrix.
| using Crux::imat4 = Matrix<int, 4, 4> |
4x4 integer matrix.
| using Crux::mat2 = Matrix<float, 2, 2> |
2x2 single-precision floating-point matrix.
| using Crux::mat3 = Matrix<float, 3, 3> |
3x3 single-precision floating-point matrix.
| using Crux::mat4 = Matrix<float, 4, 4> |
4x4 single-precision floating-point matrix.
|
constexpr |
Computes the determinant of a 2x2 matrix.
Calculates the determinant using the formula: ad - bc.
| a | The matrix. |
|
constexpr |
Computes the determinant of a 3x3 matrix.
Uses the rule of Sarrus or cofactor expansion.
| a | The matrix. |
|
constexpr |
Computes the determinant of a 4x4 matrix.
Uses cofactor expansion along the first row.
| a | The matrix. |
|
constexpr |
Generates an identity matrix of size NxN.
Returns a square matrix with ones on the diagonal and zeros elsewhere.
Computes the inverse of a 2x2 matrix.
Returns the inverse if the matrix is invertible; otherwise, returns the original matrix.
| a | The matrix. |
Computes the inverse of a 3x3 matrix.
Returns the inverse if the matrix is invertible; otherwise, returns the original matrix.
| a | The matrix. |
Computes the inverse of a 4x4 matrix.
Returns the inverse if the matrix is invertible; otherwise, returns the original matrix.
| a | The matrix. |
|
constexpr |
Creates a look-at view matrix using position, target, and up vectors.
Constructs a right-handed coordinate system for a camera transform, where:
The matrix transforms world coordinates into view space.
| T | Numeric type for the vector and matrix (e.g. float, double). |
| position | The camera position in world space. |
| target | The point in world space the camera is looking at. |
| up | The world up vector, usually (0,0,1) or (0,1,0) depending on conventions. |
|
constexpr |
Computes the Frobenius norm of the matrix.
Calculates the square root of the sum of the squares of all elements.
| a | The matrix. |
|
constexpr |
Normalizes the matrix by dividing each element by the Frobenius norm.
Scales the matrix so that its Frobenius norm is 1. If the norm is zero, returns the original matrix.
| a | The matrix to normalize. |
|
constexpr |
Multiplies each matrix element by a scalar.
Multiplies every element of the matrix by the given scalar value.
| a | Input matrix. |
| scalar | Scalar value to multiply by. |
|
constexpr |
Performs matrix multiplication (dot product).
Multiplies two matrices using the standard matrix multiplication rule.
| a | Left matrix (RowsA x ColsA). |
| b | Right matrix (ColsA x ColsB). |
|
constexpr |
Multiplies each matrix element by a scalar.
Multiplies every element of the matrix by the given scalar value.
| scalar | Scalar value to multiply by. |
| a | Input matrix. |
|
constexpr |
Adds two matrices element-wise.
Adds corresponding elements of two matrices of the same size.
| a | First matrix. |
| b | Second matrix. |
|
constexpr |
Subtracts two matrices element-wise.
Subtracts corresponding elements of matrix b from matrix a.
| a | First matrix. |
| b | Second matrix. |
|
constexpr |
Divides each matrix element by a scalar.
Divides every element of the matrix by the given scalar value.
| a | Input matrix. |
| scalar | Scalar value to divide by. |
|
constexpr |
Creates a 4x4 rotation matrix around the X axis.
Constructs a rotation matrix for rotating points around the X axis by the given angle.
| angle | Rotation angle in radians. |
|
constexpr |
Creates a 4x4 rotation matrix around the Y axis.
Constructs a rotation matrix for rotating points around the Y axis by the given angle.
| angle | Rotation angle in radians. |
|
constexpr |
Creates a 4x4 rotation matrix around the Z axis.
Constructs a rotation matrix for rotating points around the Z axis by the given angle.
| angle | Rotation angle in radians. |
Constructs a 4x4 3D non-uniform scaling matrix from a vector.
Unpacks the Vector<T,3> into sx, sy, sz.
| s | Scale vector (x, y, z). |
|
constexpr |
Constructs a uniform scaling matrix of size N x N.
Puts s on every diagonal entry, zeros elsewhere.
| T | Numeric type. |
| N | Dimension of the square matrix. |
| s | Uniform scale factor. |
|
constexpr |
Constructs a 4x4 3D non-uniform scaling matrix.
Scales X, Y, Z axes independently; leaves W = 1.
| sx | Scale in X direction. |
| sy | Scale in Y direction. |
| sz | Scale in Z direction. |
|
constexpr |
Constructs a 2D scaling matrix.
Creates a 2x2 matrix that scales points in 2D space.
| tx | Scale in X direction. |
| ty | Scale in Y direction. |
|
constexpr |
Computes the trace (sum of diagonal elements) of a square matrix.
Sums the elements on the main diagonal of the matrix.
| a | The matrix. |
|
constexpr |
Applies a 3D translation to a 4x4 matrix using a vector.
Multiplies the input matrix by a translation matrix constructed from the given vector.
| m | The matrix to transform. |
| v | The translation vector. |
|
constexpr |
Constructs a 4x4 3D translation matrix.
| tx | Translation along X axis. |
| ty | Translation along Y axis. |
| tz | Translation along Z axis. |
|
constexpr |
Constructs a 3x3 2D translation matrix.
Creates a 3x3 matrix for translating points in 2D homogeneous coordinates.
| tx | Translation along X axis. |
| ty | Translation along Y axis. |
|
constexpr |
Transposes the given matrix (rows become columns).
Swaps the rows and columns of the input matrix.
| a | The matrix to transpose. |
|
constexpr |
Generates a zero matrix of size Rows x Cols.
Returns a matrix filled with zeros.