SA_Maths
Sapphire Suite's C++ Maths Library
Loading...
Searching...
No Matches
Vector4.hpp
Go to the documentation of this file.
1// Copyright (c) 2023 Sapphire development team. All Rights Reserved.
2
3#pragma once
4
5#ifndef SAPPHIRE_MATHS_VECTOR4_GUARD
6#define SAPPHIRE_MATHS_VECTOR4_GUARD
7
8#include <cstdint>
9#include <limits>
10
11#include <SA/Maths/Debug.hpp>
12
14
15
26namespace SA
27{
28 template <typename T>
29 struct Vec2;
30
31 template <typename T>
32 struct Vec3;
33
39 template <typename T>
40 struct Vec4
41 {
43 using Type = T;
44
46 T x = T();
47
49 T y = T();
50
52 T z = T();
53
55 T w = T();
56
57
58//{ Constructors
59
61 Vec4() = default;
62
71 constexpr Vec4(T _x, T _y, T _z, T _w) noexcept;
72
78 constexpr Vec4(T _scale) noexcept;
79
80
82 Vec4(Vec4&&) = default;
83
85 Vec4(const Vec4&) = default;
86
94 template <typename TIn>
95 constexpr Vec4(const Vec4<TIn>&_other) noexcept;
96
106 template <typename TIn>
107 constexpr Vec4(const Vec2<TIn>&_other, T _z = T(0), T _w = T(0)) noexcept;
108
117 template <typename TIn>
118 constexpr Vec4(const Vec2<TIn>&_v1, const Vec2<TIn>& _v2) noexcept;
119
128 template <typename TIn>
129 constexpr Vec4(const Vec3<TIn>&_other, T _w = T(0)) noexcept;
130
131//}
132
133//{ Equals
134
140 constexpr bool IsZero() const noexcept;
141
150 constexpr bool Equals(const Vec4& _other, T _epsilon = std::numeric_limits<T>::epsilon()) const noexcept;
151
152
160 constexpr bool operator==(const Vec4 & _rhs) const noexcept;
161
169 constexpr bool operator!=(const Vec4 & _rhs) const noexcept;
170//}
171
172//{ Acccessors
173
179 T* Data() noexcept;
180
186 const T* Data() const noexcept;
187
188
196 T& operator[](uint32_t _index);
197
205 const T& operator[](uint32_t _index) const;
206
207//}
208
209//{ Operators
210
216 Vec4& operator=(Vec4&&) = default;
217
223 Vec4& operator=(const Vec4&) = default;
224
225//}
226 };
227
228
229#if SA_LOGGER_IMPL
230
242 template <typename T>
243 std::string ToString(const Vec4<T>& _v);
244
245#endif
246
247
248//{ Aliases
249
252
255
258
261
262
264 template <typename T>
266
269
272
275
278
279//}
280}
281
290#include <SA/Maths/Space/Vector4.inl>
291
292#endif // GUARD
Maths module Debug compatibility definition.
Equals method implementation.
Vector 2 Sapphire's class.
Definition Vector2.hpp:41
Vector 3 Sapphire-Maths class.
Definition Vector3.hpp:43
Vector 4 Sapphire-Maths class.
Definition Vector4.hpp:41
constexpr bool IsZero() const noexcept
Whether this vector is a zero vector.
constexpr Vec4(T _x, T _y, T _z, T _w) noexcept
Value constructor.
constexpr Vec4(const Vec2< TIn > &_other, T _z=T(0), T _w=T(0)) noexcept
Value constructor from Vec2.
T * Data() noexcept
Getter of vector data
T w
Vector's W component (stored after xyz).
Definition Vector4.hpp:55
Vec4()=default
Default constructor.
constexpr Vec4(T _scale) noexcept
Scale Value constructor.
constexpr Vec4(const Vec4< TIn > &_other) noexcept
Value constructor from another Vec4 type.
T Type
Type of the Vector.
Definition Vector4.hpp:43
Vec4(Vec4 &&)=default
Default move constructor.
constexpr bool Equals(const Vec4 &_other, T _epsilon=std::numeric_limits< T >::epsilon()) const noexcept
Compare 2 vector.
T y
Vector's Y component (axis value).
Definition Vector4.hpp:49
Vec4(const Vec4 &)=default
Default copy constructor.
T z
Vector's Z component (axis value).
Definition Vector4.hpp:52
T x
Vector's X component (axis value).
Definition Vector4.hpp:46