IceShard 1
A personal game engine project, with development focused on 2D/2.5D games.
Loading...
Searching...
No Matches
decompose.hxx
Go to the documentation of this file.
1
3
4#pragma once
6#include <ice/math/rotate.hxx>
7#include <ice/math/scale.hxx>
9
10namespace ice::math
11{
12
13 template<typename T>
14 constexpr void decompose(
15 mat<4, 4, T> matrix,
16 vec3f* pos,
17 vec3f* scale,
18 vec<3, rad>* angle
19 ) noexcept;
20
21
22 template<typename T>
23 constexpr void decompose(
24 mat<4, 4, T> matrix,
25 vec3f* pos,
26 vec3f* scale,
27 vec<3, rad>* angle
28 ) noexcept
29 {
30 if (scale != nullptr)
31 {
32 *scale = ice::math::scale(matrix);
33 }
34
35 matrix = ice::math::ortho_normalize(matrix);
36
37 if (pos != nullptr)
38 {
39 *pos = ice::math::translation(matrix);
40 }
41 if (angle != nullptr)
42 {
43 *angle = ice::math::rotation(matrix);
44 }
45 }
46
47} // namespace ice::math
Definition algorithm.hxx:8
mat< Size, 1, T > vec
Definition vector.hxx:172
constexpr auto ortho_normalize(mat< 4, 4, T > matrix) noexcept -> mat< 4, 4, T >
Definition matrix_operations.hxx:224
constexpr void decompose(mat< 4, 4, T > matrix, vec3f *pos, vec3f *scale, vec< 3, rad > *angle) noexcept
Definition decompose.hxx:23
constexpr auto translation(mat< 3, 3, f32 > const &matrix) noexcept -> vec< 2, f32 >
Definition translate.hxx:45
auto rotation(mat< 4, 4, f32 > const &matrix) noexcept -> vec< 3, rad >
Definition rotate.hxx:72
vec< 3, f32 > vec3f
Definition vector.hxx:182
constexpr auto scale(vec< 3, f32 > v) noexcept -> mat< 4, 4, f32 >
Definition scale.hxx:26
Definition matrix.hxx:12