template<class T>
nCine::Primitives::Matrix4x4 class

Four-by-four matrix.

Column-major 4×4 matrix stored as four Vector4 columns. Provides component-wise and scalar arithmetic, matrix and vector multiplication, transposition and inversion, in-place and standalone transform builders (translation, rotation, scaling) and the Ortho(), Frustum() and Perspective() projection builders.

Public static functions

static auto Translation(T xx, T yy, T zz) -> Matrix4x4
Creates a translation matrix.
static auto Translation(const Vector3<T>& v) -> Matrix4x4
static auto RotationX(T radians) -> Matrix4x4
Creates a rotation matrix around the X axis.
static auto RotationY(T radians) -> Matrix4x4
Creates a rotation matrix around the Y axis.
static auto RotationZ(T radians) -> Matrix4x4
Creates a rotation matrix around the Z axis.
static auto Scaling(T xx, T yy, T zz) -> Matrix4x4
Creates a non-uniform scaling matrix.
static auto Scaling(const Vector3<T>& v) -> Matrix4x4
static auto Scaling(T s) -> Matrix4x4
Creates a uniform scaling matrix.
static auto Ortho(T left, T right, T bottom, T top, T near, T far) -> Matrix4x4
Creates an orthographic projection matrix.
static auto Frustum(T left, T right, T bottom, T top, T near, T far) -> Matrix4x4
Creates a perspective projection matrix from frustum boundaries.
static auto Perspective(T fovY, T aspect, T near, T far) -> Matrix4x4
Creates a perspective projection matrix from a vertical field of view and aspect ratio.

Constructors, destructors, conversion operators

Matrix4x4() constexpr noexcept
Matrix4x4(NoInitT) explicit noexcept
Matrix4x4(const Vector4<T>& v0, const Vector4<T>& v1, const Vector4<T>& v2, const Vector4<T>& v3) noexcept

Public functions

void Set(const Vector4<T>& v0, const Vector4<T>& v1, const Vector4<T>& v2, const Vector4<T>& v3)
auto Data() -> T*
auto Data() const -> const T*
auto operator[](std::size_t index) -> Vector4<T>&
auto operator[](std::size_t index) const -> const Vector4<T>&
auto operator==(const Matrix4x4& m) const -> bool
auto operator!=(const Matrix4x4& m) const -> bool
auto operator-() const -> Matrix4x4
auto operator+=(const Matrix4x4& m) -> Matrix4x4&
auto operator-=(const Matrix4x4& m) -> Matrix4x4&
auto operator*=(const Matrix4x4& m) -> Matrix4x4&
auto operator/=(const Matrix4x4& m) -> Matrix4x4&
auto operator+=(T s) -> Matrix4x4&
auto operator-=(T s) -> Matrix4x4&
auto operator*=(T s) -> Matrix4x4&
auto operator/=(T s) -> Matrix4x4&
auto operator*(const Vector4<T>& v) const -> Vector4<T>
auto operator*(const Vector3<T>& v) const -> Vector3<T>
auto operator+(const Matrix4x4& m) const -> Matrix4x4
auto operator-(const Matrix4x4& m) const -> Matrix4x4
auto operator*(const Matrix4x4& m) const -> Matrix4x4
auto operator/(const Matrix4x4& m) const -> Matrix4x4
auto operator+(T s) const -> Matrix4x4
auto operator-(T s) const -> Matrix4x4
auto operator*(T s) const -> Matrix4x4
auto operator/(T s) const -> Matrix4x4
auto Transposed() const -> Matrix4x4
Returns the transpose of the matrix.
auto Transpose() -> Matrix4x4&
Transposes the matrix in place and returns it.
auto Inverse() const -> Matrix4x4
Returns the inverse of the matrix.
auto Translate(T xx, T yy, T zz) -> Matrix4x4&
Applies a translation to the matrix in place.
auto Translate(const Vector3<T>& v) -> Matrix4x4&
auto RotateX(T radians) -> Matrix4x4&
Applies a rotation around the X axis to the matrix in place.
auto RotateY(T radians) -> Matrix4x4&
Applies a rotation around the Y axis to the matrix in place.
auto RotateZ(T radians) -> Matrix4x4&
Applies a rotation around the Z axis to the matrix in place.
auto Scale(T xx, T yy, T zz) -> Matrix4x4&
Applies a non-uniform scaling to the matrix in place.
auto Scale(const Vector3<T>& v) -> Matrix4x4&
auto Scale(T s) -> Matrix4x4&
Applies a uniform scaling to the matrix in place.

Constants

static const Matrix4x4 Zero
Matrix with all elements set to zero.
static const Matrix4x4 Identity
Identity matrix.

Friends

template<class S>
auto operator*(const Vector4<S>& v, const Matrix4x4<S>& m) -> Vector4<S>
template<class S>
auto operator*(const Vector3<S>& v, const Matrix4x4<S>& m) -> Vector3<S>
template<class S>
auto operator*(S s, const Matrix4x4<S>& m) -> Matrix4x4<S>

Function documentation

template<class T>
static Matrix4x4 nCine::Primitives::Matrix4x4<T>::Translation(const Vector3<T>& v)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<class T>
static Matrix4x4 nCine::Primitives::Matrix4x4<T>::Scaling(const Vector3<T>& v)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<class T>
Matrix4x4& nCine::Primitives::Matrix4x4<T>::Translate(const Vector3<T>& v)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<class T>
Matrix4x4& nCine::Primitives::Matrix4x4<T>::Scale(const Vector3<T>& v)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.