10#include <mv/math/detail/Matrix4Ops.hpp>
15 requires std::is_floating_point_v<T>
72 std::size_t index)
const noexcept
79 std::size_t index)
const noexcept
83 ComponentAt(Rows_[0], index), ComponentAt(Rows_[1], index),
84 ComponentAt(Rows_[2], index), ComponentAt(Rows_[3], index));
88 std::size_t
column)
const noexcept
96 using Ops = detail::Matrix4Ops<T>;
97 if constexpr (Ops::HasNative)
99 return RowVector::FromNative(
100 Ops::Transform(
vector.Components_, Rows_[0].Components_,
101 Rows_[1].Components_, Rows_[2].Components_,
102 Rows_[3].Components_));
111 using Ops = detail::Matrix4Ops<T>;
112 if constexpr (Ops::HasNative)
115 Rows_[0].Components_, Rows_[1].Components_,
116 Rows_[2].Components_, Rows_[3].Components_,
117 right.Rows_[0].Components_,
right.Rows_[1].Components_,
118 right.Rows_[2].Components_,
right.Rows_[3].Components_));
121 return Mat4(
right.TransformHomogeneous(Rows_[0]),
122 right.TransformHomogeneous(Rows_[1]),
123 right.TransformHomogeneous(Rows_[2]),
124 right.TransformHomogeneous(Rows_[3]));
129 using Ops = detail::Matrix4Ops<T>;
130 if constexpr (Ops::HasNative)
133 Ops::Transpose(Rows_[0].Components_, Rows_[1].Components_,
134 Rows_[2].Components_, Rows_[3].Components_));
141 using Ops = detail::Matrix4Ops<T>;
142 if constexpr (Ops::HasNative)
144 return Ops::Determinant(
145 Rows_[0].Components_, Rows_[1].Components_,
146 Rows_[2].Components_, Rows_[3].Components_);
149 return Element(0
U, 0
U) * MinorDeterminant(0
U, 0
U) -
150 Element(0
U, 1U) * MinorDeterminant(0
U, 1U) +
151 Element(0
U, 2U) * MinorDeterminant(0
U, 2U) -
152 Element(0
U, 3U) * MinorDeterminant(0
U, 3U);
157 using Ops = detail::Matrix4Ops<T>;
158 if constexpr (Ops::HasNative)
160 const typename Ops::Rows
inverse = Ops::InverseUnchecked(
161 Rows_[0].Components_, Rows_[1].Components_,
162 Rows_[2].Components_, Rows_[3].Components_);
218 const Mat4&,
const Mat4&)
noexcept =
default;
222 std::size_t index)
noexcept
244 std::size_t destination = 0U;
245 for (std::size_t row = 0U; row < 4U; ++row)
247 if (row == removedRow)
251 for (std::size_t column = 0U; column < 4U; ++column)
253 if (column != removedColumn)
255 minor[destination++] =
Element(row, column);
259 return minor[0] * (minor[4] * minor[8] - minor[5] * minor[7]) -
260 minor[1] * (minor[3] * minor[8] - minor[5] * minor[6]) +
261 minor[2] * (minor[3] * minor[7] - minor[4] * minor[6]);
264 template <
typename Ops = detail::Matrix4Ops<T>>
265 [[nodiscard]]
static Mat4 FromNativeRows(
266 const typename Ops::Rows& rows)
noexcept
267 requires Ops::HasNative
269 return Mat4(RowVector::FromNative(rows.Row0),
270 RowVector::FromNative(rows.Row1),
271 RowVector::FromNative(rows.Row2),
272 RowVector::FromNative(rows.Row3));
278 template <
typename T>
279 requires std::is_floating_point_v<T>
292static_assert(std::is_trivially_copyable_v<mv::math::Mat4f>);
293static_assert(std::is_standard_layout_v<mv::math::Mat4f>);
296static_assert(std::is_trivially_copyable_v<mv::math::Mat4d>);
297static_assert(std::is_standard_layout_v<mv::math::Mat4d>);
Mat4 operator*(const Mat4 &right) const noexcept
static constexpr Mat4 Zero() noexcept
static constexpr Mat4 Identity() noexcept
T Determinant() const noexcept
constexpr Mat4(T m11, T m12, T m13, T m14, T m21, T m22, T m23, T m24, T m31, T m32, T m33, T m34, T m41, T m42, T m43, T m44) noexcept
std::optional< Mat4 > TryInverse() const noexcept
constexpr const RowVector & Row(std::size_t index) const noexcept
friend constexpr bool operator==(const Mat4 &, const Mat4 &) noexcept=default
constexpr T Element(std::size_t row, std::size_t column) const noexcept
RowVector TransformHomogeneous(const RowVector &vector) const noexcept
constexpr RowVector Column(std::size_t index) const noexcept
constexpr Mat4() noexcept
bool IsFinite() const noexcept
Mat4 Transposed() const noexcept
constexpr Mat4(const RowVector &row0, const RowVector &row1, const RowVector &row2, const RowVector &row3) noexcept
Vec3< T > operator*(const Vec3< T > &vector, const Mat3< T > &matrix) noexcept