LiteFX 0.3.1.2022
Computer Graphics Engine
math.hpp
1#pragma once
2
3#include <litefx/core.h>
4
5#if !defined (LITEFX_MATH_API)
6# if defined(LiteFX_Math_EXPORTS) && (defined _WIN32 || defined WINCE)
7# define LITEFX_MATH_API __declspec(dllexport)
8# elif (defined(LiteFX_Math_EXPORTS) || defined(__APPLE__)) && defined __GNUC__ && __GNUC__ >= 4
9# define LITEFX_MATH_API __attribute__ ((visibility ("default")))
10# elif !defined(LiteFX_Math_EXPORTS) && (defined _WIN32 || defined WINCE)
11# define LITEFX_MATH_API __declspec(dllimport)
12# endif
13#endif
14
15#ifndef LITEFX_MATH_API
16# define LITEFX_MATH_API
17#endif
18
19#if defined(BUILD_WITH_GLM)
20#include <glm/glm.hpp>
21#endif
22
23#if defined(BUILD_WITH_DIRECTX_MATH)
24#include <DirectXMath.h>
25#endif
26
27#include <litefx/vector.hpp>
28#include <litefx/matrix.hpp>
29
30namespace LiteFX::Math {
31 using namespace LiteFX;
32
33 using Byte = uint8_t;
34 using Int16 = int16_t;
35 using UInt16 = uint16_t;
36 using Int32 = int32_t;
37 using UInt32 = uint32_t;
38 using Int64 = int64_t;
39 using UInt64 = uint64_t;
40 using Float = float_t;
41 using Double = double_t;
42
43#pragma region Vector
44 class LITEFX_MATH_API Vector1f : public Vector<Float, 1> {
45 public:
46 Vector1f() noexcept;
47 Vector1f(const Float& v) noexcept;
48 Vector1f(const Vector1f&) noexcept;
49 Vector1f(const Vector<Float, 1>&) noexcept;
50 Vector1f(Vector1f&&) noexcept;
51 Vector1f(Vector<Float, 1>&&) noexcept;
52 //virtual ~Vector1f() noexcept = default;
53
54 public:
55 inline Vector1f& operator=(const Vector<Float, 1>& _other) noexcept;
56 inline Vector1f& operator=(Vector<Float, 1>&& _other) noexcept;
57 inline Vector1f& operator=(const Array<Float>& _other) noexcept;
58 inline Vector1f& operator=(const Vector1f& _other) noexcept;
59 inline Vector1f& operator=(Vector1f&& _other) noexcept;
60 inline const Float& operator[](const unsigned int& i) const noexcept;
61 inline Float& operator[](const unsigned int& i) noexcept;
62 inline operator Array<Float>() noexcept;
63
64#if defined(BUILD_WITH_GLM)
65 public:
66 Vector1f(const glm::f32vec1& v) noexcept;
67 Vector1f(glm::f32vec1&& v) noexcept;
68 inline operator glm::f32vec1() noexcept;
69#endif
70
71#if defined(BUILD_WITH_DIRECTX_MATH)
72 public:
73 Vector1f(const DirectX::XMVECTOR& v) noexcept;
74 Vector1f(DirectX::XMVECTOR&& v) noexcept;
75 inline operator DirectX::XMVECTOR() noexcept;
76#endif
77 };
78
79 class LITEFX_MATH_API Vector1u : public Vector<UInt32, 1> {
80 public:
81 Vector1u() noexcept;
82 Vector1u(const UInt32& v) noexcept;
83 Vector1u(const Vector1u&) noexcept;
84 Vector1u(const Vector<UInt32, 1>&) noexcept;
85 Vector1u(Vector1u&&) noexcept;
86 Vector1u(Vector<UInt32, 1>&&) noexcept;
87 //virtual ~Vector1u() noexcept = default;
88 inline operator UInt32() noexcept;
89
90 public:
91 inline Vector1u& operator=(const Vector<UInt32, 1>& _other) noexcept;
92 inline Vector1u& operator=(Vector<UInt32, 1>&& _other) noexcept;
93 inline Vector1u& operator=(const Array<UInt32>& _other) noexcept;
94 inline Vector1u& operator=(const Vector1u& _other) noexcept;
95 inline Vector1u& operator=(Vector1u&& _other) noexcept;
96 inline const UInt32& operator[](const unsigned int& i) const noexcept;
97 inline UInt32& operator[](const unsigned int& i) noexcept;
98 inline operator Array<UInt32>() noexcept;
99
100#if defined(BUILD_WITH_GLM)
101 public:
102 Vector1u(const glm::u32vec1& v) noexcept;
103 Vector1u(glm::u32vec1&& v) noexcept;
104 inline operator glm::u32vec1() noexcept;
105#endif
106
107#if defined(BUILD_WITH_DIRECTX_MATH)
108 public:
109 Vector1u(const DirectX::XMVECTOR& v) noexcept;
110 Vector1u(DirectX::XMVECTOR&& v) noexcept;
111 inline operator DirectX::XMVECTOR() noexcept;
112#endif
113 };
114
115 class LITEFX_MATH_API Vector2f : public Vector<Float, 2> {
116 public:
117 Vector2f() noexcept;
118 Vector2f(const Float& v) noexcept;
119 Vector2f(const Float& x, const Float& y) noexcept;
120 Vector2f(const Vector2f&) noexcept;
121 Vector2f(const Vector<Float, 2>&) noexcept;
122 Vector2f(Vector2f&&) noexcept;
123 Vector2f(Vector<Float, 2>&&) noexcept;
124 //virtual ~Vector2f() noexcept = default;
125
126 public:
127 inline Vector2f& operator=(const Vector<Float, 2>& _other) noexcept;
128 inline Vector2f& operator=(Vector<Float, 2>&& _other) noexcept;
129 inline Vector2f& operator=(const Array<Float>& _other) noexcept;
130 inline Vector2f& operator=(const Vector2f& _other) noexcept;
131 inline Vector2f& operator=(Vector2f&& _other) noexcept;
132 inline const Float& operator[](const unsigned int& i) const noexcept;
133 inline Float& operator[](const unsigned int& i) noexcept;
134 inline operator Array<Float>() noexcept;
135
136#if defined(BUILD_WITH_GLM)
137 public:
138 Vector2f(const glm::f32vec2& v) noexcept;
139 Vector2f(glm::f32vec2&& v) noexcept;
140 inline operator glm::f32vec2() noexcept;
141#endif
142
143#if defined(BUILD_WITH_DIRECTX_MATH)
144 public:
145 Vector2f(const DirectX::XMVECTOR& v) noexcept;
146 Vector2f(DirectX::XMVECTOR&& v) noexcept;
147 Vector2f(const DirectX::XMFLOAT2& v) noexcept;
148 Vector2f(DirectX::XMFLOAT2&& v) noexcept;
149 inline operator DirectX::XMVECTOR() noexcept;
150 inline operator DirectX::XMFLOAT2() noexcept;
151#endif
152 };
153
154 class LITEFX_MATH_API Vector2u : public Vector<UInt32, 2> {
155 public:
156 Vector2u() noexcept;
157 Vector2u(const UInt32& v) noexcept;
158 Vector2u(const UInt32& x, const UInt32& y) noexcept;
159 Vector2u(const Vector2u&) noexcept;
160 Vector2u(const Vector<UInt32, 2>&) noexcept;
161 Vector2u(Vector2u&&) noexcept;
162 Vector2u(Vector<UInt32, 2>&&) noexcept;
163 //virtual ~Vector2u() noexcept = default;
164
165 public:
166 inline Vector2u& operator=(const Vector<UInt32, 2>& _other) noexcept;
167 inline Vector2u& operator=(Vector<UInt32, 2>&& _other) noexcept;
168 inline Vector2u& operator=(const Array<UInt32>& _other) noexcept;
169 inline Vector2u& operator=(const Vector2u& _other) noexcept;
170 inline Vector2u& operator=(Vector2u&& _other) noexcept;
171 inline const UInt32& operator[](const unsigned int& i) const noexcept;
172 inline UInt32& operator[](const unsigned int& i) noexcept;
173 inline operator Array<UInt32>() noexcept;
174
175#if defined(BUILD_WITH_GLM)
176 public:
177 Vector2u(const glm::u32vec2& v) noexcept;
178 Vector2u(glm::u32vec2&& v) noexcept;
179 inline operator glm::u32vec2() noexcept;
180#endif
181
182#if defined(BUILD_WITH_DIRECTX_MATH)
183 public:
184 Vector2u(const DirectX::XMVECTOR& v) noexcept;
185 Vector2u(DirectX::XMVECTOR&& v) noexcept;
186 Vector2u(const DirectX::XMUINT2& v) noexcept;
187 Vector2u(DirectX::XMUINT2&& v) noexcept;
188 inline operator DirectX::XMVECTOR() noexcept;
189 inline operator DirectX::XMUINT2() noexcept;
190#endif
191 };
192
193 class LITEFX_MATH_API Vector2i : public Vector<Int32, 2> {
194 public:
195 Vector2i() noexcept;
196 Vector2i(const Int32& v) noexcept;
197 Vector2i(const Int32& x, const Int32& y) noexcept;
198 Vector2i(const Vector2i&) noexcept;
199 Vector2i(const Vector<Int32, 2>&) noexcept;
200 Vector2i(Vector2i&&) noexcept;
201 Vector2i(Vector<Int32, 2>&&) noexcept;
202 //virtual ~Vector2i() noexcept = default;
203
204 public:
205 inline Vector2i& operator=(const Vector<Int32, 2>& _other) noexcept;
206 inline Vector2i& operator=(Vector<Int32, 2>&& _other) noexcept;
207 inline Vector2i& operator=(const Array<Int32>& _other) noexcept;
208 inline Vector2i& operator=(const Vector2i& _other) noexcept;
209 inline Vector2i& operator=(Vector2i&& _other) noexcept;
210 inline const Int32& operator[](const unsigned int& i) const noexcept;
211 inline Int32& operator[](const unsigned int& i) noexcept;
212 inline operator Array<Int32>() noexcept;
213
214#if defined(BUILD_WITH_GLM)
215 public:
216 Vector2i(const glm::i32vec2& v) noexcept;
217 Vector2i(glm::i32vec2&& v) noexcept;
218 inline operator glm::i32vec2() noexcept;
219#endif
220
221#if defined(BUILD_WITH_DIRECTX_MATH)
222 public:
223 Vector2i(const DirectX::XMVECTOR& v) noexcept;
224 Vector2i(DirectX::XMVECTOR&& v) noexcept;
225 Vector2i(const DirectX::XMINT2& v) noexcept;
226 Vector2i(DirectX::XMINT2&& v) noexcept;
227 inline operator DirectX::XMVECTOR() noexcept;
228 inline operator DirectX::XMINT2() noexcept;
229#endif
230 };
231
232 class LITEFX_MATH_API Vector3f : public Vector<Float, 3> {
233 public:
234 Vector3f() noexcept;
235 Vector3f(const Float& v) noexcept;
236 Vector3f(const Float& x, const Float& y, const Float& z) noexcept;
237 Vector3f(const Vector3f&) noexcept;
238 Vector3f(const Vector<Float, 3>&) noexcept;
239 Vector3f(Vector3f&&) noexcept;
240 Vector3f(Vector<Float, 3>&&) noexcept;
241 //virtual ~Vector3f() noexcept = default;
242
243 public:
244 inline Vector3f& operator=(const Vector<Float, 3>& _other) noexcept;
245 inline Vector3f& operator=(Vector<Float, 3>&& _other) noexcept;
246 inline Vector3f& operator=(const Array<Float>& _other) noexcept;
247 inline Vector3f& operator=(const Vector3f& _other) noexcept;
248 inline Vector3f& operator=(Vector3f&& _other) noexcept;
249 inline const Float& operator[](const unsigned int& i) const noexcept;
250 inline Float& operator[](const unsigned int& i) noexcept;
251 inline operator Array<Float>() noexcept;
252
253#if defined(BUILD_WITH_GLM)
254 public:
255 Vector3f(const glm::f32vec3& v) noexcept;
256 Vector3f(glm::f32vec3&& v) noexcept;
257 inline operator glm::f32vec3() noexcept;
258#endif
259
260#if defined(BUILD_WITH_DIRECTX_MATH)
261 public:
262 Vector3f(const DirectX::XMVECTOR& v) noexcept;
263 Vector3f(DirectX::XMVECTOR&& v) noexcept;
264 Vector3f(const DirectX::XMFLOAT3& v) noexcept;
265 Vector3f(DirectX::XMFLOAT3&& v) noexcept;
266 inline operator DirectX::XMVECTOR() noexcept;
267 inline operator DirectX::XMFLOAT3() noexcept;
268#endif
269 };
270
271 class LITEFX_MATH_API Vector3u : public Vector<UInt32, 3> {
272 public:
273 Vector3u() noexcept;
274 Vector3u(const UInt32& v) noexcept;
275 Vector3u(const UInt32& x, const UInt32& y, const UInt32& z) noexcept;
276 Vector3u(const Vector3u&) noexcept;
277 Vector3u(const Vector<UInt32, 3>&) noexcept;
278 Vector3u(Vector3u&&) noexcept;
279 Vector3u(Vector<UInt32, 3>&&) noexcept;
280 //virtual ~Vector3u() noexcept = default;
281
282 public:
283 inline Vector3u& operator=(const Vector<UInt32, 3>& _other) noexcept;
284 inline Vector3u& operator=(Vector<UInt32, 3>&& _other) noexcept;
285 inline Vector3u& operator=(const Array<UInt32>& _other) noexcept;
286 inline Vector3u& operator=(const Vector3u& _other) noexcept;
287 inline Vector3u& operator=(Vector3u&& _other) noexcept;
288 inline const UInt32& operator[](const unsigned int& i) const noexcept;
289 inline UInt32& operator[](const unsigned int& i) noexcept;
290 inline operator Array<UInt32>() noexcept;
291
292#if defined(BUILD_WITH_GLM)
293 public:
294 Vector3u(const glm::u32vec3& v) noexcept;
295 Vector3u(glm::u32vec3&& v) noexcept;
296 inline operator glm::u32vec3() noexcept;
297#endif
298
299#if defined(BUILD_WITH_DIRECTX_MATH)
300 public:
301 Vector3u(const DirectX::XMVECTOR& v) noexcept;
302 Vector3u(DirectX::XMVECTOR&& v) noexcept;
303 Vector3u(const DirectX::XMUINT3& v) noexcept;
304 Vector3u(DirectX::XMUINT3&& v) noexcept;
305 inline operator DirectX::XMVECTOR() noexcept;
306 inline operator DirectX::XMUINT3() noexcept;
307#endif
308 };
309
310 class LITEFX_MATH_API Vector3i : public Vector<Int32, 3> {
311 public:
312 Vector3i() noexcept;
313 Vector3i(const Int32& v) noexcept;
314 Vector3i(const Int32& x, const Int32& y, const Int32& z) noexcept;
315 Vector3i(const Vector3i&) noexcept;
316 Vector3i(const Vector<Int32, 3>&) noexcept;
317 Vector3i(Vector3i&&) noexcept;
318 Vector3i(Vector<Int32, 3>&&) noexcept;
319 //virtual ~Vector3i() noexcept = default;
320
321 public:
322 inline Vector3i& operator=(const Vector<Int32, 3>& _other) noexcept;
323 inline Vector3i& operator=(Vector<Int32, 3>&& _other) noexcept;
324 inline Vector3i& operator=(const Array<Int32>& _other) noexcept;
325 inline Vector3i& operator=(const Vector3i& _other) noexcept;
326 inline Vector3i& operator=(Vector3i&& _other) noexcept;
327 inline const Int32& operator[](const unsigned int& i) const noexcept;
328 inline Int32& operator[](const unsigned int& i) noexcept;
329 inline operator Array<Int32>() noexcept;
330
331#if defined(BUILD_WITH_GLM)
332 public:
333 Vector3i(const glm::i32vec3& v) noexcept;
334 Vector3i(glm::i32vec3&& v) noexcept;
335 inline operator glm::i32vec3() noexcept;
336#endif
337
338#if defined(BUILD_WITH_DIRECTX_MATH)
339 public:
340 Vector3i(const DirectX::XMVECTOR& v) noexcept;
341 Vector3i(DirectX::XMVECTOR&& v) noexcept;
342 Vector3i(const DirectX::XMINT3& v) noexcept;
343 Vector3i(DirectX::XMINT3&& v) noexcept;
344 inline operator DirectX::XMVECTOR() noexcept;
345 inline operator DirectX::XMINT3() noexcept;
346#endif
347 };
348
349 class LITEFX_MATH_API Vector4f : public Vector<Float, 4> {
350 public:
351 Vector4f() noexcept;
352 Vector4f(const Float& v) noexcept;
353 Vector4f(const Float& x, const Float& y, const Float& z, const Float& w) noexcept;
354 Vector4f(const Vector4f&) noexcept;
355 Vector4f(const Vector<Float, 4>&) noexcept;
356 Vector4f(Vector4f&&) noexcept;
357 Vector4f(Vector<Float, 4>&&) noexcept;
358 //virtual ~Vector4f() noexcept = default;
359
360 public:
361 inline Vector4f& operator=(const Vector<Float, 4>& _other) noexcept;
362 inline Vector4f& operator=(Vector<Float, 4>&& _other) noexcept;
363 inline Vector4f& operator=(const Array<Float>& _other) noexcept;
364 inline Vector4f& operator=(const Vector4f& _other) noexcept;
365 inline Vector4f& operator=(Vector4f&& _other) noexcept;
366 inline const Float& operator[](const unsigned int& i) const noexcept;
367 inline Float& operator[](const unsigned int& i) noexcept;
368 inline operator Array<Float>() noexcept;
369
370#if defined(BUILD_WITH_GLM)
371 public:
372 Vector4f(const glm::f32vec4& v) noexcept;
373 Vector4f(glm::f32vec4&& v) noexcept;
374 inline operator glm::f32vec4() noexcept;
375#endif
376
377#if defined(BUILD_WITH_DIRECTX_MATH)
378 public:
379 Vector4f(const DirectX::XMVECTOR& v) noexcept;
380 Vector4f(DirectX::XMVECTOR&& v) noexcept;
381 Vector4f(const DirectX::XMFLOAT4& v) noexcept;
382 Vector4f(DirectX::XMFLOAT4&& v) noexcept;
383 inline operator DirectX::XMVECTOR() noexcept;
384 inline operator DirectX::XMFLOAT4() noexcept;
385#endif
386 };
387
388 class LITEFX_MATH_API Vector4u : public Vector<UInt32, 4> {
389 public:
390 Vector4u() noexcept;
391 Vector4u(const UInt32& v) noexcept;
392 Vector4u(const UInt32& x, const UInt32& y, const UInt32& z, const UInt32& w) noexcept;
393 Vector4u(const Vector4u&) noexcept;
394 Vector4u(const Vector<UInt32, 4>&) noexcept;
395 Vector4u(Vector4u&&) noexcept;
396 Vector4u(Vector<UInt32, 4>&&) noexcept;
397 //virtual ~Vector4u() noexcept = default;
398
399 public:
400 inline Vector4u& operator=(const Vector<UInt32, 4>& _other) noexcept;
401 inline Vector4u& operator=(Vector<UInt32, 4>&& _other) noexcept;
402 inline Vector4u& operator=(const Array<UInt32>& _other) noexcept;
403 inline Vector4u& operator=(const Vector4u& _other) noexcept;
404 inline Vector4u& operator=(Vector4u&& _other) noexcept;
405 inline const UInt32& operator[](const unsigned int& i) const noexcept;
406 inline UInt32& operator[](const unsigned int& i) noexcept;
407 inline operator Array<UInt32>() noexcept;
408
409#if defined(BUILD_WITH_GLM)
410 public:
411 Vector4u(const glm::u32vec4& v) noexcept;
412 Vector4u(glm::u32vec4&& v) noexcept;
413 inline operator glm::u32vec4() noexcept;
414#endif
415
416#if defined(BUILD_WITH_DIRECTX_MATH)
417 public:
418 Vector4u(const DirectX::XMVECTOR& v) noexcept;
419 Vector4u(DirectX::XMVECTOR&& v) noexcept;
420 Vector4u(const DirectX::XMUINT4& v) noexcept;
421 Vector4u(DirectX::XMUINT4&& v) noexcept;
422 inline operator DirectX::XMVECTOR() noexcept;
423 inline operator DirectX::XMUINT4() noexcept;
424#endif
425 };
426
427 class LITEFX_MATH_API Vector4i : public Vector<Int32, 4> {
428 public:
429 Vector4i() noexcept;
430 Vector4i(const Int32& v) noexcept;
431 Vector4i(const Int32& x, const Int32& y, const Int32& z, const Int32& w) noexcept;
432 Vector4i(const Vector4i&) noexcept;
433 Vector4i(const Vector<Int32, 4>&) noexcept;
434 Vector4i(Vector4i&&) noexcept;
435 Vector4i(Vector<Int32, 4>&&) noexcept;
436 //virtual ~Vector4i() noexcept = default;
437
438 public:
439 inline Vector4i& operator=(const Vector<Int32, 4>& _other) noexcept;
440 inline Vector4i& operator=(Vector<Int32, 4>&& _other) noexcept;
441 inline Vector4i& operator=(const Array<Int32>& _other) noexcept;
442 inline Vector4i& operator=(const Vector4i& _other) noexcept;
443 inline Vector4i& operator=(Vector4i&& _other) noexcept;
444 inline const Int32& operator[](const unsigned int& i) const noexcept;
445 inline Int32& operator[](const unsigned int& i) noexcept;
446 inline operator Array<Int32>() noexcept;
447
448#if defined(BUILD_WITH_GLM)
449 public:
450 Vector4i(const glm::i32vec4& v) noexcept;
451 Vector4i(glm::i32vec4&& v) noexcept;
452 inline operator glm::i32vec4() noexcept;
453#endif
454
455#if defined(BUILD_WITH_DIRECTX_MATH)
456 public:
457 Vector4i(const DirectX::XMVECTOR& v) noexcept;
458 Vector4i(DirectX::XMVECTOR&& v) noexcept;
459 Vector4i(const DirectX::XMINT4& v) noexcept;
460 Vector4i(DirectX::XMINT4&& v) noexcept;
461 inline operator DirectX::XMVECTOR() noexcept;
462 inline operator DirectX::XMINT4() noexcept;
463#endif
464 };
465
466 // Define exported vector types.
467 namespace Vectors {
504 }
505#pragma endregion
506
507#pragma region Size
508 class LITEFX_MATH_API Size4d : public Vector<size_t, 4> {
509 public:
510 Size4d() noexcept;
511 Size4d(const size_t& v) noexcept;
512 Size4d(const size_t& w, const size_t& h, const size_t& d, const size_t& a) noexcept;
513 Size4d(const Size4d&) noexcept;
514 Size4d(Size4d&&) noexcept;
515 //virtual ~Size4d() noexcept = default;
516
517 public:
518 inline Size4d& operator=(const Size4d& _other) noexcept;
519 inline Size4d& operator=(Size4d&& _other) noexcept;
520 inline Size4d operator/(const size_t& s) noexcept;
521 inline Size4d& operator/=(const size_t& s) noexcept;
522 inline Size4d operator*(const size_t& s) noexcept;
523 inline Size4d& operator*=(const size_t& s) noexcept;
524 inline Size4d operator+(const Size4d& s) noexcept;
525 inline Size4d& operator+=(const Size4d& s) noexcept;
526 inline Size4d operator-(const Size4d& s) noexcept;
527 inline Size4d& operator-=(const Size4d& s) noexcept;
528
529 public:
530 inline const size_t& width() const noexcept;
531 inline size_t& width() noexcept;
532 inline const size_t& height() const noexcept;
533 inline size_t& height() noexcept;
534 inline const size_t& depth() const noexcept;
535 inline size_t& depth() noexcept;
536 inline const size_t& alpha() const noexcept;
537 inline size_t& alpha() noexcept;
538 };
539
540 class LITEFX_MATH_API Size3d : public Vector<size_t, 3> {
541 public:
542 Size3d() noexcept;
543 Size3d(const size_t& v) noexcept;
544 Size3d(const size_t& w, const size_t& h, const size_t& d) noexcept;
545 Size3d(const Size3d&) noexcept;
546 Size3d(Size3d&&) noexcept;
547 //virtual ~Size3d() noexcept = default;
548
549 public:
550 inline Size3d& operator=(const Size3d& _other) noexcept;
551 inline Size3d& operator=(Size3d&& _other) noexcept;
552 inline operator Size4d() const noexcept;
553 inline Size3d operator/(const size_t& s) noexcept;
554 inline Size3d& operator/=(const size_t& s) noexcept;
555 inline Size3d operator*(const size_t& s) noexcept;
556 inline Size3d& operator*=(const size_t& s) noexcept;
557 inline Size3d operator+(const Size3d& s) noexcept;
558 inline Size3d& operator+=(const Size3d& s) noexcept;
559 inline Size3d operator-(const Size3d& s) noexcept;
560 inline Size3d& operator-=(const Size3d& s) noexcept;
561
562 public:
563 inline const size_t& width() const noexcept;
564 inline size_t& width() noexcept;
565 inline const size_t& height() const noexcept;
566 inline size_t& height() noexcept;
567 inline const size_t& depth() const noexcept;
568 inline size_t& depth() noexcept;
569 };
570
571 class LITEFX_MATH_API Size2d : public Vector<size_t, 2> {
572 public:
573 Size2d() noexcept;
574 Size2d(const size_t& v) noexcept;
575 Size2d(const size_t& w, const size_t& h) noexcept;
576 Size2d(const Size2d&) noexcept;
577 Size2d(Size2d&&) noexcept;
578 //virtual ~Size2d() noexcept = default;
579
580 public:
581 inline Size2d& operator=(const Size2d& _other) noexcept;
582 inline Size2d& operator=(Size2d&& _other) noexcept;
583 inline operator Size3d() const noexcept;
584 inline operator Size4d() const noexcept;
585 inline Size2d operator/(const size_t& s) noexcept;
586 inline Size2d& operator/=(const size_t& s) noexcept;
587 inline Size2d operator*(const size_t& s) noexcept;
588 inline Size2d& operator*=(const size_t& s) noexcept;
589 inline Size2d operator+(const Size2d& s) noexcept;
590 inline Size2d& operator+=(const Size2d& s) noexcept;
591 inline Size2d operator-(const Size2d& s) noexcept;
592 inline Size2d& operator-=(const Size2d& s) noexcept;
593
594 public:
595 inline const size_t& width() const noexcept;
596 inline size_t& width() noexcept;
597 inline const size_t& height() const noexcept;
598 inline size_t& height() noexcept;
599 };
600#pragma endregion
601
602#pragma region Rectangle
603 class LITEFX_MATH_API Rect : public Vector<size_t, 4> {
604 public:
605 Rect() noexcept;
606 Rect(const Vector<size_t, 2>& pos, const size_t& w, const size_t& h) noexcept;
607 Rect(const size_t& x, const size_t& y, const size_t& w, const size_t& h) noexcept;
608 Rect(const Rect&) noexcept;
609 Rect(Rect&&) noexcept;
610 //virtual ~Rect() noexcept = default;
611
612 public:
613 inline Rect& operator=(const Rect& _other) noexcept;
614 inline Rect& operator=(Rect&& _other) noexcept;
615
616 public:
617 inline Vector<size_t, 2> position() const noexcept;
618 inline Size2d extent() const noexcept;
619 inline const size_t& width() const noexcept;
620 inline size_t& width() noexcept;
621 inline const size_t& height() const noexcept;
622 inline size_t& height() noexcept;
623 };
624
625 class LITEFX_MATH_API RectI : public Vector<Int32, 4> {
626 public:
627 RectI() noexcept;
628 RectI(const Vector<Int32, 2>& pos, const Int32& w, const Int32& h) noexcept;
629 RectI(const Int32& x, const Int32& y, const Int32& w, const Int32& h) noexcept;
630 RectI(const RectI&) noexcept;
631 RectI(RectI&&) noexcept;
632 //virtual ~RectI() noexcept = default;
633
634 public:
635 inline RectI& operator=(const RectI& _other) noexcept;
636 inline RectI& operator=(RectI&& _other) noexcept;
637
638 public:
639 inline Vector<Int32, 2> position() const noexcept;
640 inline Size2d extent() const noexcept;
641 inline const Int32& width() const noexcept;
642 inline Int32& width() noexcept;
643 inline const Int32& height() const noexcept;
644 inline Int32& height() noexcept;
645 };
646
647 class LITEFX_MATH_API RectF : public Vector<Float, 4> {
648 public:
649 RectF() noexcept;
650 RectF(const Vector<Float, 2>& pos, const Float& w, const Float& h) noexcept;
651 RectF(const Float& x, const Float& y, const Float& w, const Float& h) noexcept;
652 RectF(const RectF&) noexcept;
653 RectF(RectF&&) noexcept;
654 //virtual ~RectF() noexcept = default;
655
656 public:
657 inline RectF& operator=(const RectF& _other) noexcept;
658 inline RectF& operator=(RectF&& _other) noexcept;
659
660 public:
661 inline Vector<Float, 2> position() const noexcept;
662 inline Size2d extent() const noexcept;
663 inline const Float& width() const noexcept;
664 inline Float& width() noexcept;
665 inline const Float& height() const noexcept;
666 inline Float& height() noexcept;
667 };
668#pragma endregion
669}
Definition: math.hpp:647
RectF & operator=(const RectF &_other) noexcept
Definition: math.hpp:603
Rect & operator=(const Rect &_other) noexcept
Definition: math.hpp:625
RectI & operator=(const RectI &_other) noexcept
Definition: math.hpp:571
Definition: math.hpp:540
Definition: math.hpp:508
Definition: math.hpp:44
Definition: math.hpp:79
Definition: math.hpp:115
Definition: math.hpp:193
Definition: math.hpp:154
Definition: math.hpp:232
Definition: math.hpp:310
Definition: math.hpp:271
Definition: math.hpp:349
Definition: math.hpp:427
Definition: math.hpp:388
Definition: vector.hpp:9
Definition: math.hpp:30
uint32_t UInt32
Definition: math.hpp:37
uint16_t UInt16
Definition: math.hpp:35
int16_t Int16
Definition: math.hpp:34
float_t Float
Definition: math.hpp:40
uint64_t UInt64
Definition: math.hpp:39
int64_t Int64
Definition: math.hpp:38
int32_t Int32
Definition: math.hpp:36
double_t Double
Definition: math.hpp:41
uint8_t Byte
Definition: math.hpp:33
Definition: app.hpp:6
std::vector< T > Array
Represents a dynamic array.
Definition: containers.hpp:58