3#include <litefx/core.h>
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)
15#ifndef LITEFX_MATH_API
16# define LITEFX_MATH_API
19#if defined(LITEFX_BUILD_WITH_GLM)
23#if defined(LITEFX_BUILD_WITH_DIRECTX_MATH)
24#include <DirectXMath.h>
27#include <litefx/vector.hpp>
28#include <litefx/matrix.hpp>
88 constexpr Byte operator ""_b(
unsigned long long int arg)
noexcept {
89 return static_cast<Byte>(arg);
97 constexpr UInt8 operator ""_ui8(
unsigned long long int arg)
noexcept {
98 return static_cast<UInt8>(arg);
106 constexpr Int16 operator ""_i16(
unsigned long long int arg)
noexcept {
107 return static_cast<Int16>(arg);
115 constexpr UInt16 operator ""_ui16(
unsigned long long int arg)
noexcept {
116 return static_cast<UInt16>(arg);
124 constexpr Int32 operator ""_i32(
unsigned long long int arg)
noexcept {
125 return static_cast<Int32>(arg);
133 constexpr UInt32 operator ""_ui32(
unsigned long long int arg)
noexcept {
134 return static_cast<UInt32>(arg);
142 constexpr Int64 operator ""_i64(
unsigned long long int arg)
noexcept {
143 return static_cast<Int64>(arg);
151 constexpr UInt64 operator ""_ui64(
unsigned long long int arg)
noexcept {
152 return static_cast<UInt64>(arg);
160 constexpr Float operator ""_f32(
long double arg)
noexcept {
161 return static_cast<Float>(arg);
169 constexpr Double operator ""_f64(
long double arg)
noexcept {
170 return static_cast<Double>(arg);
180 template <
typename T = UInt32>
181 static constexpr T align(T size, T alignment) {
182 return (size + alignment - 1) & ~(alignment - 1);
193#if defined(LITEFX_BUILD_WITH_GLM)
199 Vector1f(
const glm::f32vec1& v)
noexcept;
205 Vector1f(glm::f32vec1&& v)
noexcept;
210 operator glm::f32vec1()
const noexcept;
213#if defined(LITEFX_BUILD_WITH_DIRECTX_MATH)
219 Vector1f(
const DirectX::XMVECTOR& v)
noexcept;
225 Vector1f(DirectX::XMVECTOR&& v)
noexcept;
230 operator DirectX::XMVECTOR()
const noexcept;
243#if defined(LITEFX_BUILD_WITH_GLM)
249 Vector1u(
const glm::u32vec1& v)
noexcept;
255 Vector1u(glm::u32vec1&& v)
noexcept;
260 operator glm::u32vec1()
const noexcept;
263#if defined(LITEFX_BUILD_WITH_DIRECTX_MATH)
269 Vector1u(
const DirectX::XMVECTOR& v)
noexcept;
275 Vector1u(DirectX::XMVECTOR&& v)
noexcept;
280 operator DirectX::XMVECTOR()
const noexcept;
291#if defined(LITEFX_BUILD_WITH_GLM)
297 Vector2f(
const glm::f32vec2& v)
noexcept;
303 Vector2f(glm::f32vec2&& v)
noexcept;
308 operator glm::f32vec2()
const noexcept;
311#if defined(LITEFX_BUILD_WITH_DIRECTX_MATH)
317 Vector2f(
const DirectX::XMVECTOR& v)
noexcept;
323 Vector2f(DirectX::XMVECTOR&& v)
noexcept;
329 Vector2f(
const DirectX::XMFLOAT2& v)
noexcept;
335 Vector2f(DirectX::XMFLOAT2&& v)
noexcept;
340 operator DirectX::XMVECTOR()
const noexcept;
345 operator DirectX::XMFLOAT2()
const noexcept;
356#if defined(LITEFX_BUILD_WITH_GLM)
362 Vector2u(
const glm::u32vec2& v)
noexcept;
368 Vector2u(glm::u32vec2&& v)
noexcept;
373 operator glm::u32vec2()
const noexcept;
376#if defined(LITEFX_BUILD_WITH_DIRECTX_MATH)
382 Vector2u(
const DirectX::XMVECTOR& v)
noexcept;
388 Vector2u(DirectX::XMVECTOR&& v)
noexcept;
394 Vector2u(
const DirectX::XMUINT2& v)
noexcept;
400 Vector2u(DirectX::XMUINT2&& v)
noexcept;
405 operator DirectX::XMVECTOR()
const noexcept;
410 operator DirectX::XMUINT2()
const noexcept;
421#if defined(LITEFX_BUILD_WITH_GLM)
427 Vector2i(
const glm::i32vec2& v)
noexcept;
433 Vector2i(glm::i32vec2&& v)
noexcept;
438 operator glm::i32vec2()
const noexcept;
441#if defined(LITEFX_BUILD_WITH_DIRECTX_MATH)
447 Vector2i(
const DirectX::XMVECTOR& v)
noexcept;
453 Vector2i(DirectX::XMVECTOR&& v)
noexcept;
459 Vector2i(
const DirectX::XMINT2& v)
noexcept;
465 Vector2i(DirectX::XMINT2&& v)
noexcept;
470 operator DirectX::XMVECTOR()
const noexcept;
475 operator DirectX::XMINT2()
const noexcept;
486#if defined(LITEFX_BUILD_WITH_GLM)
488 Vector3f(
const glm::f32vec3& v)
noexcept;
489 Vector3f(glm::f32vec3&& v)
noexcept;
490 operator glm::f32vec3()
const noexcept;
493#if defined(LITEFX_BUILD_WITH_DIRECTX_MATH)
495 Vector3f(
const DirectX::XMVECTOR& v)
noexcept;
496 Vector3f(DirectX::XMVECTOR&& v)
noexcept;
497 Vector3f(
const DirectX::XMFLOAT3& v)
noexcept;
498 Vector3f(DirectX::XMFLOAT3&& v)
noexcept;
499 operator DirectX::XMVECTOR()
const noexcept;
500 operator DirectX::XMFLOAT3()
const noexcept;
508#if defined(LITEFX_BUILD_WITH_GLM)
510 Vector3u(
const glm::u32vec3& v)
noexcept;
511 Vector3u(glm::u32vec3&& v)
noexcept;
512 operator glm::u32vec3()
const noexcept;
515#if defined(LITEFX_BUILD_WITH_DIRECTX_MATH)
517 Vector3u(
const DirectX::XMVECTOR& v)
noexcept;
518 Vector3u(DirectX::XMVECTOR&& v)
noexcept;
519 Vector3u(
const DirectX::XMUINT3& v)
noexcept;
520 Vector3u(DirectX::XMUINT3&& v)
noexcept;
521 operator DirectX::XMVECTOR()
const noexcept;
522 operator DirectX::XMUINT3()
const noexcept;
530#if defined(LITEFX_BUILD_WITH_GLM)
532 Vector3i(
const glm::i32vec3& v)
noexcept;
533 Vector3i(glm::i32vec3&& v)
noexcept;
534 operator glm::i32vec3()
const noexcept;
537#if defined(LITEFX_BUILD_WITH_DIRECTX_MATH)
539 Vector3i(
const DirectX::XMVECTOR& v)
noexcept;
540 Vector3i(DirectX::XMVECTOR&& v)
noexcept;
541 Vector3i(
const DirectX::XMINT3& v)
noexcept;
542 Vector3i(DirectX::XMINT3&& v)
noexcept;
543 operator DirectX::XMVECTOR()
const noexcept;
544 operator DirectX::XMINT3()
const noexcept;
552#if defined(LITEFX_BUILD_WITH_GLM)
554 Vector4f(
const glm::f32vec4& v)
noexcept;
555 Vector4f(glm::f32vec4&& v)
noexcept;
556 operator glm::f32vec4()
const noexcept;
559#if defined(LITEFX_BUILD_WITH_DIRECTX_MATH)
561 Vector4f(
const DirectX::XMVECTOR& v)
noexcept;
562 Vector4f(DirectX::XMVECTOR&& v)
noexcept;
563 Vector4f(
const DirectX::XMFLOAT4& v)
noexcept;
564 Vector4f(DirectX::XMFLOAT4&& v)
noexcept;
565 operator DirectX::XMVECTOR()
const noexcept;
566 operator DirectX::XMFLOAT4()
const noexcept;
574#if defined(LITEFX_BUILD_WITH_GLM)
576 Vector4u(
const glm::u32vec4& v)
noexcept;
577 Vector4u(glm::u32vec4&& v)
noexcept;
578 operator glm::u32vec4()
const noexcept;
581#if defined(LITEFX_BUILD_WITH_DIRECTX_MATH)
583 Vector4u(
const DirectX::XMVECTOR& v)
noexcept;
584 Vector4u(DirectX::XMVECTOR&& v)
noexcept;
585 Vector4u(
const DirectX::XMUINT4& v)
noexcept;
586 Vector4u(DirectX::XMUINT4&& v)
noexcept;
587 operator DirectX::XMVECTOR()
const noexcept;
588 operator DirectX::XMUINT4()
const noexcept;
596#if defined(LITEFX_BUILD_WITH_GLM)
598 Vector4i(
const glm::i32vec4& v)
noexcept;
599 Vector4i(glm::i32vec4&& v)
noexcept;
600 operator glm::i32vec4()
const noexcept;
603#if defined(LITEFX_BUILD_WITH_DIRECTX_MATH)
605 Vector4i(
const DirectX::XMVECTOR& v)
noexcept;
606 Vector4i(DirectX::XMVECTOR&& v)
noexcept;
607 Vector4i(
const DirectX::XMINT4& v)
noexcept;
608 Vector4i(DirectX::XMINT4&& v)
noexcept;
609 operator DirectX::XMVECTOR()
const noexcept;
610 operator DirectX::XMINT4()
const noexcept;
804 Size4d(
size_t v)
noexcept;
805 Size4d(
size_t w,
size_t h,
size_t d,
size_t a)
noexcept;
813 Size4d operator/(
size_t s) noexcept;
814 Size4d& operator/=(
size_t s) noexcept;
815 Size4d operator*(
size_t s) noexcept;
816 Size4d& operator*=(
size_t s) noexcept;
823 size_t width() const noexcept;
824 size_t&
width() noexcept;
825 size_t height() const noexcept;
826 size_t&
height() noexcept;
827 size_t depth() const noexcept;
828 size_t&
depth() noexcept;
829 size_t alpha() const noexcept;
830 size_t&
alpha() noexcept;
836 Size3d(
size_t v)
noexcept;
837 Size3d(
size_t w,
size_t h,
size_t d)
noexcept;
845 operator
Size4d() const noexcept;
846 Size3d operator/(
size_t s) noexcept;
847 Size3d& operator/=(
size_t s) noexcept;
848 Size3d operator*(
size_t s) noexcept;
849 Size3d& operator*=(
size_t s) noexcept;
856 size_t width() const noexcept;
857 size_t&
width() noexcept;
858 size_t height() const noexcept;
859 size_t&
height() noexcept;
860 size_t depth() const noexcept;
861 size_t&
depth() noexcept;
867 Size2d(
size_t v)
noexcept;
868 Size2d(
size_t w,
size_t h)
noexcept;
876 operator
Size3d() const noexcept;
877 operator
Size4d() const noexcept;
878 Size2d operator/(
size_t s) noexcept;
879 Size2d& operator/=(
size_t s) noexcept;
880 Size2d operator*(
size_t s) noexcept;
881 Size2d& operator*=(
size_t s) noexcept;
888 size_t width() const noexcept;
889 size_t&
width() noexcept;
890 size_t height() const noexcept;
891 size_t&
height() noexcept;
895#pragma region Rectangle
900 Rect(
size_t x,
size_t y,
size_t w,
size_t h)
noexcept;
907 Rect& operator=(
Rect&& _other) noexcept;
912 size_t width() const noexcept;
913 size_t&
width() noexcept;
914 size_t height() const noexcept;
915 size_t&
height() noexcept;
Float width() const noexcept
Definition rect.cpp:160
~RectF() noexcept=default
Float height() const noexcept
Definition rect.cpp:168
Size2d extent() const noexcept
Definition rect.cpp:156
Vector< Float, 2 > position() const noexcept
Definition rect.cpp:152
RectF() noexcept
Definition rect.cpp:124
Size2d extent() const noexcept
Definition rect.cpp:44
size_t height() const noexcept
Definition rect.cpp:56
Rect() noexcept
Definition rect.cpp:9
size_t width() const noexcept
Definition rect.cpp:48
Vector< size_t, 2 > position() const noexcept
Definition rect.cpp:37
Int32 height() const noexcept
Definition rect.cpp:112
RectI() noexcept
Definition rect.cpp:68
Size2d extent() const noexcept
Definition rect.cpp:100
Int32 width() const noexcept
Definition rect.cpp:104
Vector< Int32, 2 > position() const noexcept
Definition rect.cpp:96
~RectI() noexcept=default
size_t width() const noexcept
Definition size.cpp:40
Size2d() noexcept
Definition size.cpp:9
size_t height() const noexcept
Definition size.cpp:42
~Size2d() noexcept=default
size_t depth() const noexcept
Definition size.cpp:83
size_t width() const noexcept
Definition size.cpp:79
size_t height() const noexcept
Definition size.cpp:81
Size3d() noexcept
Definition size.cpp:49
~Size3d() noexcept=default
size_t height() const noexcept
Definition size.cpp:123
~Size4d() noexcept=default
size_t width() const noexcept
Definition size.cpp:121
Size4d() noexcept
Definition size.cpp:90
size_t alpha() const noexcept
Definition size.cpp:127
size_t depth() const noexcept
Definition size.cpp:125
A vector that contains a single float.
Definition math.hpp:189
constexpr Vector() noexcept=default
Initializes an empty vector.
A vector that contains a single unsigned integer.
Definition math.hpp:239
constexpr Vector() noexcept=default
Initializes an empty vector.
A vector that contains two floats.
Definition math.hpp:287
constexpr Vector() noexcept=default
Initializes an empty vector.
A vector that contains two signed integers.
Definition math.hpp:417
constexpr Vector() noexcept=default
Initializes an empty vector.
A vector that contains two unsigned integers.
Definition math.hpp:352
constexpr Vector() noexcept=default
Initializes an empty vector.
A vector that stores three floats.
Definition math.hpp:482
constexpr Vector() noexcept=default
Initializes an empty vector.
constexpr Vector() noexcept=default
Initializes an empty vector.
constexpr Vector() noexcept=default
Initializes an empty vector.
constexpr Vector() noexcept=default
Initializes an empty vector.
constexpr Vector() noexcept=default
Initializes an empty vector.
constexpr Vector() noexcept=default
Initializes an empty vector.
Contains additional exported vector types.
Definition math.hpp:617
TVector4< UInt32 > UInt32Vector4
A vector that contains four 32 bit unsigned integers.
Definition math.hpp:716
TVector4< Int32 > Int32Vector4
A vector that contains four 32 bit signed integers.
Definition math.hpp:696
TVector3< Int32 > Int32Vector3
A vector that contains three 32 bit signed integers.
Definition math.hpp:691
TVector2< Int16 > Int16Vector2
A vector that contains two 16 bit signed integers.
Definition math.hpp:646
TVector1< Float > FloatVector1
A vector that contains a single floating point value with single precision.
Definition math.hpp:761
TVector2< UInt16 > UInt16Vector2
A vector that contains two 16 bit unsigned integers.
Definition math.hpp:666
TVector3< UInt64 > UInt64Vector3
A vector that contains three 64 bit unsigned integers.
Definition math.hpp:751
TVector2< Float > FloatVector2
A vector that contains two floating point values with single precision.
Definition math.hpp:766
TVector3< UInt16 > UInt16Vector3
A vector that contains three 16 bit unsigned integers.
Definition math.hpp:671
TVector2< Int32 > Int32Vector2
A vector that contains two 32 bit signed integers.
Definition math.hpp:686
TVector1< UInt32 > UInt32Vector1
A vector that contains a single 32 bit unsigned integer.
Definition math.hpp:701
TVector3< Float > FloatVector3
A vector that contains three floating point values with single precision.
Definition math.hpp:771
TVector3< UInt32 > UInt32Vector3
A vector that contains three 32 bit unsigned integers.
Definition math.hpp:711
TVector3< Double > DoubleVector3
A vector that contains three floating point values with double precision.
Definition math.hpp:791
TVector1< Double > DoubleVector1
A vector that contains a single floating point value with double precision.
Definition math.hpp:781
TVector1< UInt16 > UInt16Vector1
A vector that contains a single 16 bit unsigned integer.
Definition math.hpp:661
TVector4< UInt64 > UInt64Vector4
A vector that contains four 64 bit unsigned integers.
Definition math.hpp:756
TVector3< Int64 > Int64Vector3
A vector that contains three 64 bit signed integers.
Definition math.hpp:731
TVector1< Int32 > Int32Vector1
A vector that contains a single 32 bit signed integer.
Definition math.hpp:681
TVector4< Int16 > Int16Vector4
A vector that contains four 16 bit signed integers.
Definition math.hpp:656
TVector1< UInt64 > UInt64Vector1
A vector that contains a single 64 bit unsigned integer.
Definition math.hpp:741
TVector2< UInt32 > UInt32Vector2
A vector that contains two 32 bit unsigned integers.
Definition math.hpp:706
TVector4< UInt8 > ByteVector4
A vector that contains four bytes.
Definition math.hpp:636
TVector3< Int16 > Int16Vector3
A vector that contains three 16 bit signed integers.
Definition math.hpp:651
TVector2< UInt8 > ByteVector2
A vector that contains two bytes.
Definition math.hpp:626
TVector2< UInt64 > UInt64Vector2
A vector that contains two 64 bit unsigned integers.
Definition math.hpp:746
TVector4< Float > FloatVector4
A vector that contains four floating point values with single precision.
Definition math.hpp:776
TVector1< UInt8 > ByteVector1
A vector that contains a single byte.
Definition math.hpp:621
TVector1< Int64 > Int64Vector1
A vector that contains a single 64 bit signed integer.
Definition math.hpp:721
TVector4< UInt16 > UInt16Vector4
A vector that contains four 16 bit unsigned integers.
Definition math.hpp:676
TVector4< Double > DoubleVector4
A vector that contains four floating point values with double precision.
Definition math.hpp:796
TVector3< UInt8 > ByteVector3
A vector that contains three bytes.
Definition math.hpp:631
TVector1< Int16 > Int16Vector1
A vector that contains a single 16 bit signed integer.
Definition math.hpp:641
TVector4< Int64 > Int64Vector4
A vector that contains four 64 bit signed integers.
Definition math.hpp:736
TVector2< Double > DoubleVector2
A vector that contains two floating point values with double precision.
Definition math.hpp:786
TVector2< Int64 > Int64Vector2
A vector that contains two 64 bit signed integers.
Definition math.hpp:726
uint16_t UInt16
A type for an unsigned 16 bit integer.
Definition math.hpp:51
uint8_t UInt8
A type for an unsigned 8 bit integer.
Definition math.hpp:41
Vector< T, 1 > TVector1
A generic vector with one component.
Definition vector.hpp:317
uint64_t UInt64
A type for an unsigned 64 bit integer.
Definition math.hpp:71
Vector< T, 4 > TVector4
A generic vector with four components.
Definition vector.hpp:335
float_t Float
A type for a floating point value with single precision.
Definition math.hpp:76
double_t Double
A type for a floating point value with double precision.
Definition math.hpp:81
uint32_t UInt32
A type for an unsigned 32 bit integer.
Definition math.hpp:61
int64_t Int64
A type for a signed 64 bit integer.
Definition math.hpp:66
int16_t Int16
A type for a signed 16 bit integer.
Definition math.hpp:46
Vector< T, 3 > TVector3
A generic vector with three components.
Definition vector.hpp:329
int32_t Int32
A type for a signed 32 bit integer.
Definition math.hpp:56
std::byte Byte
A type for a single byte of raw memory.
Definition math.hpp:36
Vector< T, 2 > TVector2
A generic vector with two components.
Definition vector.hpp:323
constexpr scalar_type w() const noexcept
Definition vector.hpp:300
constexpr scalar_type x() const noexcept
Definition vector.hpp:252
constexpr scalar_type y() const noexcept
Definition vector.hpp:268
constexpr Vector() noexcept=default
Initializes an empty vector.