IceShard
1
A personal game engine project, with development focused on 2D/2.5D games.
Toggle main menu visibility
Loading...
Searching...
No Matches
math
public
ice
math
scale.hxx
Go to the documentation of this file.
1
3
4
#pragma once
5
#include <
ice/math/vector.hxx
>
6
#include <
ice/math/matrix/matrix_operations.hxx
>
7
#include <
ice/math/matrix/matrix_operators.hxx
>
8
9
namespace
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
matrix_operations.hxx
matrix_operators.hxx
ice::math
Definition
algorithm.hxx:8
ice::math::mat2x2_identity
static constexpr auto mat2x2_identity
Definition
matrix.hxx:77
ice::math::mul
constexpr auto mul(U first, Args... args) noexcept
Definition
algorithm.hxx:38
ice::math::scale2d
constexpr auto scale2d(vec< 2, f32 > v) noexcept -> mat< 2, 2, f32 >
Definition
scale.hxx:21
ice::math::vec
mat< Size, 1, T > vec
Definition
vector.hxx:172
ice::math::mat4x4_identity
static constexpr auto mat4x4_identity
Definition
matrix.hxx:79
ice::math::length
constexpr auto length(vec< Size, T > left) noexcept -> T
Definition
vector_operations.hxx:110
ice::math::scale
constexpr auto scale(vec< 3, f32 > v) noexcept -> mat< 4, 4, f32 >
Definition
scale.hxx:26
ice::math::mat
Definition
matrix.hxx:12
ice::math::mat::v
T v[count_columns][count_rows]
Definition
matrix.hxx:17
vector.hxx
Generated by
1.18.0