sandbox
Loading...
Searching...
No Matches
matrix_cast.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: MIT
27#ifndef LIBSBX_MATH_MATRIX_CAST_HPP_
28#define LIBSBX_MATH_MATRIX_CAST_HPP_
29
30#include <type_traits>
31#include <concepts>
32#include <utility>
33
36#include <libsbx/math/matrix3x3.hpp>
37#include <libsbx/math/matrix4x4.hpp>
38#include <libsbx/math/quaternion.hpp>
39
40namespace sbx::math {
41
49template<typename Type, typename Return, typename... Args>
50concept dispatcher_for = requires() {
51 { std::remove_cvref_t<Type>::invoke(std::declval<Args>()...) } -> std::same_as<Return>;
52};
53
55namespace detail {
56
63template<typename To, typename From>
64struct matrix_cast_impl;
65
66} // namespace detail
79template<typename To, typename From>
80requires (dispatcher_for<detail::matrix_cast_impl<To, std::remove_cvref_t<From>>, To, From>)
81[[nodiscard]] constexpr auto matrix_cast(const From& from) -> To;
82
87 vector3 position;
88 quaternion rotation;
89 vector3 scale;
90}; // struct decompose_result
91
99[[nodiscard]] auto decompose(const matrix4x4& matrix) noexcept -> decompose_result;
100
101} // namespace sbx::math
102
103#include <libsbx/math/matrix_cast.ipp>
104
105#endif // LIBSBX_MATH_MATRIX_CAST_HPP_
Definition: matrix4x4.hpp:26
Definition: quaternion.hpp:25
Definition: vector3.hpp:23
Concept describing a valid dispatcher implementation.
Definition: matrix_cast.hpp:50
Core numeric concepts and type traits.
Generic fixed-size matrix type.
Result of matrix decomposition.
Definition: matrix_cast.hpp:86