2#ifndef LIBSBX_MATH_MATRIX4X4_HPP_
3#define LIBSBX_MATH_MATRIX4X4_HPP_
14#include <fmt/format.h>
17#include <libsbx/math/vector3.hpp>
18#include <libsbx/math/vector4.hpp>
20#include <libsbx/math/matrix3x3.hpp>
30 template<scalar Other>
33 inline static constexpr auto x_axis = std::size_t{0u};
34 inline static constexpr auto y_axis = std::size_t{1u};
35 inline static constexpr auto z_axis = std::size_t{2u};
36 inline static constexpr auto w_axis = std::size_t{3u};
40 using value_type = base_type::value_type;
41 using reference = base_type::reference;
42 using const_reference = base_type::const_reference;
43 using size_type = base_type::size_type;
50 using base_type::base_type;
54 template<
typename Column0,
typename Column1,
typename Column2,
typename Column3>
62 template<scalar Other>
64 Other x0, Other x1, Other x2, Other x3,
65 Other y0, Other y1, Other y2, Other y3,
66 Other z0, Other z1, Other z2, Other z3,
67 Other w0, Other w1, Other w2, Other w3
70 template<scalar Other>
71 constexpr basic_matrix4x4(
const Other v00,
const Other v11,
const Other v22,
const Other v33)
noexcept;
73 template<scalar Other>
95 [[nodiscard]]
constexpr static auto orthographic(
const value_type left,
const value_type right,
const value_type bottom,
const value_type top)
noexcept ->
basic_matrix4x4;
97 [[nodiscard]]
constexpr static auto orthographic(
const value_type left,
const value_type right,
const value_type bottom,
const value_type top,
const value_type near,
const value_type far)
noexcept ->
basic_matrix4x4;
115 constexpr auto operator[](size_type index)
const noexcept ->
const column_type&;
117 constexpr auto operator[](size_type index)
noexcept ->
column_type&;
121template<scalar Lhs, scalar Rhs>
124template<scalar Lhs, scalar Rhs>
127template<scalar Lhs, scalar Rhs>
130template<scalar Lhs, scalar Rhs>
133template<scalar Lhs, scalar Rhs>
136template<scalar Lhs, scalar Rhs>
147template<sbx::math::scalar Type>
148struct fmt::formatter<sbx::math::basic_matrix4x4<Type>> {
150 template<
typename ParseContext>
151 constexpr auto parse(ParseContext& context) ->
decltype(context.begin()) {
152 return context.begin();
155 template<
typename FormatContext>
157 if constexpr (sbx::math::is_floating_point_v<Type>) {
158 return fmt::format_to(context.out(),
159 "\n{:.2f}, {:.2f}, {:.2f}, {:.2f}\n{:.2f}, {:.2f}, {:.2f}, {:.2f}\n{:.2f}, {:.2f}, {:.2f}, {:.2f}\n{:.2f}, {:.2f}, {:.2f}, {:.2f}",
160 matrix[0][0], matrix[1][0], matrix[2][0], matrix[3][0],
161 matrix[0][1], matrix[1][1], matrix[2][1], matrix[3][1],
162 matrix[0][2], matrix[1][2], matrix[2][2], matrix[3][2],
163 matrix[0][3], matrix[1][3], matrix[2][3], matrix[3][3]
166 return fmt::format_to(context.out(),
167 "\n{}, {}, {}, {}\n{}, {}, {}, {}\n{}, {}, {}, {}\n{}, {}, {}, {}",
168 matrix[0][0], matrix[1][0], matrix[2][0], matrix[3][0],
169 matrix[0][1], matrix[1][1], matrix[2][1], matrix[3][1],
170 matrix[0][2], matrix[1][2], matrix[2][2], matrix[3][2],
171 matrix[0][3], matrix[1][3], matrix[2][3], matrix[3][3]
178#include <libsbx/math/matrix4x4.ipp>
Angle types and utilities.
constexpr auto operator/(basic_degree< Type > lhs, const Other rhs) noexcept -> basic_degree< Type >
Divides a degree value by a scalar factor.
Definition: angle.ipp:112
constexpr auto operator+(basic_degree< Type > lhs, const basic_degree< Other > &rhs) noexcept -> basic_degree< Type >
Adds two degree values.
Definition: angle.ipp:90
constexpr auto operator*(basic_degree< Type > lhs, const Other rhs) noexcept -> basic_degree< Type >
Multiplies a degree value by a scalar factor.
Definition: angle.ipp:105
Unified angle type stored internally in radians.
Definition: angle.hpp:591
Definition: matrix3x3.hpp:26
Definition: matrix4x4.hpp:26
Fixed-size column-major matrix.
Definition: matrix.hpp:48
static constexpr auto identity(const value_type value=static_cast< value_type >(1)) noexcept -> basic_matrix
Constructs an identity matrix.
Definition: matrix.ipp:113
Definition: vector3.hpp:23
Definition: vector4.hpp:24
Concept for scalar numeric types.
Definition: concepts.hpp:150
Core numeric concepts and type traits.
Generic fixed-size matrix type.