IceShard 1
A personal game engine project, with development focused on 2D/2.5D games.
Loading...
Searching...
No Matches
vector_operators.hxx
Go to the documentation of this file.
1
3
4#pragma once
6
7namespace ice::math
8{
9
10 template<u32 Size, typename T>
11 constexpr auto operator-(vec<Size, T> left) noexcept -> vec<Size, T>;
12
13 template<u32 Size, typename T, typename U = T>
14 constexpr auto operator+(vec<Size, T> left, vec<Size, U> right) noexcept -> vec<Size, T>;
15
16 template<u32 Size, typename T, typename U = T>
17 constexpr auto operator-(vec<Size, T> left, vec<Size, U> right) noexcept -> vec<Size, T>;
18
19 template<u32 Size, typename T, typename U = T>
20 constexpr auto operator*(vec<Size, T> left, U right) noexcept -> vec<Size, T>;
21
22 template<u32 Size, typename T, typename U = T>
23 constexpr auto operator/(vec<Size, T> left, U right) noexcept -> vec<Size, T>;
24
25
26 template<u32 Size, typename T>
27 constexpr auto operator-(vec<Size, T> left) noexcept -> vec<Size, T>
28 {
29 vec<Size, T> result{ };
30 for (u32 i = 0; i < Size; ++i)
31 {
32 result.v[0][i] = -left.v[0][i];
33 }
34 return result;
35 }
36
37 template<u32 Size, typename T, typename U>
38 constexpr auto operator+(vec<Size, T> left, vec<Size, U> right) noexcept -> vec<Size, T>
39 {
40 return ice::math::add(left, right);
41 }
42
43 template<u32 Size, typename T, typename U>
44 constexpr auto operator+=(vec<Size, T>& left, vec<Size, U> right) noexcept -> vec<Size, T>&
45 {
46 left = ice::math::add(left, right);
47 return left;
48 }
49
50 template<u32 Size, typename T, typename U>
51 constexpr auto operator-(vec<Size, T> left, vec<Size, U> right) noexcept -> vec<Size, T>
52 {
53 return ice::math::sub(left, right);
54 }
55
56 template<u32 Size, typename T, typename U>
57 constexpr auto operator-=(vec<Size, T>& left, vec<Size, U> right) noexcept -> vec<Size, T>&
58 {
59 left = ice::math::sub(left, right);
60 return left;
61 }
62
63 template<u32 Size, typename T, typename U>
64 constexpr auto operator*(vec<Size, T> left, U right) noexcept -> vec<Size, T>
65 {
66 return ice::math::mul(left, right);
67 }
68
69 template<u32 Size, typename T, typename U>
70 constexpr auto operator/(vec<Size, T> left, U right) noexcept -> vec<Size, T>
71 {
72 return ice::math::div(left, right);
73 }
74
75} // namespace ice::math
Definition algorithm.hxx:8
constexpr auto mul(U first, Args... args) noexcept
Definition algorithm.hxx:38
constexpr auto div(U first, Args... args) noexcept
Definition algorithm.hxx:46
constexpr auto operator+=(vec< Size, T > &left, vec< Size, U > right) noexcept -> vec< Size, T > &
Definition vector_operators.hxx:44
constexpr auto operator-(arr_t< Size, T > left) noexcept -> arr_t< Size, T >
Definition array_operators.hxx:45
mat< Size, 1, T > vec
Definition vector.hxx:172
constexpr auto operator*(ScalarType left, NumberType right) noexcept -> ScalarType
Definition angles.hxx:158
constexpr auto operator/(ScalarType left, NumberType right) noexcept -> ScalarType
Definition angles.hxx:164
constexpr auto add(arr_t< Size, T > left, arr_t< Size, U > right) noexcept -> arr_t< Size, T >
Definition array_operations.hxx:71
constexpr auto operator-=(vec< Size, T > &left, vec< Size, U > right) noexcept -> vec< Size, T > &
Definition vector_operators.hxx:57
constexpr auto operator+(arr_t< Size, T > left, arr_t< Size, U > right) noexcept -> arr_t< Size, T >
Definition array_operators.hxx:56
constexpr auto sub(U first, Args... args) noexcept
Definition algorithm.hxx:30
std::uint32_t u32
Definition types.hxx:26
T v[count_columns][count_rows]
Definition matrix.hxx:17