IceShard 1
A personal game engine project, with development focused on 2D/2.5D games.
Loading...
Searching...
No Matches
scale.hxx
Go to the documentation of this file.
1
3
4#pragma once
5#include <ice/math/vector.hxx>
8
9namespace ice::math
10{
11
12 constexpr auto scale2d(vec<2, f32> v) noexcept -> mat<2, 2, f32>;
13 constexpr auto scale(vec<3, f32> v) noexcept -> mat<4, 4, f32>;
14
15 constexpr auto scale2d(mat<2, 2, f32> left, vec<2, f32> right) noexcept -> mat<2, 2, f32>;
16 constexpr auto scale(mat<4, 4, f32> left, vec<3, f32> right) noexcept -> mat<4, 4, f32>;
17
18 constexpr auto scale(mat<4, 4, f32> const& matrix) noexcept -> vec<3, f32>;
19
20
21 constexpr auto scale2d(vec<2, f32> v) noexcept -> mat<2, 2, f32>
22 {
23 return scale2d(mat2x2_identity, v);
24 }
25
26 constexpr auto scale(vec<3, f32> v) noexcept -> mat<4, 4, f32>
27 {
28 return scale(mat4x4_identity, v);
29 }
30
31 constexpr auto scale2d(mat<2, 2, f32> left, vec<2, f32> right) noexcept -> mat<2, 2, f32>
32 {
33 mat<2, 2, f32> temp{ };
34 temp.v[0][0] = right.v[0][0];
35 temp.v[1][1] = right.v[0][1];
36 return mul(left, temp);
37 }
38
39 constexpr auto scale(mat<4, 4, f32> left, vec<3, f32> right) noexcept -> mat<4, 4, f32>
40 {
41 mat<4, 4, f32> temp{ };
42 temp.v[0][0] = right.v[0][0];
43 temp.v[1][1] = right.v[0][1];
44 temp.v[2][2] = right.v[0][2];
45 temp.v[3][3] = 1.f;
46 return mul(left, temp);
47 }
48
49 constexpr auto scale(mat<4, 4, f32> const& matrix) noexcept -> vec<3, f32>
50 {
51 return {
52 length(vec<3, f32>{matrix.v[0]}),
53 length(vec<3, f32>{matrix.v[1]}),
54 length(vec<3, f32>{matrix.v[2]})
55 };
56 }
57
58} // namespace ice::math
Definition algorithm.hxx:8
static constexpr auto mat2x2_identity
Definition matrix.hxx:77
constexpr auto mul(U first, Args... args) noexcept
Definition algorithm.hxx:38
constexpr auto scale2d(vec< 2, f32 > v) noexcept -> mat< 2, 2, f32 >
Definition scale.hxx:21
mat< Size, 1, T > vec
Definition vector.hxx:172
static constexpr auto mat4x4_identity
Definition matrix.hxx:79
constexpr auto length(vec< Size, T > left) noexcept -> T
Definition vector_operations.hxx:110
constexpr auto scale(vec< 3, f32 > v) noexcept -> mat< 4, 4, f32 >
Definition scale.hxx:26
Definition matrix.hxx:12
T v[count_columns][count_rows]
Definition matrix.hxx:17