Raven Engine v0.1
Loading...
Searching...
No Matches
MatrixOps.h File Reference

Core Matrix arithmetic and geometric operations for Crux. More...

#include <Crux/Types/Matrix.h>
#include <Crux/Types/Vector.h>
#include <Crux/Math/BasicMath.h>
#include <cmath>

Namespaces

namespace  Crux

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.

Detailed Description

Core Matrix arithmetic and geometric operations for Crux.

Provides templated implementations of common matrix operations such as addition, multiplication, inversion, normalization and more. All functions are constexpr-friendly for compile-time use with Vector<T, N> types.

Author
Philip