4#ifndef GREM_CORE_MATH_HPP
5#define GREM_CORE_MATH_HPP
27using std::numbers::e_v;
28using std::numbers::egamma_v;
29using std::numbers::inv_pi_v;
30using std::numbers::inv_sqrt3_v;
31using std::numbers::inv_sqrtpi_v;
32using std::numbers::ln10_v;
33using std::numbers::ln2_v;
34using std::numbers::log10e_v;
35using std::numbers::log2e_v;
36using std::numbers::phi_v;
37using std::numbers::pi_v;
38using std::numbers::sqrt2_v;
39using std::numbers::sqrt3_v;
41inline constexpr float E = e_v<float>;
42inline constexpr float LOG2E = log2e_v<float>;
43inline constexpr float LOG10E = log10e_v<float>;
44inline constexpr float PI = pi_v<float>;
45inline constexpr float INV_PI = inv_pi_v<float>;
47inline constexpr float LN2 = ln2_v<float>;
48inline constexpr float LN10 = ln10_v<float>;
49inline constexpr float SQRT2 = sqrt2_v<float>;
50inline constexpr float SQRT3 = sqrt3_v<float>;
51inline constexpr float INV_SQRT3 = inv_sqrt3_v<float>;
52inline constexpr float EGAMMA = egamma_v<float>;
53inline constexpr float PHI = phi_v<float>;
57template <
size_t N,
typename T>
63 static constexpr size_t RANK = 1;
71 :
x(static_cast<T>(v.
x)) {}
80 if (std::is_constant_evaluated()) {
92 if (std::is_constant_evaluated()) {
110 static constexpr size_t RANK = 2;
117 template <typename U>
119 :
x(static_cast<T>(v.
x))
120 ,
y(static_cast<T>(v.
y)) {}
130 template <
typename U>
139 if (std::is_constant_evaluated()) {
146 return reinterpret_cast<Component*
>(
this)[i];
152 if (std::is_constant_evaluated()) {
159 return reinterpret_cast<const Component*
>(
this)[i];
171 static constexpr size_t RANK = 3;
179 template <typename U>
181 :
x(static_cast<T>(v.
x))
182 ,
y(static_cast<T>(v.
y))
183 ,
z(static_cast<T>(v.
z)) {}
205 template <
typename U>
210 template <
typename U>
212 return vec<2, U>{
static_cast<U
>(
x),
static_cast<U
>(
y)};
219 if (std::is_constant_evaluated()) {
227 return reinterpret_cast<Component*
>(
this)[i];
233 if (std::is_constant_evaluated()) {
241 return reinterpret_cast<const Component*
>(
this)[i];
253 static constexpr size_t RANK = 4;
262 template <typename U>
264 :
x(static_cast<T>(v.
x))
265 ,
y(static_cast<T>(v.
y))
266 ,
z(static_cast<T>(v.
z))
267 ,
w(static_cast<T>(v.
w)) {}
317 template <
typename U>
322 template <
typename U>
324 return vec<2, U>{
static_cast<U
>(
x),
static_cast<U
>(
y)};
327 template <
typename U>
329 return vec<3, U>{
static_cast<U
>(
x),
static_cast<U
>(
y),
static_cast<U
>(
z)};
336 if (std::is_constant_evaluated()) {
345 return reinterpret_cast<Component*
>(
this)[i];
351 if (std::is_constant_evaluated()) {
360 return reinterpret_cast<const Component*
>(
this)[i];
475 static constexpr size_t RANK = 4;
477 uint32_t _private_value{};
482 : _private_value(encode(value)) {}
484 template <
typename U>
512 template <
typename U>
517 template <
typename U>
522 template <
typename U>
527 template <
typename U>
533 return decode(_private_value);
539 return decode(_private_value)[i];
547 [[nodiscard]]
static constexpr uint32_t encode(
vec4 value)
noexcept {
548 float x =
clamp(value.x, -1.0f, 1.0f) * 511.0f;
549 float y =
clamp(value.y, -1.0f, 1.0f) * 511.0f;
550 float z =
clamp(value.z, -1.0f, 1.0f) * 511.0f;
551 float w =
clamp(value.w, -1.0f, 1.0f);
552 x += (value.x < 0.0f) ? -0.5f : 0.5f;
553 y += (value.y < 0.0f) ? -0.5f : 0.5f;
554 z += (value.z < 0.0f) ? -0.5f : 0.5f;
555 w += (value.w < 0.0f) ? -0.5f : 0.5f;
556 return (bit_cast<uint32_t>(
static_cast<int32_t
>(x)) & 0b1111111111) |
557 ((bit_cast<uint32_t>(
static_cast<int32_t
>(y)) & 0b1111111111) << 10) |
558 ((bit_cast<uint32_t>(
static_cast<int32_t
>(z)) & 0b1111111111) << 20) |
559 ((bit_cast<uint32_t>(
static_cast<int32_t
>(w)) & 0b11) << 30);
562 [[nodiscard]]
static constexpr vec4 decode(uint32_t value)
noexcept {
563 uint32_t x =
static_cast<uint32_t
>(value & 0b1111111111);
564 uint32_t y =
static_cast<uint32_t
>((value >> 10) & 0b1111111111);
565 uint32_t z =
static_cast<uint32_t
>((value >> 20) & 0b1111111111);
566 uint32_t w =
static_cast<uint32_t
>((value >> 30) & 0b11);
567 x |= uint32_t{0} - (x & 0b1000000000);
568 y |= uint32_t{0} - (y & 0b1000000000);
569 z |= uint32_t{0} - (z & 0b1000000000);
570 w |= uint32_t{0} - (w & 0b10);
572 static_cast<float>(bit_cast<int32_t>(x)) / 511.0f,
573 static_cast<float>(bit_cast<int32_t>(y)) / 511.0f,
574 static_cast<float>(bit_cast<int32_t>(z)) / 511.0f,
575 static_cast<float>(bit_cast<int32_t>(w)),
581 static constexpr size_t RANK = 4;
583 uint32_t _private_value{};
588 : _private_value(encode(value)) {}
590 template <
typename U>
631 return decode(_private_value);
637 return decode(_private_value)[i];
645 [[nodiscard]]
static constexpr uint32_t encode(
vec4 value)
noexcept {
646 return (
static_cast<uint32_t
>(
clamp(value.x, 0.0f, 1.0f) * 1023.0f)) |
647 (
static_cast<uint32_t
>(
clamp(value.y, 0.0f, 1.0f) * 1023.0f) << 10) |
648 (
static_cast<uint32_t
>(
clamp(value.z, 0.0f, 1.0f) * 1023.0f) << 20) |
649 (
static_cast<uint32_t
>(
clamp(value.w, 0.0f, 1.0f) * 3.0f) << 30);
652 [[nodiscard]]
static constexpr vec4 decode(uint32_t value)
noexcept {
654 static_cast<float>(value & 0b1111111111) / 1023.0f,
655 static_cast<float>((value >> 10) & 0b1111111111) / 1023.0f,
656 static_cast<float>((value >> 20) & 0b1111111111) / 1023.0f,
657 static_cast<float>((value >> 30) & 0b11) / 3.0f,
662template <
size_t C,
size_t R,
typename T>
665 static constexpr size_t RANK = C;
671 template <typename U>
673 for (
size_t i = 0; i < C; ++i) {
679 for (
size_t i = 0; i < C; ++i) {
680 _private_value[i][i] = value;
685 : _private_value{{ix, iy}, {jx, jy}} {}
687 GREM_ALWAYS_INLINE constexpr mat(T ix, T iy, T iz, T jx, T jy, T jz, T kx, T ky, T kz)
noexcept requires(C == 3 && R == 3)
688 : _private_value{{ix, iy, iz}, {jx, jy, jz}, {kx, ky, kz}} {}
690 GREM_ALWAYS_INLINE constexpr mat(T ix, T iy, T iz, T iw, T jx, T jy, T jz, T jw, T kx, T ky, T kz, T kw, T lx, T ly, T lz, T lw)
noexcept requires(C == 4 && R == 4)
691 : _private_value{{ix, iy, iz, iw}, {jx, jy, jz, jw}, {kx, ky, kz, kw}, {lx, ly, lz, lw}} {}
694 : _private_value{i} {}
697 : _private_value{i, j} {}
700 : _private_value{i, j, k} {}
703 : _private_value{i, j, k, l} {}
707 for (
size_t y = 0; y < N; ++y) {
708 for (
size_t x = 0; x < N; ++x) {
709 _private_value[y][x] = m[y][x];
712 for (
size_t i = N; i < C; ++i) {
713 _private_value[i][i] = T{1};
719 _private_value[0][0],
725 _private_value[0][0],
726 _private_value[0][1],
727 _private_value[1][0],
728 _private_value[1][1],
734 _private_value[0][0],
735 _private_value[0][1],
736 _private_value[0][2],
737 _private_value[1][0],
738 _private_value[1][1],
739 _private_value[1][2],
740 _private_value[2][0],
741 _private_value[2][1],
742 _private_value[2][2],
750 return _private_value[i];
755 return _private_value[i];
827 static constexpr size_t RANK = 4;
836 template <typename U>
838 :
x(static_cast<T>(q.
x))
839 ,
y(static_cast<T>(q.
y))
840 ,
z(static_cast<T>(q.
z))
841 ,
w(static_cast<T>(q.
w)) {}
859 if (std::is_constant_evaluated()) {
868 return reinterpret_cast<Component*
>(
this)[i];
874 if (std::is_constant_evaluated()) {
883 return reinterpret_cast<const Component*
>(
this)[i];
908template <
size_t N,
typename T>
911 for (
size_t i = 0; i < N; ++i) {
930 std::conditional_t<
sizeof(T) ==
sizeof(uint8_t), uint8_t,
931 std::conditional_t<
sizeof(T) ==
sizeof(uint16_t), uint16_t,
932 std::conditional_t<
sizeof(T) ==
sizeof(uint32_t), uint32_t,
935 if constexpr (
sizeof(Mask) ==
sizeof(T)) {
936 const Mask mask =
static_cast<Mask
>(condition) - Mask{1};
937 const Mask ifTrueMask = bit_cast<Mask>(ifTrue);
938 const Mask ifFalseMask = bit_cast<Mask>(ifFalse);
939 return bit_cast<T>((mask & ifFalseMask) | (~mask & ifTrueMask));
941 return (condition) ? ifTrue : ifFalse;
955template <
size_t N,
typename T>
959 std::conditional_t<
sizeof(T) ==
sizeof(uint8_t), uint8_t,
960 std::conditional_t<
sizeof(T) ==
sizeof(uint16_t), uint16_t,
961 std::conditional_t<
sizeof(T) ==
sizeof(uint32_t), uint32_t,
964 if constexpr (
sizeof(Mask) ==
sizeof(T)) {
966 const vec<N, Mask> ifTrueMask = bit_cast<vec<N, Mask>>(ifTrue);
967 const vec<N, Mask> ifFalseMask = bit_cast<vec<N, Mask>>(ifFalse);
968 return bit_cast<vec<N, T>>((mask & ifFalseMask) | (~mask & ifTrueMask));
971 for (
size_t i = 0; i < N; ++i) {
972 result[i] =
select(conditions[i], ifTrue[i], ifFalse[i]);
987template <
size_t N,
typename T>
990 for (
size_t i = 0; i < N; ++i) {
991 result[i] =
min(a[i], b[i]);
1005template <
size_t N,
typename T>
1008 for (
size_t i = 0; i < N; ++i) {
1009 result[i] =
max(a[i], b[i]);
1026template <
size_t N,
typename T>
1029 for (
size_t i = 0; i < N; ++i) {
1030 result[i] =
clamp(values[i], minValues[i], maxValues[i]);
1047template <
size_t N,
typename T>
1050 for (
size_t i = 0; i < N; ++i) {
1051 result[i] =
clamp(values[i], minValue, maxValue);
1083using std::isunordered;
1093using std::nextafter;
1094using std::nexttoward;
1095using std::remainder;
1113template <
typename T>
1116 if (std::is_constant_evaluated()) {
1119 while (current != previous) {
1121 current = T{0.5} * (current + a / current);
1125 return std::sqrt(a);
1135template <
typename T>
1138 return T{1} /
sqrt(a);
1141template <
typename T>
1143 return a -
floor(a);
1153template <
typename T>
1165template <
typename T>
1167 return std::exp2(a);
1178template <
typename T>
1180 return std::pow(a, b);
1191template <
typename T>
1193 return std::fmod(a, b);
1203template <
typename T>
1205 return static_cast<T
>(T{0} < a) -
static_cast<T
>(a < T{0});
1217template <
typename T>
1221 return value -
floor(value / limit) * limit;
1223 return static_cast<T
>(value % limit);
1225 return static_cast<T
>((value % limit + limit) % limit);
1229template <
typename T>
1234template <
typename T>
1239template <
typename T>
1244template <
typename T>
1249template <
typename T>
1254template <
typename T>
1266 for (
size_t i = 0; i < N; ++i) {
1267 result[i] =
not_(a[i]);
1278 bool result =
false;
1279 for (
size_t i = 0; i < N; ++i) {
1292 for (
size_t i = 0; i < N; ++i) {
1298#define GREM_PRIVATE_DEFINE_COMPONENT_WISE_VECTOR_OVERLOAD_OF_UNARY_MATH_FUNCTION(ResultType, function) \
1299 template <size_t N, typename T> \
1300 [[nodiscard]] GREM_ALWAYS_INLINE constexpr vec<N, ResultType> GREM_VECTORCALL function(vec<N, T> a) requires(requires(const vec<N, T> x, const size_t i) { function(x[i]); }) \
1302 vec<N, ResultType> result; \
1303 for (size_t i = 0; i < N; ++i) { \
1304 result[i] = function(a[i]); \
1309#define GREM_PRIVATE_DEFINE_COMPONENT_WISE_VECTOR_OVERLOAD_OF_BINARY_MATH_FUNCTION(ResultType, function) \
1310 template <size_t N, typename T> \
1311 [[nodiscard]] GREM_ALWAYS_INLINE constexpr vec<N, ResultType> GREM_VECTORCALL function(vec<N, T> a, vec<N, T> b) \
1312 requires(requires(const vec<N, T> x, const vec<N, T> y, const size_t i) { function(x[i], y[i]); }) { \
1313 vec<N, ResultType> result; \
1314 for (size_t i = 0; i < N; ++i) { \
1315 result[i] = function(a[i], b[i]); \
1320#define GREM_PRIVATE_DEFINE_COMPONENT_WISE_VECTOR_X_SCALAR_OVERLOAD_OF_BINARY_MATH_FUNCTION(ResultType, function) \
1321 template <size_t N, typename T> \
1322 [[nodiscard]] GREM_ALWAYS_INLINE constexpr vec<N, ResultType> GREM_VECTORCALL function(vec<N, T> a, T b) \
1323 requires(requires(const vec<N, T> x, const T y, const size_t i) { function(x[i], y); }) { \
1324 vec<N, ResultType> result; \
1325 for (size_t i = 0; i < N; ++i) { \
1326 result[i] = function(a[i], b); \
1331#define GREM_PRIVATE_DEFINE_COMPONENT_WISE_SCALAR_X_VECTOR_OVERLOAD_OF_BINARY_MATH_FUNCTION(ResultType, function) \
1332 template <size_t N, typename T> \
1333 [[nodiscard]] GREM_ALWAYS_INLINE constexpr vec<N, ResultType> GREM_VECTORCALL function(T a, vec<N, T> b) \
1334 requires(requires(const T x, const vec<N, T> y, const size_t i) { function(x, y[i]); }) { \
1335 vec<N, ResultType> result; \
1336 for (size_t i = 0; i < N; ++i) { \
1337 result[i] = function(a, b[i]); \
1342#define GREM_PRIVATE_DEFINE_COMPONENT_WISE_VECTOR_OVERLOAD_OF_TERNARY_MATH_FUNCTION(ResultType, function) \
1343 template <size_t N, typename T> \
1344 [[nodiscard]] GREM_ALWAYS_INLINE constexpr vec<N, ResultType> GREM_VECTORCALL function(vec<N, T> a, vec<N, T> b, vec<N, T> c) \
1345 requires(requires(const vec<N, T> x, const vec<N, T> y, const vec<N, T> z, const size_t i) { function(x[i], y[i], z[i]); }) { \
1346 vec<N, ResultType> result; \
1347 for (size_t i = 0; i < N; ++i) { \
1348 result[i] = function(a[i], b[i], c[i]); \
1353#define GREM_PRIVATE_DEFINE_COMPONENT_WISE_VECTOR_X_VECTOR_X_SCALAR_OVERLOAD_OF_TERNARY_MATH_FUNCTION(ResultType, function) \
1354 template <size_t N, typename T> \
1355 [[nodiscard]] GREM_ALWAYS_INLINE constexpr vec<N, ResultType> GREM_VECTORCALL function(vec<N, T> a, vec<N, T> b, T c) \
1356 requires(requires(const vec<N, T> x, const vec<N, T> y, const T z, const size_t i) { function(x[i], y[i], z); }) { \
1357 vec<N, ResultType> result; \
1358 for (size_t i = 0; i < N; ++i) { \
1359 result[i] = function(a[i], b[i], c); \
1364#define GREM_PRIVATE_DEFINE_COMPONENT_WISE_VECTOR_X_SCALAR_X_VECTOR_OVERLOAD_OF_TERNARY_MATH_FUNCTION(ResultType, function) \
1365 template <size_t N, typename T> \
1366 [[nodiscard]] GREM_ALWAYS_INLINE constexpr vec<N, ResultType> GREM_VECTORCALL function(vec<N, T> a, T b, vec<N, T> c) \
1367 requires(requires(const vec<N, T> x, const T y, const vec<N, T> z, const size_t i) { function(x[i], y, z[i]); }) { \
1368 vec<N, ResultType> result; \
1369 for (size_t i = 0; i < N; ++i) { \
1370 result[i] = function(a[i], b, c[i]); \
1375#define GREM_PRIVATE_DEFINE_COMPONENT_WISE_VECTOR_X_SCALAR_X_SCALAR_OVERLOAD_OF_TERNARY_MATH_FUNCTION(ResultType, function) \
1376 template <size_t N, typename T> \
1377 [[nodiscard]] GREM_ALWAYS_INLINE constexpr vec<N, ResultType> GREM_VECTORCALL function(vec<N, T> a, T b, T c) \
1378 requires(requires(const vec<N, T> x, const T y, const T z, const size_t i) { function(x[i], y, z); }) { \
1379 vec<N, ResultType> result; \
1380 for (size_t i = 0; i < N; ++i) { \
1381 result[i] = function(a[i], b, c); \
1386GREM_PRIVATE_DEFINE_COMPONENT_WISE_VECTOR_OVERLOAD_OF_UNARY_MATH_FUNCTION(T,
abs)
1387GREM_PRIVATE_DEFINE_COMPONENT_WISE_VECTOR_OVERLOAD_OF_UNARY_MATH_FUNCTION(T,
sqrt)
1388GREM_PRIVATE_DEFINE_COMPONENT_WISE_VECTOR_OVERLOAD_OF_UNARY_MATH_FUNCTION(T,
inversesqrt)
1389GREM_PRIVATE_DEFINE_COMPONENT_WISE_VECTOR_OVERLOAD_OF_UNARY_MATH_FUNCTION(T,
cos)
1390GREM_PRIVATE_DEFINE_COMPONENT_WISE_VECTOR_OVERLOAD_OF_UNARY_MATH_FUNCTION(T,
cosh)
1391GREM_PRIVATE_DEFINE_COMPONENT_WISE_VECTOR_OVERLOAD_OF_UNARY_MATH_FUNCTION(T,
acos)
1392GREM_PRIVATE_DEFINE_COMPONENT_WISE_VECTOR_OVERLOAD_OF_UNARY_MATH_FUNCTION(T,
acosh)
1393GREM_PRIVATE_DEFINE_COMPONENT_WISE_VECTOR_OVERLOAD_OF_UNARY_MATH_FUNCTION(T,
sin)
1394GREM_PRIVATE_DEFINE_COMPONENT_WISE_VECTOR_OVERLOAD_OF_UNARY_MATH_FUNCTION(T,
sinh)
1395GREM_PRIVATE_DEFINE_COMPONENT_WISE_VECTOR_OVERLOAD_OF_UNARY_MATH_FUNCTION(T,
asin)
1396GREM_PRIVATE_DEFINE_COMPONENT_WISE_VECTOR_OVERLOAD_OF_UNARY_MATH_FUNCTION(T,
asinh)
1397GREM_PRIVATE_DEFINE_COMPONENT_WISE_VECTOR_OVERLOAD_OF_UNARY_MATH_FUNCTION(T,
tan)
1398GREM_PRIVATE_DEFINE_COMPONENT_WISE_VECTOR_OVERLOAD_OF_UNARY_MATH_FUNCTION(T,
tanh)
1399GREM_PRIVATE_DEFINE_COMPONENT_WISE_VECTOR_OVERLOAD_OF_UNARY_MATH_FUNCTION(T,
atan)
1400GREM_PRIVATE_DEFINE_COMPONENT_WISE_VECTOR_OVERLOAD_OF_UNARY_MATH_FUNCTION(T,
atanh)
1401GREM_PRIVATE_DEFINE_COMPONENT_WISE_VECTOR_OVERLOAD_OF_UNARY_MATH_FUNCTION(T,
cbrt)
1402GREM_PRIVATE_DEFINE_COMPONENT_WISE_VECTOR_OVERLOAD_OF_UNARY_MATH_FUNCTION(T,
erf)
1403GREM_PRIVATE_DEFINE_COMPONENT_WISE_VECTOR_OVERLOAD_OF_UNARY_MATH_FUNCTION(T,
erfc)
1404GREM_PRIVATE_DEFINE_COMPONENT_WISE_VECTOR_OVERLOAD_OF_UNARY_MATH_FUNCTION(T,
lgamma)
1405GREM_PRIVATE_DEFINE_COMPONENT_WISE_VECTOR_OVERLOAD_OF_UNARY_MATH_FUNCTION(T,
tgamma)
1406GREM_PRIVATE_DEFINE_COMPONENT_WISE_VECTOR_OVERLOAD_OF_BINARY_MATH_FUNCTION(T,
pow)
1407GREM_PRIVATE_DEFINE_COMPONENT_WISE_VECTOR_X_SCALAR_OVERLOAD_OF_BINARY_MATH_FUNCTION(T,
pow)
1408GREM_PRIVATE_DEFINE_COMPONENT_WISE_SCALAR_X_VECTOR_OVERLOAD_OF_BINARY_MATH_FUNCTION(T,
pow)
1409GREM_PRIVATE_DEFINE_COMPONENT_WISE_VECTOR_OVERLOAD_OF_UNARY_MATH_FUNCTION(T,
exp)
1410GREM_PRIVATE_DEFINE_COMPONENT_WISE_VECTOR_OVERLOAD_OF_UNARY_MATH_FUNCTION(T,
exp2)
1411GREM_PRIVATE_DEFINE_COMPONENT_WISE_VECTOR_OVERLOAD_OF_UNARY_MATH_FUNCTION(T,
expm1)
1412GREM_PRIVATE_DEFINE_COMPONENT_WISE_VECTOR_OVERLOAD_OF_UNARY_MATH_FUNCTION(T,
log)
1413GREM_PRIVATE_DEFINE_COMPONENT_WISE_VECTOR_OVERLOAD_OF_UNARY_MATH_FUNCTION(T,
log10)
1414GREM_PRIVATE_DEFINE_COMPONENT_WISE_VECTOR_OVERLOAD_OF_UNARY_MATH_FUNCTION(T,
log1p)
1415GREM_PRIVATE_DEFINE_COMPONENT_WISE_VECTOR_OVERLOAD_OF_UNARY_MATH_FUNCTION(T,
log2)
1416GREM_PRIVATE_DEFINE_COMPONENT_WISE_VECTOR_OVERLOAD_OF_UNARY_MATH_FUNCTION(T,
logb)
1417GREM_PRIVATE_DEFINE_COMPONENT_WISE_VECTOR_OVERLOAD_OF_UNARY_MATH_FUNCTION(
int,
ilogb)
1418GREM_PRIVATE_DEFINE_COMPONENT_WISE_VECTOR_OVERLOAD_OF_UNARY_MATH_FUNCTION(T,
round)
1419GREM_PRIVATE_DEFINE_COMPONENT_WISE_VECTOR_OVERLOAD_OF_UNARY_MATH_FUNCTION(
long,
lround)
1420GREM_PRIVATE_DEFINE_COMPONENT_WISE_VECTOR_OVERLOAD_OF_UNARY_MATH_FUNCTION(T,
trunc)
1421GREM_PRIVATE_DEFINE_COMPONENT_WISE_VECTOR_OVERLOAD_OF_UNARY_MATH_FUNCTION(T,
floor)
1422GREM_PRIVATE_DEFINE_COMPONENT_WISE_VECTOR_OVERLOAD_OF_UNARY_MATH_FUNCTION(T,
ceil)
1423GREM_PRIVATE_DEFINE_COMPONENT_WISE_VECTOR_OVERLOAD_OF_UNARY_MATH_FUNCTION(T,
fract)
1424GREM_PRIVATE_DEFINE_COMPONENT_WISE_VECTOR_OVERLOAD_OF_UNARY_MATH_FUNCTION(T,
sign)
1425GREM_PRIVATE_DEFINE_COMPONENT_WISE_VECTOR_OVERLOAD_OF_BINARY_MATH_FUNCTION(T,
fmod)
1426GREM_PRIVATE_DEFINE_COMPONENT_WISE_VECTOR_X_SCALAR_OVERLOAD_OF_BINARY_MATH_FUNCTION(T,
fmod)
1427GREM_PRIVATE_DEFINE_COMPONENT_WISE_SCALAR_X_VECTOR_OVERLOAD_OF_BINARY_MATH_FUNCTION(T,
fmod)
1428GREM_PRIVATE_DEFINE_COMPONENT_WISE_VECTOR_OVERLOAD_OF_BINARY_MATH_FUNCTION(T,
wrap)
1429GREM_PRIVATE_DEFINE_COMPONENT_WISE_VECTOR_X_SCALAR_OVERLOAD_OF_BINARY_MATH_FUNCTION(T,
wrap)
1430GREM_PRIVATE_DEFINE_COMPONENT_WISE_SCALAR_X_VECTOR_OVERLOAD_OF_BINARY_MATH_FUNCTION(T,
wrap)
1431GREM_PRIVATE_DEFINE_COMPONENT_WISE_VECTOR_OVERLOAD_OF_TERNARY_MATH_FUNCTION(T,
fma)
1432GREM_PRIVATE_DEFINE_COMPONENT_WISE_VECTOR_X_VECTOR_X_SCALAR_OVERLOAD_OF_TERNARY_MATH_FUNCTION(T,
fma)
1433GREM_PRIVATE_DEFINE_COMPONENT_WISE_VECTOR_X_SCALAR_X_VECTOR_OVERLOAD_OF_TERNARY_MATH_FUNCTION(T,
fma)
1434GREM_PRIVATE_DEFINE_COMPONENT_WISE_VECTOR_X_SCALAR_X_SCALAR_OVERLOAD_OF_TERNARY_MATH_FUNCTION(T,
fma)
1435GREM_PRIVATE_DEFINE_COMPONENT_WISE_VECTOR_OVERLOAD_OF_BINARY_MATH_FUNCTION(T,
fdim)
1436GREM_PRIVATE_DEFINE_COMPONENT_WISE_VECTOR_X_SCALAR_OVERLOAD_OF_BINARY_MATH_FUNCTION(T,
fdim)
1437GREM_PRIVATE_DEFINE_COMPONENT_WISE_SCALAR_X_VECTOR_OVERLOAD_OF_BINARY_MATH_FUNCTION(T,
fdim)
1438GREM_PRIVATE_DEFINE_COMPONENT_WISE_VECTOR_OVERLOAD_OF_BINARY_MATH_FUNCTION(
bool,
equal)
1439GREM_PRIVATE_DEFINE_COMPONENT_WISE_VECTOR_OVERLOAD_OF_BINARY_MATH_FUNCTION(
bool,
notEqual)
1440GREM_PRIVATE_DEFINE_COMPONENT_WISE_VECTOR_OVERLOAD_OF_BINARY_MATH_FUNCTION(
bool,
lessThan)
1441GREM_PRIVATE_DEFINE_COMPONENT_WISE_VECTOR_OVERLOAD_OF_BINARY_MATH_FUNCTION(
bool,
lessThanEqual)
1442GREM_PRIVATE_DEFINE_COMPONENT_WISE_VECTOR_OVERLOAD_OF_BINARY_MATH_FUNCTION(
bool,
greaterThan)
1443GREM_PRIVATE_DEFINE_COMPONENT_WISE_VECTOR_OVERLOAD_OF_BINARY_MATH_FUNCTION(
bool,
greaterThanEqual)
1445#undef GREM_PRIVATE_DEFINE_COMPONENT_WISE_VECTOR_OVERLOAD_OF_UNARY_MATH_FUNCTION
1446#undef GREM_PRIVATE_DEFINE_COMPONENT_WISE_VECTOR_OVERLOAD_OF_BINARY_MATH_FUNCTION
1447#undef GREM_PRIVATE_DEFINE_COMPONENT_WISE_VECTOR_X_SCALAR_OVERLOAD_OF_BINARY_MATH_FUNCTION
1451#define GREM_PRIVATE_DEFINE_COMPONENT_WISE_UNARY_VECTOR_OPERATORS(op) \
1452 template <typename T> \
1453 [[nodiscard]] GREM_ALWAYS_INLINE constexpr vec<1, T> GREM_VECTORCALL operator op(vec<1, T> a) { \
1454 return {static_cast<T>(op a.x)}; \
1456 template <typename T> \
1457 [[nodiscard]] GREM_ALWAYS_INLINE constexpr vec<2, T> GREM_VECTORCALL operator op(vec<2, T> a) { \
1458 return {static_cast<T>(op a.x), static_cast<T>(op a.y)}; \
1460 template <typename T> \
1461 [[nodiscard]] GREM_ALWAYS_INLINE constexpr vec<3, T> GREM_VECTORCALL operator op(vec<3, T> a) { \
1462 return {static_cast<T>(op a.x), static_cast<T>(op a.y), static_cast<T>(op a.z)}; \
1464 template <typename T> \
1465 [[nodiscard]] GREM_ALWAYS_INLINE constexpr vec<4, T> GREM_VECTORCALL operator op(vec<4, T> a) { \
1466 return {static_cast<T>(op a.x), static_cast<T>(op a.y), static_cast<T>(op a.z), static_cast<T>(op a.w)}; \
1469#define GREM_PRIVATE_DEFINE_COMPONENT_WISE_BINARY_VECTOR_OPERATORS(op) \
1470 template <typename T> \
1471 [[nodiscard]] GREM_ALWAYS_INLINE constexpr vec<1, T> GREM_VECTORCALL operator op(vec<1, T> a, vec<1, T> b) { \
1472 return {static_cast<T>(a.x op b.x)}; \
1474 template <typename T> \
1475 [[nodiscard]] GREM_ALWAYS_INLINE constexpr vec<2, T> GREM_VECTORCALL operator op(vec<2, T> a, vec<2, T> b) { \
1476 return {static_cast<T>(a.x op b.x), static_cast<T>(a.y op b.y)}; \
1478 template <typename T> \
1479 [[nodiscard]] GREM_ALWAYS_INLINE constexpr vec<3, T> GREM_VECTORCALL operator op(vec<3, T> a, vec<3, T> b) { \
1480 return {static_cast<T>(a.x op b.x), static_cast<T>(a.y op b.y), static_cast<T>(a.z op b.z)}; \
1482 template <typename T> \
1483 [[nodiscard]] GREM_ALWAYS_INLINE constexpr vec<4, T> GREM_VECTORCALL operator op(vec<4, T> a, vec<4, T> b) { \
1484 return {static_cast<T>(a.x op b.x), static_cast<T>(a.y op b.y), static_cast<T>(a.z op b.z), static_cast<T>(a.w op b.w)}; \
1487#define GREM_PRIVATE_DEFINE_COMPONENT_WISE_BINARY_VECTOR_X_SCALAR_OPERATORS(op) \
1488 template <typename T> \
1489 [[nodiscard]] GREM_ALWAYS_INLINE constexpr vec<1, T> GREM_VECTORCALL operator op(vec<1, T> a, T b) requires(strict_arithmetic<T>) { \
1490 return {static_cast<T>(a.x op b)}; \
1492 template <typename T> \
1493 [[nodiscard]] GREM_ALWAYS_INLINE constexpr vec<2, T> GREM_VECTORCALL operator op(vec<2, T> a, T b) requires(strict_arithmetic<T>) { \
1494 return {static_cast<T>(a.x op b), static_cast<T>(a.y op b)}; \
1496 template <typename T> \
1497 [[nodiscard]] GREM_ALWAYS_INLINE constexpr vec<3, T> GREM_VECTORCALL operator op(vec<3, T> a, T b) requires(strict_arithmetic<T>) { \
1498 return {static_cast<T>(a.x op b), static_cast<T>(a.y op b), static_cast<T>(a.z op b)}; \
1500 template <typename T> \
1501 [[nodiscard]] GREM_ALWAYS_INLINE constexpr vec<4, T> GREM_VECTORCALL operator op(vec<4, T> a, T b) requires(strict_arithmetic<T>) { \
1502 return {static_cast<T>(a.x op b), static_cast<T>(a.y op b), static_cast<T>(a.z op b), static_cast<T>(a.w op b)}; \
1505#define GREM_PRIVATE_DEFINE_COMPONENT_WISE_BINARY_SCALAR_X_VECTOR_OPERATORS(op) \
1506 template <typename T> \
1507 [[nodiscard]] GREM_ALWAYS_INLINE constexpr vec<1, T> GREM_VECTORCALL operator op(T a, vec<1, T> b) requires(strict_arithmetic<T>) { \
1508 return {static_cast<T>(a op b.x)}; \
1510 template <typename T> \
1511 [[nodiscard]] GREM_ALWAYS_INLINE constexpr vec<2, T> GREM_VECTORCALL operator op(T a, vec<2, T> b) requires(strict_arithmetic<T>) { \
1512 return {static_cast<T>(a op b.x), static_cast<T>(a op b.y)}; \
1514 template <typename T> \
1515 [[nodiscard]] GREM_ALWAYS_INLINE constexpr vec<3, T> GREM_VECTORCALL operator op(T a, vec<3, T> b) requires(strict_arithmetic<T>) { \
1516 return {static_cast<T>(a op b.x), static_cast<T>(a op b.y), static_cast<T>(a op b.z)}; \
1518 template <typename T> \
1519 [[nodiscard]] GREM_ALWAYS_INLINE constexpr vec<4, T> GREM_VECTORCALL operator op(T a, vec<4, T> b) requires(strict_arithmetic<T>) { \
1520 return {static_cast<T>(a op b.x), static_cast<T>(a op b.y), static_cast<T>(a op b.z), static_cast<T>(a op b.w)}; \
1523#define GREM_PRIVATE_DEFINE_COMPOUND_VECTOR_OPERATORS(op) \
1524 template <typename T> \
1525 GREM_ALWAYS_INLINE constexpr vec<1, T>& GREM_VECTORCALL operator op(vec<1, T>& a, vec<1, T> b) { \
1529 template <typename T> \
1530 GREM_ALWAYS_INLINE constexpr vec<2, T>& GREM_VECTORCALL operator op(vec<2, T>& a, vec<2, T> b) { \
1535 template <typename T> \
1536 GREM_ALWAYS_INLINE constexpr vec<3, T>& GREM_VECTORCALL operator op(vec<3, T>& a, vec<3, T> b) { \
1542 template <typename T> \
1543 GREM_ALWAYS_INLINE constexpr vec<4, T>& GREM_VECTORCALL operator op(vec<4, T>& a, vec<4, T> b) { \
1551#define GREM_PRIVATE_DEFINE_COMPOUND_VECTOR_X_SCALAR_OPERATORS(op) \
1552 template <typename T> \
1553 GREM_ALWAYS_INLINE constexpr vec<1, T>& GREM_VECTORCALL operator op(vec<1, T>& a, T b) requires(strict_arithmetic<T>) { \
1557 template <typename T> \
1558 GREM_ALWAYS_INLINE constexpr vec<2, T>& GREM_VECTORCALL operator op(vec<2, T>& a, T b) requires(strict_arithmetic<T>) { \
1563 template <typename T> \
1564 GREM_ALWAYS_INLINE constexpr vec<3, T>& GREM_VECTORCALL operator op(vec<3, T>& a, T b) requires(strict_arithmetic<T>) { \
1570 template <typename T> \
1571 GREM_ALWAYS_INLINE constexpr vec<4, T>& GREM_VECTORCALL operator op(vec<4, T>& a, T b) requires(strict_arithmetic<T>) { \
1579#define GREM_PRIVATE_DEFINE_COMPONENT_WISE_UNARY_MATRIX_OPERATORS(op) \
1580 template <size_t R, typename T> \
1581 [[nodiscard]] GREM_ALWAYS_INLINE constexpr mat<1, R, T> GREM_VECTORCALL operator op(const mat<1, R, T>& a) { \
1584 template <size_t R, typename T> \
1585 [[nodiscard]] GREM_ALWAYS_INLINE constexpr mat<2, R, T> GREM_VECTORCALL operator op(const mat<2, R, T>& a) { \
1586 return {op a[0], op a[1]}; \
1588 template <size_t R, typename T> \
1589 [[nodiscard]] GREM_ALWAYS_INLINE constexpr mat<3, R, T> GREM_VECTORCALL operator op(const mat<3, R, T>& a) { \
1590 return {op a[0], op a[1], op a[2]}; \
1592 template <size_t R, typename T> \
1593 [[nodiscard]] GREM_ALWAYS_INLINE constexpr mat<4, R, T> GREM_VECTORCALL operator op(const mat<4, R, T>& a) { \
1594 return {op a[0], op a[1], op a[2], op a[3]}; \
1597#define GREM_PRIVATE_DEFINE_COMPONENT_WISE_BINARY_MATRIX_OPERATORS(op) \
1598 template <size_t R, typename T> \
1599 [[nodiscard]] GREM_ALWAYS_INLINE constexpr mat<1, R, T> GREM_VECTORCALL operator op(const mat<1, R, T>& a, const mat<1, R, T>& b) { \
1600 return {a[0] op b[0]}; \
1602 template <size_t R, typename T> \
1603 [[nodiscard]] GREM_ALWAYS_INLINE constexpr mat<2, R, T> GREM_VECTORCALL operator op(const mat<2, R, T>& a, const mat<2, R, T>& b) { \
1604 return {a[0] op b[0], a[1] op b[1]}; \
1606 template <size_t R, typename T> \
1607 [[nodiscard]] GREM_ALWAYS_INLINE constexpr mat<3, R, T> GREM_VECTORCALL operator op(const mat<3, R, T>& a, const mat<3, R, T>& b) { \
1608 return {a[0] op b[0], a[1] op b[1], a[2] op b[2]}; \
1610 template <size_t R, typename T> \
1611 [[nodiscard]] GREM_ALWAYS_INLINE constexpr mat<4, R, T> GREM_VECTORCALL operator op(const mat<4, R, T>& a, const mat<4, R, T>& b) { \
1612 return {a[0] op b[0], a[1] op b[1], a[2] op b[2], a[3] op b[3]}; \
1615#define GREM_PRIVATE_DEFINE_COMPONENT_WISE_BINARY_MATRIX_X_SCALAR_OPERATORS(op) \
1616 template <size_t R, typename T> \
1617 [[nodiscard]] GREM_ALWAYS_INLINE constexpr mat<1, R, T> GREM_VECTORCALL operator op(const mat<1, R, T>& a, T b) requires(strict_arithmetic<T>) { \
1618 return {a[0] op b}; \
1620 template <size_t R, typename T> \
1621 [[nodiscard]] GREM_ALWAYS_INLINE constexpr mat<2, R, T> GREM_VECTORCALL operator op(const mat<2, R, T>& a, T b) requires(strict_arithmetic<T>) { \
1622 return {a[0] op b, a[1] op b}; \
1624 template <size_t R, typename T> \
1625 [[nodiscard]] GREM_ALWAYS_INLINE constexpr mat<3, R, T> GREM_VECTORCALL operator op(const mat<3, R, T>& a, T b) requires(strict_arithmetic<T>) { \
1626 return {a[0] op b, a[1] op b, a[2] op b}; \
1628 template <size_t R, typename T> \
1629 [[nodiscard]] GREM_ALWAYS_INLINE constexpr mat<4, R, T> GREM_VECTORCALL operator op(const mat<4, R, T>& a, T b) requires(strict_arithmetic<T>) { \
1630 return {a[0] op b, a[1] op b, a[2] op b, a[3] op b}; \
1633#define GREM_PRIVATE_DEFINE_COMPONENT_WISE_BINARY_SCALAR_X_MATRIX_OPERATORS(op) \
1634 template <size_t R, typename T> \
1635 [[nodiscard]] GREM_ALWAYS_INLINE constexpr mat<1, R, T> GREM_VECTORCALL operator op(T a, const mat<1, R, T>& b) requires(strict_arithmetic<T>) { \
1636 return {a op b[0]}; \
1638 template <size_t R, typename T> \
1639 [[nodiscard]] GREM_ALWAYS_INLINE constexpr mat<2, R, T> GREM_VECTORCALL operator op(T a, const mat<2, R, T>& b) requires(strict_arithmetic<T>) { \
1640 return {a op b[0], a op b[1]}; \
1642 template <size_t R, typename T> \
1643 [[nodiscard]] GREM_ALWAYS_INLINE constexpr mat<3, R, T> GREM_VECTORCALL operator op(T a, const mat<3, R, T>& b) requires(strict_arithmetic<T>) { \
1644 return {a op b[0], a op b[1], a op b[2]}; \
1646 template <size_t R, typename T> \
1647 [[nodiscard]] GREM_ALWAYS_INLINE constexpr mat<4, R, T> GREM_VECTORCALL operator op(T a, const mat<4, R, T>& b) requires(strict_arithmetic<T>) { \
1648 return {a op b[0], a op b[1], a op b[2], a op b[3]}; \
1651#define GREM_PRIVATE_DEFINE_COMPOUND_MATRIX_OPERATORS(op) \
1652 template <size_t R, typename T> \
1653 GREM_ALWAYS_INLINE constexpr mat<1, R, T>& GREM_VECTORCALL operator op(mat<1, R, T>& a, const mat<1, R, T>& b) { \
1657 template <size_t R, typename T> \
1658 GREM_ALWAYS_INLINE constexpr mat<2, R, T>& GREM_VECTORCALL operator op(mat<2, R, T>& a, const mat<2, R, T>& b) { \
1663 template <size_t R, typename T> \
1664 GREM_ALWAYS_INLINE constexpr mat<3, R, T>& GREM_VECTORCALL operator op(mat<3, R, T>& a, const mat<3, R, T>& b) { \
1670 template <size_t R, typename T> \
1671 GREM_ALWAYS_INLINE constexpr mat<4, R, T>& GREM_VECTORCALL operator op(mat<4, R, T>& a, const mat<4, R, T>& b) { \
1679#define GREM_PRIVATE_DEFINE_COMPOUND_MATRIX_X_SCALAR_OPERATORS(op) \
1680 template <size_t R, typename T> \
1681 GREM_ALWAYS_INLINE constexpr mat<1, R, T>& GREM_VECTORCALL operator op(mat<1, R, T>& a, T b) requires(strict_arithmetic<T>) { \
1685 template <size_t R, typename T> \
1686 GREM_ALWAYS_INLINE constexpr mat<2, R, T>& GREM_VECTORCALL operator op(mat<2, R, T>& a, T b) requires(strict_arithmetic<T>) { \
1691 template <size_t R, typename T> \
1692 GREM_ALWAYS_INLINE constexpr mat<3, R, T>& GREM_VECTORCALL operator op(mat<3, R, T>& a, T b) requires(strict_arithmetic<T>) { \
1698 template <size_t R, typename T> \
1699 GREM_ALWAYS_INLINE constexpr mat<4, R, T>& GREM_VECTORCALL operator op(mat<4, R, T>& a, T b) requires(strict_arithmetic<T>) { \
1707#define GREM_PRIVATE_DEFINE_COMPONENT_WISE_UNARY_QUATERNION_OPERATORS(op) \
1708 template <typename T> \
1709 [[nodiscard]] GREM_ALWAYS_INLINE constexpr qua<T> GREM_VECTORCALL operator op(qua<T> a) { \
1710 return {static_cast<T>(op a.x), static_cast<T>(op a.y), static_cast<T>(op a.z), static_cast<T>(op a.w)}; \
1713#define GREM_PRIVATE_DEFINE_COMPONENT_WISE_BINARY_QUATERNION_OPERATORS(op) \
1714 template <typename T> \
1715 [[nodiscard]] GREM_ALWAYS_INLINE constexpr qua<T> GREM_VECTORCALL operator op(qua<T> a, qua<T> b) { \
1716 return {static_cast<T>(a.x op b.x), static_cast<T>(a.y op b.y), static_cast<T>(a.z op b.z), static_cast<T>(a.w op b.w)}; \
1719#define GREM_PRIVATE_DEFINE_COMPONENT_WISE_BINARY_QUATERNION_X_SCALAR_OPERATORS(op) \
1720 template <typename T> \
1721 [[nodiscard]] GREM_ALWAYS_INLINE constexpr qua<T> GREM_VECTORCALL operator op(qua<T> a, T b) requires(floating_point<T>) { \
1722 return {static_cast<T>(a.x op b), static_cast<T>(a.y op b), static_cast<T>(a.z op b), static_cast<T>(a.w op b)}; \
1725#define GREM_PRIVATE_DEFINE_COMPONENT_WISE_BINARY_SCALAR_X_QUATERNION_OPERATORS(op) \
1726 template <typename T> \
1727 [[nodiscard]] GREM_ALWAYS_INLINE constexpr qua<T> GREM_VECTORCALL operator op(T a, qua<T> b) requires(floating_point<T>) { \
1728 return {static_cast<T>(a op b.x), static_cast<T>(a op b.y), static_cast<T>(a op b.z), static_cast<T>(a op b.w)}; \
1731#define GREM_PRIVATE_DEFINE_COMPOUND_QUATERNION_OPERATORS(op) \
1732 template <typename T> \
1733 GREM_ALWAYS_INLINE constexpr qua<T>& GREM_VECTORCALL operator op(qua<T>& a, qua<T> b) { \
1741#define GREM_PRIVATE_DEFINE_COMPOUND_QUATERNION_X_SCALAR_OPERATORS(op) \
1742 template <typename T> \
1743 GREM_ALWAYS_INLINE constexpr qua<T>& GREM_VECTORCALL operator op(qua<T>& a, T b) requires(floating_point<T>) { \
1751GREM_PRIVATE_DEFINE_COMPONENT_WISE_UNARY_VECTOR_OPERATORS(~)
1752GREM_PRIVATE_DEFINE_COMPONENT_WISE_BINARY_VECTOR_OPERATORS(|)
1753GREM_PRIVATE_DEFINE_COMPONENT_WISE_BINARY_VECTOR_OPERATORS(&)
1754GREM_PRIVATE_DEFINE_COMPONENT_WISE_BINARY_VECTOR_OPERATORS(^)
1756GREM_PRIVATE_DEFINE_COMPONENT_WISE_UNARY_VECTOR_OPERATORS(+)
1757GREM_PRIVATE_DEFINE_COMPONENT_WISE_UNARY_MATRIX_OPERATORS(+)
1758GREM_PRIVATE_DEFINE_COMPONENT_WISE_UNARY_QUATERNION_OPERATORS(+)
1760GREM_PRIVATE_DEFINE_COMPONENT_WISE_UNARY_VECTOR_OPERATORS(-)
1761GREM_PRIVATE_DEFINE_COMPONENT_WISE_UNARY_MATRIX_OPERATORS(-)
1762GREM_PRIVATE_DEFINE_COMPONENT_WISE_UNARY_QUATERNION_OPERATORS(-)
1764GREM_PRIVATE_DEFINE_COMPONENT_WISE_BINARY_VECTOR_OPERATORS(+)
1765GREM_PRIVATE_DEFINE_COMPONENT_WISE_BINARY_MATRIX_OPERATORS(+)
1766GREM_PRIVATE_DEFINE_COMPONENT_WISE_BINARY_QUATERNION_OPERATORS(+)
1768GREM_PRIVATE_DEFINE_COMPONENT_WISE_BINARY_VECTOR_X_SCALAR_OPERATORS(+)
1769GREM_PRIVATE_DEFINE_COMPONENT_WISE_BINARY_SCALAR_X_VECTOR_OPERATORS(+)
1770GREM_PRIVATE_DEFINE_COMPONENT_WISE_BINARY_MATRIX_X_SCALAR_OPERATORS(+)
1771GREM_PRIVATE_DEFINE_COMPONENT_WISE_BINARY_SCALAR_X_MATRIX_OPERATORS(+)
1772GREM_PRIVATE_DEFINE_COMPONENT_WISE_BINARY_QUATERNION_X_SCALAR_OPERATORS(+)
1773GREM_PRIVATE_DEFINE_COMPONENT_WISE_BINARY_SCALAR_X_QUATERNION_OPERATORS(+)
1775GREM_PRIVATE_DEFINE_COMPONENT_WISE_BINARY_VECTOR_OPERATORS(-)
1776GREM_PRIVATE_DEFINE_COMPONENT_WISE_BINARY_MATRIX_OPERATORS(-)
1777GREM_PRIVATE_DEFINE_COMPONENT_WISE_BINARY_QUATERNION_OPERATORS(-)
1779GREM_PRIVATE_DEFINE_COMPONENT_WISE_BINARY_VECTOR_X_SCALAR_OPERATORS(-)
1780GREM_PRIVATE_DEFINE_COMPONENT_WISE_BINARY_SCALAR_X_VECTOR_OPERATORS(-)
1781GREM_PRIVATE_DEFINE_COMPONENT_WISE_BINARY_MATRIX_X_SCALAR_OPERATORS(-)
1782GREM_PRIVATE_DEFINE_COMPONENT_WISE_BINARY_SCALAR_X_MATRIX_OPERATORS(-)
1783GREM_PRIVATE_DEFINE_COMPONENT_WISE_BINARY_QUATERNION_X_SCALAR_OPERATORS(-)
1784GREM_PRIVATE_DEFINE_COMPONENT_WISE_BINARY_SCALAR_X_QUATERNION_OPERATORS(-)
1786GREM_PRIVATE_DEFINE_COMPONENT_WISE_BINARY_VECTOR_OPERATORS(*)
1788GREM_PRIVATE_DEFINE_COMPONENT_WISE_BINARY_VECTOR_X_SCALAR_OPERATORS(*)
1789GREM_PRIVATE_DEFINE_COMPONENT_WISE_BINARY_SCALAR_X_VECTOR_OPERATORS(*)
1790GREM_PRIVATE_DEFINE_COMPONENT_WISE_BINARY_MATRIX_X_SCALAR_OPERATORS(*)
1791GREM_PRIVATE_DEFINE_COMPONENT_WISE_BINARY_SCALAR_X_MATRIX_OPERATORS(*)
1792GREM_PRIVATE_DEFINE_COMPONENT_WISE_BINARY_QUATERNION_X_SCALAR_OPERATORS(*)
1793GREM_PRIVATE_DEFINE_COMPONENT_WISE_BINARY_SCALAR_X_QUATERNION_OPERATORS(*)
1795GREM_PRIVATE_DEFINE_COMPONENT_WISE_BINARY_VECTOR_OPERATORS(/)
1797GREM_PRIVATE_DEFINE_COMPONENT_WISE_BINARY_VECTOR_X_SCALAR_OPERATORS(/)
1798GREM_PRIVATE_DEFINE_COMPONENT_WISE_BINARY_SCALAR_X_VECTOR_OPERATORS(/)
1799GREM_PRIVATE_DEFINE_COMPONENT_WISE_BINARY_MATRIX_X_SCALAR_OPERATORS(/)
1800GREM_PRIVATE_DEFINE_COMPONENT_WISE_BINARY_SCALAR_X_MATRIX_OPERATORS(/)
1801GREM_PRIVATE_DEFINE_COMPONENT_WISE_BINARY_QUATERNION_X_SCALAR_OPERATORS(/)
1802GREM_PRIVATE_DEFINE_COMPONENT_WISE_BINARY_SCALAR_X_QUATERNION_OPERATORS(/)
1804GREM_PRIVATE_DEFINE_COMPOUND_VECTOR_OPERATORS(+=)
1805GREM_PRIVATE_DEFINE_COMPOUND_MATRIX_OPERATORS(+=)
1806GREM_PRIVATE_DEFINE_COMPOUND_QUATERNION_OPERATORS(+=)
1808GREM_PRIVATE_DEFINE_COMPOUND_VECTOR_X_SCALAR_OPERATORS(+=)
1809GREM_PRIVATE_DEFINE_COMPOUND_MATRIX_X_SCALAR_OPERATORS(+=)
1810GREM_PRIVATE_DEFINE_COMPOUND_QUATERNION_X_SCALAR_OPERATORS(+=)
1812GREM_PRIVATE_DEFINE_COMPOUND_VECTOR_OPERATORS(-=)
1813GREM_PRIVATE_DEFINE_COMPOUND_MATRIX_OPERATORS(-=)
1814GREM_PRIVATE_DEFINE_COMPOUND_QUATERNION_OPERATORS(-=)
1816GREM_PRIVATE_DEFINE_COMPOUND_VECTOR_X_SCALAR_OPERATORS(-=)
1817GREM_PRIVATE_DEFINE_COMPOUND_MATRIX_X_SCALAR_OPERATORS(-=)
1818GREM_PRIVATE_DEFINE_COMPOUND_QUATERNION_X_SCALAR_OPERATORS(-=)
1820GREM_PRIVATE_DEFINE_COMPOUND_VECTOR_OPERATORS(*=)
1822GREM_PRIVATE_DEFINE_COMPOUND_VECTOR_X_SCALAR_OPERATORS(*=)
1823GREM_PRIVATE_DEFINE_COMPOUND_MATRIX_X_SCALAR_OPERATORS(*=)
1824GREM_PRIVATE_DEFINE_COMPOUND_QUATERNION_X_SCALAR_OPERATORS(*=)
1826GREM_PRIVATE_DEFINE_COMPOUND_VECTOR_OPERATORS(/=)
1828GREM_PRIVATE_DEFINE_COMPOUND_VECTOR_X_SCALAR_OPERATORS(/=)
1829GREM_PRIVATE_DEFINE_COMPOUND_MATRIX_X_SCALAR_OPERATORS(/=)
1830GREM_PRIVATE_DEFINE_COMPOUND_QUATERNION_X_SCALAR_OPERATORS(/=)
1832#undef GREM_PRIVATE_DEFINE_COMPONENT_WISE_UNARY_VECTOR_OPERATORS
1833#undef GREM_PRIVATE_DEFINE_COMPONENT_WISE_BINARY_VECTOR_OPERATORS
1834#undef GREM_PRIVATE_DEFINE_COMPONENT_WISE_BINARY_VECTOR_X_SCALAR_OPERATORS
1835#undef GREM_PRIVATE_DEFINE_COMPONENT_WISE_BINARY_SCALAR_X_VECTOR_OPERATORS
1836#undef GREM_PRIVATE_DEFINE_COMPOUND_VECTOR_OPERATORS
1837#undef GREM_PRIVATE_DEFINE_COMPOUND_VECTOR_X_SCALAR_OPERATORS
1838#undef GREM_PRIVATE_DEFINE_COMPONENT_WISE_UNARY_MATRIX_OPERATORS
1839#undef GREM_PRIVATE_DEFINE_COMPONENT_WISE_BINARY_MATRIX_OPERATORS
1840#undef GREM_PRIVATE_DEFINE_COMPONENT_WISE_BINARY_MATRIX_X_SCALAR_OPERATORS
1841#undef GREM_PRIVATE_DEFINE_COMPONENT_WISE_BINARY_SCALAR_X_MATRIX_OPERATORS
1842#undef GREM_PRIVATE_DEFINE_COMPOUND_MATRIX_OPERATORS
1843#undef GREM_PRIVATE_DEFINE_COMPOUND_MATRIX_X_SCALAR_OPERATORS
1844#undef GREM_PRIVATE_DEFINE_COMPONENT_WISE_UNARY_QUATERNION_OPERATORS
1845#undef GREM_PRIVATE_DEFINE_COMPONENT_WISE_BINARY_QUATERNION_OPERATORS
1846#undef GREM_PRIVATE_DEFINE_COMPONENT_WISE_BINARY_QUATERNION_X_SCALAR_OPERATORS
1847#undef GREM_PRIVATE_DEFINE_COMPONENT_WISE_BINARY_SCALAR_X_QUATERNION_OPERATORS
1848#undef GREM_PRIVATE_DEFINE_COMPOUND_QUATERNION_OPERATORS
1849#undef GREM_PRIVATE_DEFINE_COMPOUND_QUATERNION_X_SCALAR_OPERATORS
1853template <
typename T>
1858template <
typename T>
1863template <
typename T>
1865 return a.x + a.y + a.z;
1868template <
typename T>
1870 return a.x + a.y + a.z + a.w;
1875template <
typename T>
1880template <
typename T>
1885template <
typename T>
1887 return a.x * a.y * a.z;
1890template <
typename T>
1892 return a.x * a.y * a.z * a.w;
1897template <
typename T>
1902template <
typename T>
1904 return min(a.x, a.y);
1907template <
typename T>
1909 return min(
min(a.x, a.y), a.z);
1912template <
typename T>
1914 return min(
min(
min(a.x, a.y), a.z), a.w);
1919template <
typename T>
1924template <
typename T>
1926 return max(a.x, a.y);
1929template <
typename T>
1931 return max(
max(a.x, a.y), a.z);
1934template <
typename T>
1936 return max(
max(
max(a.x, a.y), a.z), a.w);
1941template <
typename T>
1946template <
typename T>
1948 return a.x * b.x + a.y * b.y;
1951template <
typename T>
1953 return a.x * b.x + a.y * b.y + a.z * b.z;
1956template <
typename T>
1958 return a.x * b.x + a.y * b.y + a.z * b.z + a.w * b.w;
1961template <
typename T>
1963 return a.
x * b.
x + a.
y * b.
y + a.
z * b.
z + a.
w * b.
w;
1968template <
typename T>
1973template <
typename T>
1978template <
typename T>
1980 return a.x * a.x + a.y * a.y;
1983template <
typename T>
1985 return a.x * a.x + a.y * a.y + a.z * a.z;
1988template <
typename T>
1990 return a.x * a.x + a.y * a.y + a.z * a.z + a.w * a.w;
1993template <
typename T>
1995 return a.x * a.x + a.y * a.y + a.z * a.z + a.w * a.w;
2000template <
typename T>
2009template <
size_t N,
typename T>
2011 if constexpr (N == 1) {
2018template <
typename T>
2025template <
typename T>
2030template <
size_t N,
typename T>
2037template <
typename T>
2042template <
size_t N,
typename T>
2056template <
size_t N,
typename T>
2068template <
typename T>
2081template <
size_t N,
typename T>
2083 const T lengthSquared =
length2(a);
2085 return a /
sqrt(lengthSquared);
2100template <
typename T>
2118template <
size_t N,
typename T>
2135template <
typename T>
2137 return atan2(a.y, a.x);
2148template <
typename T>
2151 return atan2(a.y, a.x);
2156template <
size_t N,
typename T>
2162template <
size_t N,
typename T>
2164 const T magnitude =
length(a);
2165 return {.magnitude = magnitude, .direction = a / magnitude};
2168template <
size_t N,
typename T>
2170 const T magnitude =
length(a);
2177template <
typename T>
2183template <
typename T>
2188template <
typename T>
2190 const T magnitude =
length(a);
2206template <
typename T>
2213template <
typename T>
2218template <
typename T>
2220 return a[0][0] * a[1][1] - a[1][0] * a[0][1];
2223template <
typename T>
2225 return a[0][0] * (a[1][1] * a[2][2] - a[2][1] * a[1][2]) -
2226 a[1][0] * (a[0][1] * a[2][2] - a[2][1] * a[0][2]) +
2227 a[2][0] * (a[0][1] * a[1][2] - a[1][1] * a[0][2]);
2230template <
typename T>
2232 const T aa0 = a[2][2] * a[3][3] - a[3][2] * a[2][3];
2233 const T aa1 = a[2][1] * a[3][3] - a[3][1] * a[2][3];
2234 const T aa2 = a[2][1] * a[3][2] - a[3][1] * a[2][2];
2235 const T aa3 = a[2][0] * a[3][3] - a[3][0] * a[2][3];
2236 const T aa4 = a[2][0] * a[3][2] - a[3][0] * a[2][2];
2237 const T aa5 = a[2][0] * a[3][1] - a[3][0] * a[2][1];
2238 return a[0][0] * (a[1][1] * aa0 - a[1][2] * aa1 + a[1][3] * aa2) -
2239 a[0][1] * (a[1][0] * aa0 - a[1][2] * aa3 + a[1][3] * aa4) +
2240 a[0][2] * (a[1][0] * aa1 - a[1][1] * aa3 + a[1][3] * aa5) -
2241 a[0][3] * (a[1][0] * aa2 - a[1][1] * aa4 + a[1][2] * aa5);
2246template <
size_t C,
size_t R,
typename T>
2249 for (
size_t x = 0; x < R; ++x) {
2250 for (
size_t y = 0; y < C; ++y) {
2251 result[x][y] = a[y][x];
2259template <
typename T>
2261 return {-a.
x, -a.
y, -a.
z, a.
w};
2266template <
typename T>
2268 return {T{1} / a[0][0]};
2271template <
typename T>
2282template <
typename T>
2285 +(a[1][1] * a[2][2] - a[2][1] * a[1][2]),
2286 -(a[0][1] * a[2][2] - a[2][1] * a[0][2]),
2287 +(a[0][1] * a[1][2] - a[1][1] * a[0][2]),
2288 -(a[1][0] * a[2][2] - a[2][0] * a[1][2]),
2289 +(a[0][0] * a[2][2] - a[2][0] * a[0][2]),
2290 -(a[0][0] * a[1][2] - a[1][0] * a[0][2]),
2291 +(a[1][0] * a[2][1] - a[2][0] * a[1][1]),
2292 -(a[0][0] * a[2][1] - a[2][0] * a[0][1]),
2293 +(a[0][0] * a[1][1] - a[1][0] * a[0][1]),
2298template <
typename T>
2300 const T aa00 = a[2][2] * a[3][3] - a[3][2] * a[2][3];
2301 const T aa01 = a[2][1] * a[3][3] - a[3][1] * a[2][3];
2302 const T aa02 = a[2][1] * a[3][2] - a[3][1] * a[2][2];
2303 const T aa03 = a[2][0] * a[3][3] - a[3][0] * a[2][3];
2304 const T aa04 = a[2][0] * a[3][2] - a[3][0] * a[2][2];
2305 const T aa05 = a[2][0] * a[3][1] - a[3][0] * a[2][1];
2306 const T aa06 = a[1][2] * a[3][3] - a[3][2] * a[1][3];
2307 const T aa07 = a[1][1] * a[3][3] - a[3][1] * a[1][3];
2308 const T aa08 = a[1][1] * a[3][2] - a[3][1] * a[1][2];
2309 const T aa09 = a[1][0] * a[3][3] - a[3][0] * a[1][3];
2310 const T aa10 = a[1][0] * a[3][2] - a[3][0] * a[1][2];
2311 const T aa11 = a[1][0] * a[3][1] - a[3][0] * a[1][1];
2312 const T aa12 = a[1][2] * a[2][3] - a[2][2] * a[1][3];
2313 const T aa13 = a[1][1] * a[2][3] - a[2][1] * a[1][3];
2314 const T aa14 = a[1][1] * a[2][2] - a[2][1] * a[1][2];
2315 const T aa15 = a[1][0] * a[2][3] - a[2][0] * a[1][3];
2316 const T aa16 = a[1][0] * a[2][2] - a[2][0] * a[1][2];
2317 const T aa17 = a[1][0] * a[2][1] - a[2][0] * a[1][1];
2319 +(a[1][1] * aa00 - a[1][2] * aa01 + a[1][3] * aa02),
2320 -(a[0][1] * aa00 - a[0][2] * aa01 + a[0][3] * aa02),
2321 +(a[0][1] * aa06 - a[0][2] * aa07 + a[0][3] * aa08),
2322 -(a[0][1] * aa12 - a[0][2] * aa13 + a[0][3] * aa14),
2323 -(a[1][0] * aa00 - a[1][2] * aa03 + a[1][3] * aa04),
2324 +(a[0][0] * aa00 - a[0][2] * aa03 + a[0][3] * aa04),
2325 -(a[0][0] * aa06 - a[0][2] * aa09 + a[0][3] * aa10),
2326 +(a[0][0] * aa12 - a[0][2] * aa15 + a[0][3] * aa16),
2327 +(a[1][0] * aa01 - a[1][1] * aa03 + a[1][3] * aa05),
2328 -(a[0][0] * aa01 - a[0][1] * aa03 + a[0][3] * aa05),
2329 +(a[0][0] * aa07 - a[0][1] * aa09 + a[0][3] * aa11),
2330 -(a[0][0] * aa13 - a[0][1] * aa15 + a[0][3] * aa17),
2331 -(a[1][0] * aa02 - a[1][1] * aa04 + a[1][2] * aa05),
2332 +(a[0][0] * aa02 - a[0][1] * aa04 + a[0][2] * aa05),
2333 -(a[0][0] * aa08 - a[0][1] * aa10 + a[0][2] * aa11),
2334 +(a[0][0] * aa14 - a[0][1] * aa16 + a[0][2] * aa17),
2336 const T
determinant = a[0][0] * adjugate[0][0] + a[0][1] * adjugate[1][0] + a[0][2] * adjugate[2][0] + a[0][3] * adjugate[3][0];
2342template <
typename T>
2344 return {T{1} / a[0][0]};
2347template <
typename T>
2358template <
typename T>
2361 +(a[1][1] * a[2][2] - a[2][1] * a[1][2]),
2362 -(a[1][0] * a[2][2] - a[2][0] * a[1][2]),
2363 +(a[1][0] * a[2][1] - a[2][0] * a[1][1]),
2364 -(a[0][1] * a[2][2] - a[2][1] * a[0][2]),
2365 +(a[0][0] * a[2][2] - a[2][0] * a[0][2]),
2366 -(a[0][0] * a[2][1] - a[2][0] * a[0][1]),
2367 +(a[0][1] * a[1][2] - a[1][1] * a[0][2]),
2368 -(a[0][0] * a[1][2] - a[1][0] * a[0][2]),
2369 +(a[0][0] * a[1][1] - a[1][0] * a[0][1]),
2374template <
typename T>
2376 const T aa00 = a[2][2] * a[3][3] - a[3][2] * a[2][3];
2377 const T aa01 = a[2][1] * a[3][3] - a[3][1] * a[2][3];
2378 const T aa02 = a[2][1] * a[3][2] - a[3][1] * a[2][2];
2379 const T aa03 = a[2][0] * a[3][3] - a[3][0] * a[2][3];
2380 const T aa04 = a[2][0] * a[3][2] - a[3][0] * a[2][2];
2381 const T aa05 = a[2][0] * a[3][1] - a[3][0] * a[2][1];
2382 const T aa06 = a[1][2] * a[3][3] - a[3][2] * a[1][3];
2383 const T aa07 = a[1][1] * a[3][3] - a[3][1] * a[1][3];
2384 const T aa08 = a[1][1] * a[3][2] - a[3][1] * a[1][2];
2385 const T aa09 = a[1][0] * a[3][3] - a[3][0] * a[1][3];
2386 const T aa10 = a[1][0] * a[3][2] - a[3][0] * a[1][2];
2387 const T aa11 = a[1][0] * a[3][1] - a[3][0] * a[1][1];
2388 const T aa12 = a[1][2] * a[2][3] - a[2][2] * a[1][3];
2389 const T aa13 = a[1][1] * a[2][3] - a[2][1] * a[1][3];
2390 const T aa14 = a[1][1] * a[2][2] - a[2][1] * a[1][2];
2391 const T aa15 = a[1][0] * a[2][3] - a[2][0] * a[1][3];
2392 const T aa16 = a[1][0] * a[2][2] - a[2][0] * a[1][2];
2393 const T aa17 = a[1][0] * a[2][1] - a[2][0] * a[1][1];
2395 +(a[1][1] * aa00 - a[1][2] * aa01 + a[1][3] * aa02),
2396 -(a[1][0] * aa00 - a[1][2] * aa03 + a[1][3] * aa04),
2397 +(a[1][0] * aa01 - a[1][1] * aa03 + a[1][3] * aa05),
2398 -(a[1][0] * aa02 - a[1][1] * aa04 + a[1][2] * aa05),
2399 -(a[0][1] * aa00 - a[0][2] * aa01 + a[0][3] * aa02),
2400 +(a[0][0] * aa00 - a[0][2] * aa03 + a[0][3] * aa04),
2401 -(a[0][0] * aa01 - a[0][1] * aa03 + a[0][3] * aa05),
2402 +(a[0][0] * aa02 - a[0][1] * aa04 + a[0][2] * aa05),
2403 +(a[0][1] * aa06 - a[0][2] * aa07 + a[0][3] * aa08),
2404 -(a[0][0] * aa06 - a[0][2] * aa09 + a[0][3] * aa10),
2405 +(a[0][0] * aa07 - a[0][1] * aa09 + a[0][3] * aa11),
2406 -(a[0][0] * aa08 - a[0][1] * aa10 + a[0][2] * aa11),
2407 -(a[0][1] * aa12 - a[0][2] * aa13 + a[0][3] * aa14),
2408 +(a[0][0] * aa12 - a[0][2] * aa15 + a[0][3] * aa16),
2409 -(a[0][0] * aa13 - a[0][1] * aa15 + a[0][3] * aa17),
2410 +(a[0][0] * aa14 - a[0][1] * aa16 + a[0][2] * aa17),
2412 const T
determinant = a[0][0] * adjugate[0][0] + a[0][1] * adjugate[0][1] + a[0][2] * adjugate[0][2] + a[0][3] * adjugate[0][3];
2418template <
typename T>
2425template <
typename T>
2427 return a.x * b.y - b.x * a.y;
2430template <
typename T>
2433 a.y * b.z - b.y * a.z,
2434 a.z * b.x - b.z * a.x,
2435 a.x * b.y - b.x * a.y,
2439template <
typename T>
2442 a.
w * b.
x + a.
x * b.
w + a.
y * b.
z - a.
z * b.
y,
2443 a.
w * b.
y + a.
y * b.
w + a.
z * b.
x - a.
x * b.
z,
2444 a.
w * b.
z + a.
z * b.
w + a.
x * b.
y - a.
y * b.
x,
2445 a.
w * b.
w - a.
x * b.
x - a.
y * b.
y - a.
z * b.
z,
2449template <
typename T>
2454template <
typename T>
2461template <
size_t N,
size_t C2,
size_t R1,
typename T>
2464 for (
size_t y = 0; y < C2; ++y) {
2465 for (
size_t x = 0; x < R1; ++x) {
2466 for (
size_t i = 0; i < N; ++i) {
2467 result[y][x] += a[i][x] * b[y][i];
2476template <
size_t N,
typename T>
2479 for (
size_t x = 0; x < N; ++x) {
2480 for (
size_t i = 0; i < N; ++i) {
2481 result[x] += a[i][x] * b[i];
2489template <
typename T>
2492 a.
w * b.
x + a.
x * b.
w + a.
y * b.
z - a.
z * b.
y,
2493 a.
w * b.
y + a.
y * b.
w + a.
z * b.
x - a.
x * b.
z,
2494 a.
w * b.
z + a.
z * b.
w + a.
x * b.
y - a.
y * b.
x,
2495 a.
w * b.
w - a.
x * b.
x - a.
y * b.
y - a.
z * b.
z,
2501template <
typename T>
2505 return b + (xyzb * a.
w +
cross(xyz, xyzb)) * T{2};
2508template <
typename T>
2515template <
size_t N,
size_t C2,
size_t R1,
typename T>
2522template <
size_t N,
typename T>
2529template <
typename T>
2531 const T xx = a.
x * a.
x;
2532 const T yy = a.
y * a.
y;
2533 const T zz = a.
z * a.
z;
2534 const T xz = a.
x * a.
z;
2535 const T xy = a.
x * a.
y;
2536 const T yz = a.
y * a.
z;
2537 const T wx = a.
w * a.
x;
2538 const T wy = a.
w * a.
y;
2539 const T wz = a.
w * a.
z;
2541 vec<3, T>{T{1} - T{2} * (yy + zz), T{2} * (xy + wz), T{2} * (xz - wy)},
2542 vec<3, T>{T{2} * (xy - wz), T{1} - T{2} * (xx + zz), T{2} * (yz + wx)},
2543 vec<3, T>{T{2} * (xz + wy), T{2} * (yz - wx), T{1} - T{2} * (xx + yy)},
2547template <
typename T>
2549 const T xx = a.
x * a.
x;
2550 const T yy = a.
y * a.
y;
2551 const T zz = a.
z * a.
z;
2552 const T xz = a.
x * a.
z;
2553 const T xy = a.
x * a.
y;
2554 const T yz = a.
y * a.
z;
2555 const T wx = a.
w * a.
x;
2556 const T wy = a.
w * a.
y;
2557 const T wz = a.
w * a.
z;
2559 vec<4, T>{T{1} - T{2} * (yy + zz), T{2} * (xy + wz), T{2} * (xz - wy), T{0}},
2560 vec<4, T>{T{2} * (xy - wz), T{1} - T{2} * (xx + zz), T{2} * (yz + wx), T{0}},
2561 vec<4, T>{T{2} * (xz + wy), T{2} * (yz - wx), T{1} - T{2} * (xx + yy), T{0}},
2568template <
typename T>
2570 const T rSquaredTimes4Minus1[4]{
2571 a[0][0] - a[1][1] - a[2][2],
2572 a[1][1] - a[0][0] - a[2][2],
2573 a[2][2] - a[0][0] - a[1][1],
2574 a[0][0] + a[1][1] + a[2][2],
2577 size_t maxIndex = 0;
2578 if (rSquaredTimes4Minus1[1] > rSquaredTimes4Minus1[maxIndex]) {
2581 if (rSquaredTimes4Minus1[2] > rSquaredTimes4Minus1[maxIndex]) {
2584 if (rSquaredTimes4Minus1[3] > rSquaredTimes4Minus1[maxIndex]) {
2588 const T r = T{0.5} *
sqrt(T{1} + rSquaredTimes4Minus1[maxIndex]);
2589 const T s = T{0.25} / r;
2591 case 0:
return {r, (a[0][1] + a[1][0]) * s, (a[2][0] + a[0][2]) * s, (a[1][2] - a[2][1]) * s};
2592 case 1:
return {(a[0][1] + a[1][0]) * s, r, (a[1][2] + a[2][1]) * s, (a[2][0] - a[0][2]) * s};
2593 case 2:
return {(a[2][0] + a[0][2]) * s, (a[1][2] + a[2][1]) * s, r, (a[0][1] - a[1][0]) * s};
2594 case 3:
return {(a[1][2] - a[2][1]) * s, (a[2][0] - a[0][2]) * s, (a[0][1] - a[1][0]) * s, r};
2599template <
typename T>
2614template <
size_t N,
typename T>
2617 for (
size_t i = 0; i < N; ++i) {
2618 result[i][i] = components[i];
2630template <
typename T>
2635 vec<3, T>{translation.x, translation.y, T{1}},
2646template <
typename T>
2664template <
typename T>
2680template <
typename T>
2701template <
typename T>
2708 vec<3, T>{translation.x, translation.y, T{1}},
2723template <
typename T>
2730 vec<3, T>{translation.x, translation.y, T{1}},
2745template <
typename T>
2750 vec<3, T>{translation.x, translation.y, T{1}},
2764template <
typename T>
2782template <
typename T>
2788 vec<4, T>{translation.x, translation.y, translation.z, T{1}},
2799template <
typename T>
2811template <
typename T>
2813 const T cosPitch =
cos(pitchYawRollAngles.x);
2814 const T sinPitch =
sin(pitchYawRollAngles.x);
2815 const T cosYaw =
cos(pitchYawRollAngles.y);
2816 const T sinYaw =
sin(pitchYawRollAngles.y);
2817 const T cosRoll =
cos(pitchYawRollAngles.z);
2818 const T sinRoll =
sin(pitchYawRollAngles.z);
2821 cosYaw * cosRoll + sinYaw * sinPitch * sinRoll,
2823 -sinYaw * cosRoll + cosYaw * sinPitch * sinRoll,
2827 -cosYaw * sinRoll + sinYaw * sinPitch * cosRoll,
2829 sinRoll * sinYaw + cosYaw * sinPitch * cosRoll,
2849template <
typename T>
2871template <
typename T>
2887 (rotation.x * rotation.z + rotation.y * rotation.w) * scale.z * T{2},
2892 vec<4, T>{translation.x, translation.y, translation.z,
T{1}},
2907template <
typename T>
2928 vec<4, T>{translation.x, translation.y, translation.z, T{1}},
2943template <
typename T>
2949 vec<4, T>{translation.x, translation.y, translation.z, T{1}},
2963template <
typename T>
2979 (rotation.x * rotation.z + rotation.y * rotation.w) * scale.z * T{2},
2984 vec<4, T>{
T{0},
T{0},
T{0},
T{1}},
2988template <
typename T>
2993 const T viewLocalX =
dot(eye, viewRight);
2994 const T viewLocalY =
dot(eye, viewUp);
2995 const T viewLocalZ =
dot(eye, viewBackward);
2997 vec<4, T>{viewRight.x, viewUp.x, viewBackward.x, T{0}},
2998 vec<4, T>{viewRight.y, viewUp.y, viewBackward.y, T{0}},
2999 vec<4, T>{viewRight.z, viewUp.z, viewBackward.z, T{0}},
3000 vec<4, T>{-viewLocalX, -viewLocalY, -viewLocalZ, T{1}},
3004template <
typename T>
3007 vec<4, T>{T{2} / (right - left), T{0}, T{0}, T{0}},
3008 vec<4, T>{T{0}, T{2} / (top - bottom), T{0}, T{0}},
3010 vec<4, T>{(left + right) / (left - right), (bottom + top) / (bottom - top), T{0}, T{1}},
3014template <
typename T>
3017 vec<4, T>{T{2} / (right - left), T{0}, T{0}, T{0}},
3018 vec<4, T>{T{0}, T{2} / (top - bottom), T{0}, T{0}},
3019 vec<4, T>{T{0}, T{0}, T{1} / (nearZ - farZ), T{0}},
3020 vec<4, T>{(left + right) / (left - right), (bottom + top) / (bottom - top), nearZ / (nearZ - farZ), T{1}},
3024template <
typename T>
3027 vec<4, T>{(T{2} * nearZ) / (right - left), T{0}, T{0}, T{0}},
3028 vec<4, T>{T{0}, (T{2} * nearZ) / (top - bottom), T{0}, T{0}},
3029 vec<4, T>{(left + right) / (right - left), (bottom + top) / (top - bottom), farZ / (nearZ - farZ), T{-1}},
3030 vec<4, T>{T{0}, T{0}, (nearZ * farZ) / (nearZ - farZ), T{0}},
3034template <
typename T>
3036 const T tanHalfVerticalFOV =
tan(T{0.5} * verticalFieldOfView);
3038 vec<4, T>{T{1} / (tanHalfVerticalFOV * aspectRatio), T{0}, T{0}, T{0}},
3039 vec<4, T>{T{0}, T{1} / tanHalfVerticalFOV, T{0}, T{0}},
3040 vec<4, T>{T{0}, T{0}, farZ / (nearZ - farZ), T{-1}},
3041 vec<4, T>{T{0}, T{0}, (nearZ * farZ) / (nearZ - farZ), T{0}},
3045template <
typename T>
3047 const T tanHalfVerticalFOV =
tan(T{0.5} * verticalFieldOfView);
3049 vec<4, T>{T{1} / (tanHalfVerticalFOV * aspectRatio), T{0}, T{0}, T{0}},
3050 vec<4, T>{T{0}, T{1} / tanHalfVerticalFOV, T{0}, T{0}},
3061template <
size_t N,
typename T>
3064template <
typename T>
3071template <
typename T>
3089template <
typename T>
3097 result.rotation = atan2(x.y, x.x);
3099 result.rotation = atan2(y.x, -y.y);
3101 result.rotation = T{0};
3117template <
typename T>
3126 result.rotation =
qua<T>{T{0}, T{0}, T{0}, T{1}};
3128 x /= result.scale.x;
3129 y /= result.scale.y;
3130 z /= result.scale.z;
3132 result.scale = -result.scale;
3137 if (x.x + y.y + z.z > T{0}) {
3138 const T s = T{2} *
sqrt(T{1} + x.x + y.y + z.z);
3139 result.rotation.x = (y.z - z.y) / s;
3140 result.rotation.y = (z.x - x.z) / s;
3141 result.rotation.z = (x.y - y.x) / s;
3142 result.rotation.w = T{0.25} * s;
3143 }
else if (x.x >= y.y && x.x >= z.z) {
3144 const T s = T{2} *
sqrt(T{1} + x.x - y.y - z.z);
3145 result.rotation.x = T{0.25} * s;
3146 result.rotation.y = (x.y + y.x) / s;
3147 result.rotation.z = (x.z + z.x) / s;
3148 result.rotation.w = (y.z - z.y) / s;
3149 }
else if (y.y >= z.z) {
3150 const T s = T{2} *
sqrt(T{1} + y.y - x.x - z.z);
3151 result.rotation.x = (y.x + x.y) / s;
3152 result.rotation.y = T{0.25} * s;
3153 result.rotation.z = (y.z + z.y) / s;
3154 result.rotation.w = (z.x - x.z) / s;
3156 const T s = T{2} *
sqrt(T{1} + z.z - x.x - y.y);
3157 result.rotation.x = (z.x + x.z) / s;
3158 result.rotation.y = (z.y + y.z) / s;
3159 result.rotation.z = T{0.25} * s;
3160 result.rotation.w = (x.y - y.x) / s;
3168template <
typename T>
3170 constexpr T COS_ONE_HALF =
static_cast<T
>(0.87758256189037271612);
3171 if (
abs(orientation.w) <= COS_ONE_HALF) {
3172 return acos(orientation.w) * T{2};
3174 const T result =
asin(
length(
vec<3, T>{orientation.x, orientation.y, orientation.z})) * T{2};
3175 if (orientation.w < T{0}) {
3176 return T{2} * numbers::pi_v<T> - result;
3181template <
typename T>
3183 if (
const T wSquared =
length2(orientation.w); wSquared < T{1}) {
3184 return vec<3, T>{orientation.x, orientation.y, orientation.z} * (T{1} /
sqrt(T{1} - wSquared));
3189template <
typename T>
3191 return asin(T{2} * (orientation.w * orientation.x - orientation.y * orientation.z));
3194template <
typename T>
3196 return atan2(T{2} * (orientation.x * orientation.z + orientation.w * orientation.y),
3200template <
typename T>
3202 return atan2(T{2} * (orientation.x * orientation.y + orientation.w * orientation.z),
3206template <
typename T>
3213template <
typename T>
3215 const T cosine =
dot(from, to);
3217 return {T{0}, T{0}, T{0}, T{1}};
3221 return angleAxis(numbers::pi_v<T>, *axis);
3225 const T s =
sqrt(T{2} * (T{1} + cosine));
3226 return {(T{1} / s) *
cross(from, to), T{0.5} * s};
3229template <
typename T>
3238 const vec<3, T> viewBackward = -direction;
3244template <
typename T>
3246 const T halfAngle = T{0.5} * angle;
3247 return {axis *
sin(halfAngle),
cos(halfAngle)};
3250template <
typename T>
3252 const T halfAngle = T{0.5} * angle;
3253 return {
sin(halfAngle), 0.0f, 0.0f,
cos(halfAngle)};
3256template <
typename T>
3258 const T halfAngle = T{0.5} * angle;
3259 return {0.0f,
sin(halfAngle), 0.0f,
cos(halfAngle)};
3262template <
typename T>
3264 const T halfAngle = T{0.5} * angle;
3265 return {0.0f, 0.0f,
sin(halfAngle),
cos(halfAngle)};
3270template <
typename T>
3272 const T halfPitch = T{0.5} * pitchAngle;
3273 const T halfYaw = T{0.5} * yawAngle;
3274 const T halfRoll = T{0.5} * rollAngle;
3275 const T cosHalfPitch =
cos(halfPitch);
3276 const T cosHalfYaw =
cos(halfYaw);
3277 const T cosHalfRoll =
cos(halfRoll);
3278 const T sinHalfPitch =
sin(halfPitch);
3279 const T sinHalfYaw =
sin(halfYaw);
3280 const T sinHalfRoll =
sin(halfRoll);
3282 sinHalfPitch * cosHalfYaw * cosHalfRoll - cosHalfPitch * sinHalfYaw * sinHalfRoll,
3283 cosHalfPitch * sinHalfYaw * cosHalfRoll + sinHalfPitch * cosHalfYaw * sinHalfRoll,
3284 cosHalfPitch * cosHalfYaw * sinHalfRoll - sinHalfPitch * sinHalfYaw * cosHalfRoll,
3285 cosHalfPitch * cosHalfYaw * cosHalfRoll + sinHalfPitch * sinHalfYaw * sinHalfRoll,
3289template <
typename T>
3294template <
typename T>
3300template <
typename T>
3306template <
typename T>
3309 return {-
asin(z.y), atan2(z.x, z.z)};
3312template <
typename T>
3314 const T cosRoll =
cos(rollAngle);
3315 const T sinRoll =
sin(rollAngle);
3316 return {cosRoll, sinRoll};
3319template <
typename T>
3321 const T cosRoll =
cos(rollAngle);
3322 const T sinRoll =
sin(rollAngle);
3323 return {-sinRoll, cosRoll};
3326template <
typename T>
3328 const T cosYaw =
cos(yawAngle);
3329 const T sinYaw =
sin(yawAngle);
3330 const T cosPitch =
cos(pitchAngle);
3331 const T sinPitch =
sin(pitchAngle);
3332 return {sinYaw * cosPitch, -sinPitch, cosYaw * cosPitch};
3335template <
typename T>
3340template <
typename T>
3345template <
typename T>
3350template <
typename T>
3355template <
typename T>
3369template <
typename T>
3371 return wrap((b - a) + numbers::pi_v<T>, T{2} * numbers::pi_v<T>) - numbers::pi_v<T>;
3384template <
typename T>
3389template <
typename T>
3391 return angleInDegrees *
static_cast<T
>(0.01745329251994329577);
3394template <
size_t N,
typename T>
3397 for (
size_t i = 0; i < N; ++i) {
3403template <
typename T>
3405 return angleInRadians *
static_cast<T
>(57.2957795130823208768);
3408template <
size_t N,
typename T>
3411 for (
size_t i = 0; i < N; ++i) {
3427template <
typename T>
3440template <
typename T>
3453template <
typename T>
3466template <
typename T>
3479template <
typename T>
3492template <
typename T>
3505template <
typename T>
3518template <
typename T>
3531template <
typename T>
3544template <
typename T>
3557template <
typename T>
3570template <
typename T>
3583template <
size_t N,
typename T>
3586 for (
size_t i = 0; i < N; ++i) {
3587 result[i] =
signbit(values[i]);
3600template <
typename T>
3603 return std::copysignf(magnitude,
sign);
3605 return std::copysign(magnitude,
sign);
3607 magnitude =
abs(magnitude);
3608 return (
sign < 0) ? -magnitude : magnitude;
3622template <
size_t N,
typename T>
3625 for (
size_t i = 0; i < N; ++i) {
3626 result[i] = copysign(magnitudes[i], signs[i]);
3641template <
typename T>
3643 return mix(T{1}, T{0}, value < edge);
3655template <
size_t N,
typename T>
3659 for (
size_t i = 0; i < N; ++i) {
3660 result[i] = step(edges[i], values[i]);
3674template <
size_t N,
typename T>
3676 requires(
requires(
const T x,
const vec<N, T> y,
const size_t i) {
step(x, y[i]); }) {
3678 for (
size_t i = 0; i < N; ++i) {
3679 result[i] = step(edge, values[i]);
3694template <
typename T>
3696 const T t =
clamp((value - edge0) / (edge1 - edge0), T{0}, T{1});
3697 return t * t * (T{3} - T{2} * t);
3711template <
size_t N,
typename T>
3715 for (
size_t i = 0; i < N; ++i) {
3716 result[i] = smoothstep(edges0[i], edges1[i], values[i]);
3731template <
size_t N,
typename T>
3733 requires(
requires(
const T x,
const T y,
const vec<N, T> z,
const size_t i) {
smoothstep(x, y, z[i]); }) {
3735 for (
size_t i = 0; i < N; ++i) {
3736 result[i] = smoothstep(edge0, edge1, values[i]);
3750template <
typename T>
3752 return a * (T{1} - alpha) + b * alpha;
3765template <
size_t N,
typename T,
typename Alpha>
3767 requires(
requires(
const vec<N, T> x,
const vec<N, T> y,
const Alpha z,
const size_t i) {
lerp(x[i], y[i], z); }) {
3769 for (
size_t i = 0; i < N; ++i) {
3770 result[i] = lerp(a[i], b[i], alpha);
3784template <
typename T>
3786 return a * (1 - alpha) + b * alpha;
3798template <
typename T>
3800 return (value - minValue) / (maxValue - minValue);
3813template <
typename T>
3815 T cosine =
dot(a, b);
3816 if (cosine < T{0}) {
3821 return lerp(a, b, alpha);
3823 const T angle =
acos(cosine);
3824 return (a *
sin((T{1} - alpha) * angle) + b *
sin(alpha * angle)) /
sin(angle);
3836template <
typename T>
3838 return lerp(a, b, alpha);
3851template <
size_t N,
typename T,
typename Alpha>
3853 requires(
requires(
const vec<N, T> x,
const vec<N, T> y,
const Alpha z,
const size_t i) {
mix(x[i], y[i], z); }) {
3855 for (
size_t i = 0; i < N; ++i) {
3856 result[i] = mix(a[i], b[i], alpha);
3871template <
size_t N,
typename T,
typename Alpha>
3873 requires(
requires(
const vec<N, T> x,
const vec<N, T> y,
const Alpha z,
const size_t i) {
mix(x[i], y[i], z[i]); }) {
3875 for (
size_t i = 0; i < N; ++i) {
3876 result[i] = mix(a[i], b[i], alphas[i]);
3891template <
typename T>
3893 return slerp(a, b, alpha);
3905template <
typename T>
3917template <
typename T>
3929template <
size_t N,
typename T>
3942template <
size_t N,
typename T>
3955template <
size_t N,
typename T>
3969template <
size_t N,
typename T>
3971 return a - T{2} *
dot(normal, a) * normal;
3982template <
typename T>
3985 return bit_cast<float32_t>((
static_cast<uint32_t
>(flip) << 31) ^ bit_cast<uint32_t>(value));
3987 return bit_cast<float64_t>((
static_cast<uint64_t
>(flip) << 63) ^ bit_cast<uint64_t>(value));
3989 return (flip) ? -value : value;
4001template <
size_t N,
typename T>
4003 requires(
requires(
const vec<N, T> x,
const bool y,
const size_t i) {
flipSignIf(x[i], y); }) {
4005 for (
size_t i = 0; i < N; ++i) {
4006 result[i] = flipSignIf(value[i], flip);
4024template <
typename T>
4028 return min(value, maxLength);
4031 if (
abs(value) > maxLength) {
4032 value =
copysign(maxLength, value);
4035 if (value < -maxLength) {
4037 }
else if (value > maxLength) {
4058template <
size_t N,
typename T>
4061 if (
const T lengthSquared =
length2(vector); lengthSquared >
length2(maxLength)) {
4062 vector *= maxLength /
sqrt(lengthSquared);
4076template <
typename T>
4079 const T difference = targetValue - value;
4080 if (
abs(difference) <= delta) {
4083 return value +
copysign(delta, difference);
4095template <
size_t N,
typename T>
4098 const vec<N, T> difference = targetValue - value;
4103 return value + difference * (delta /
distance);
4117template <
typename T,
typename Frequency,
typename Duration>
4121 value = targetValue + (value - targetValue) *
exp(-decayRate * deltaTime);
4123 value = targetValue;
4139template <
size_t N,
typename T,
typename Frequency,
typename Duration>
4143 value = targetValue + (value - targetValue) *
exp(-decayRate * deltaTime);
4145 value = targetValue;
4160template <
typename T,
typename Frequency,
typename Duration>
4164 value *=
exp(-decayRate * deltaTime);
4181template <
size_t N,
typename T,
typename Frequency,
typename Duration>
4185 value *=
exp(-decayRate * deltaTime);
4194template <grem::
size_t N,
typename T>
4218 for (
size_t i = 1; i < N; ++i) {
4227template <
typename V>
4261template <grem::
size_t C, grem::
size_t R,
typename T>
4293 for (
size_t i = 1; i < R; ++i) {
4299 for (
size_t i = 1; i < C; ++i) {
4304 for (
size_t j = 1; j < R; ++j) {
4316template <
typename T>
4330 output.append(
"i + ");
4332 output.append(
"j + ");
4334 output.append(
"k + ");
#define GREM_ASSERT(expression)
Definition assertions.hpp:77
#define GREM_ALWAYS_INLINE
Definition attributes.hpp:10
#define GREM_VECTORCALL
Definition attributes.hpp:51
Optional value type that holds either a value or no value.
Definition Optional.hpp:58
Definition concepts.hpp:85
Definition concepts.hpp:35
Definition concepts.hpp:91
Definition concepts.hpp:76
Definition concepts.hpp:79
@ T
't'
Definition keyboard.hpp:90
Definition aliases.hpp:17
constexpr float LN10
Definition math.hpp:48
constexpr float SQRT2
Definition math.hpp:49
constexpr float SQRT3
Definition math.hpp:50
constexpr float LOG2E
Definition math.hpp:42
constexpr float LOG10E
Definition math.hpp:43
constexpr float PHI
Definition math.hpp:53
constexpr float EGAMMA
Definition math.hpp:52
constexpr float LN2
Definition math.hpp:47
constexpr float INV_PI
Definition math.hpp:45
constexpr float INV_SQRTPI
Definition math.hpp:46
constexpr float PI
Definition math.hpp:44
constexpr float E
Definition math.hpp:41
constexpr float INV_SQRT3
Definition math.hpp:51
GREM_ALWAYS_INLINE qua< T > GREM_VECTORCALL quatLookAt(vec< 3, T > direction, vec< 3, T > up)
Definition math.hpp:3230
GREM_ALWAYS_INLINE constexpr T GREM_VECTORCALL length2(T a)
Definition math.hpp:1969
GREM_ALWAYS_INLINE constexpr vec< N, T > GREM_VECTORCALL erf(vec< N, T > a)
Definition math.hpp:1402
GREM_ALWAYS_INLINE constexpr bool GREM_VECTORCALL lessThan(T a, T b)
Definition math.hpp:1240
vec< 1, size_t > uzvec1
Definition math.hpp:433
mat< 2, 2, double > dmat2
Definition math.hpp:808
vec< 1, double > dvec1
Definition math.hpp:441
qua< float > quat
Definition math.hpp:892
GREM_ALWAYS_INLINE constexpr T midpoint(T a, T b)
Get the midpoint between two values.
Definition fundamentals.hpp:559
GREM_ALWAYS_INLINE constexpr T GREM_VECTORCALL lerp(T a, T b, T alpha)
Perform linear interpolation (lerp) between two values.
Definition math.hpp:3751
Clock::duration Duration
Definition Clock.hpp:25
GREM_ALWAYS_INLINE constexpr vec< 2, T > GREM_VECTORCALL angledVector(T angle)
Create a 2-dimensional direction unit vector from an angle.
Definition math.hpp:2207
vec< 4, bool32_t > b32vec4
Definition math.hpp:384
vec< 4, float64_t > f64vec4
Definition math.hpp:456
GREM_ALWAYS_INLINE constexpr vec< N, T > GREM_VECTORCALL cos(vec< N, T > a)
Definition math.hpp:1389
GREM_ALWAYS_INLINE constexpr T GREM_VECTORCALL distance(T a, T b)
Definition math.hpp:2038
GREM_ALWAYS_INLINE constexpr mat< N, N, T > GREM_VECTORCALL diagonal(vec< N, T > components)
Create a matrix from its diagonal components.
Definition math.hpp:2615
GREM_ALWAYS_INLINE constexpr mat< 3, 3, T > GREM_VECTORCALL translateScale(vec< 2, T > translation, vec< 2, T > scale)
Create a combined translation and scale matrix describing a 2D transformation.
Definition math.hpp:2746
GREM_ALWAYS_INLINE constexpr vec< N, T > GREM_VECTORCALL sin(vec< N, T > a)
Definition math.hpp:1393
vec< 4, bool8_t > b8vec4
Definition math.hpp:376
vec< 3, uint16_t > u16vec3
Definition math.hpp:411
GREM_ALWAYS_INLINE constexpr bool GREM_VECTORCALL lessThanEqual(T a, T b)
Definition math.hpp:1245
mat< 4, 4, int8_t > i8mat4
Definition math.hpp:774
GREM_ALWAYS_INLINE constexpr vec< N, T > GREM_VECTORCALL lgamma(vec< N, T > a)
Definition math.hpp:1404
vec< 4, uint64_t > u64vec4
Definition math.hpp:428
vec< 2, uint16_t > u16vec2
Definition math.hpp:410
vec< 4, bool64_t > b64vec4
Definition math.hpp:388
GREM_ALWAYS_INLINE constexpr vec< N, T > GREM_VECTORCALL asin(vec< N, T > a)
Definition math.hpp:1395
vec< 4, float > vec4
Definition math.hpp:440
vec< 4, i16norm > i16vec4norm
Definition math.hpp:468
GREM_ALWAYS_INLINE constexpr T GREM_VECTORCALL flipSignIf(T value, bool flip)
Get a value with its sign flipped if a boolean is true.
Definition math.hpp:3983
GREM_ALWAYS_INLINE constexpr T GREM_VECTORCALL sqrt(T a)
Get the square root of a value.
Definition math.hpp:1114
vec< 3, bool64_t > b64vec3
Definition math.hpp:387
GREM_ALWAYS_INLINE vec< 3, T > GREM_VECTORCALL getPitchYawRoll(qua< T > orientation)
Definition math.hpp:3207
vec< 3, uint32_t > u32vec3
Definition math.hpp:419
mat< 2, 2, int8_t > i8mat2
Definition math.hpp:772
GREM_ALWAYS_INLINE constexpr bool GREM_VECTORCALL notEqual(T a, T b)
Definition math.hpp:1235
mat< 3, 3, int16_t > i16mat3
Definition math.hpp:781
vec< 1, float > vec1
Definition math.hpp:437
GREM_ALWAYS_INLINE qua< T > GREM_VECTORCALL roll(T angle)
Definition math.hpp:3263
GREM_ALWAYS_INLINE constexpr vec< N, T > GREM_VECTORCALL normalize(vec< N, T > a)
Convert a vector to a unit vector of length 1 in the same direction.
Definition math.hpp:2057
mat< 1, 1, uint8_t > u8mat1
Definition math.hpp:775
vec< 1, float16_t > f16vec1
Definition math.hpp:445
GREM_ALWAYS_INLINE mat< 4, 4, T > GREM_VECTORCALL lookAt(vec< 3, T > eye, vec< 3, T > target, vec< 3, T > up)
Definition math.hpp:2989
vec< 4, int > ivec4
Definition math.hpp:392
GREM_ALWAYS_INLINE constexpr mat< 3, 3, T > GREM_VECTORCALL translate(vec< 2, T > translation)
Create a translation matrix describing a 2D translation.
Definition math.hpp:2631
GREM_ALWAYS_INLINE constexpr vec< N, T > flipY(vec< N, T > a)
Get a vector flipped along the Y axis.
Definition math.hpp:3943
vec< 2, float64_t > f64vec2
Definition math.hpp:454
mat< 1, 1, float16_t > f16mat1
Definition math.hpp:811
vec< 2, float > vec2
Definition math.hpp:438
vec< 3, i8norm > i8vec3norm
Definition math.hpp:459
vec< 4, bool > bvec4
Definition math.hpp:372
vec< 3, u8norm > u8vec3norm
Definition math.hpp:463
mat< 1, 1, int8_t > i8mat1
Definition math.hpp:771
GREM_ALWAYS_INLINE constexpr T GREM_VECTORCALL wrap(T value, T limit) noexcept
Wrap a scalar value around a range of non-negative values.
Definition math.hpp:1218
GREM_ALWAYS_INLINE constexpr vec< N, T > GREM_VECTORCALL floor(vec< N, T > a)
Definition math.hpp:1421
mat< 4, 4, int64_t > i64mat4
Definition math.hpp:798
vec< 1, int16_t > i16vec1
Definition math.hpp:405
mat< 1, 1, float32_t > f32mat1
Definition math.hpp:815
mat< 2, 2, int16_t > i16mat2
Definition math.hpp:780
GREM_ALWAYS_INLINE constexpr mat< 1, 1, T > GREM_VECTORCALL inverseTranspose(const mat< 1, 1, T > &a)
Definition math.hpp:2343
GREM_ALWAYS_INLINE constexpr decltype(auto) clamp(T &&value, Low &&minValue, High &&maxValue)
Clamp a value to a specific interval.
Definition fundamentals.hpp:630
GREM_ALWAYS_INLINE T GREM_VECTORCALL getPitch(qua< T > orientation)
Definition math.hpp:3190
GREM_ALWAYS_INLINE constexpr Optional< T > GREM_VECTORCALL tryDivide(T a, T b)
Try to divide a floating-point value by a scalar and produce a defined result.
Definition math.hpp:2101
GREM_ALWAYS_INLINE constexpr bool GREM_VECTORCALL greaterThan(T a, T b)
Definition math.hpp:1250
vec< 3, int64_t > i64vec3
Definition math.hpp:423
mat< 2, 2, uint64_t > u64mat2
Definition math.hpp:800
GREM_ALWAYS_INLINE constexpr T GREM_VECTORCALL smoothstep(T edge0, T edge1, T value)
Perform Hermite interpolation between two edge values.
Definition math.hpp:3695
GREM_ALWAYS_INLINE constexpr T GREM_VECTORCALL determinant(const mat< 1, 1, T > &a)
Definition math.hpp:2214
vec< 4, i8norm > i8vec4norm
Definition math.hpp:460
GREM_ALWAYS_INLINE constexpr vec< N, int > GREM_VECTORCALL ilogb(vec< N, T > a)
Definition math.hpp:1417
vec< 2, i16norm > i16vec2norm
Definition math.hpp:466
vec< 4, ssize_t > izvec4
Definition math.hpp:432
vec< 2, uint64_t > u64vec2
Definition math.hpp:426
vec< 3, uint8_t > u8vec3
Definition math.hpp:403
mat< 4, 4, double > dmat4
Definition math.hpp:810
mat< 4, 4, uint8_t > u8mat4
Definition math.hpp:778
vec< 4, int32_t > i32vec4
Definition math.hpp:416
GREM_ALWAYS_INLINE constexpr qua< T > slerp(qua< T > a, qua< T > b, T alpha)
Perform spherical linear interpolation (slerp) between two quaternions.
Definition math.hpp:3814
constexpr Offset2D operator/(Offset2D a, int32_t b) noexcept
Definition extents.hpp:700
vec< 2, size_t > uzvec2
Definition math.hpp:434
GREM_ALWAYS_INLINE qua< T > GREM_VECTORCALL yaw(T angle)
Definition math.hpp:3257
GREM_ALWAYS_INLINE T copysign(T magnitude, T sign)
Get a value with the sign of a different value.
Definition math.hpp:3601
mat< 1, 1, uint16_t > u16mat1
Definition math.hpp:783
GREM_ALWAYS_INLINE qua< T > GREM_VECTORCALL pitch(T angle)
Definition math.hpp:3251
GREM_ALWAYS_INLINE constexpr mat< R, C, T > transpose(const mat< C, R, T > &a)
Definition math.hpp:2247
mat< 3, 3, uint32_t > u32mat3
Definition math.hpp:793
GREM_ALWAYS_INLINE constexpr vec< N, T > GREM_VECTORCALL tgamma(vec< N, T > a)
Definition math.hpp:1405
GREM_ALWAYS_INLINE constexpr T GREM_VECTORCALL cross(vec< 2, T > a, vec< 2, T > b)
Definition math.hpp:2426
vec< 2, int8_t > i8vec2
Definition math.hpp:398
GREM_ALWAYS_INLINE constexpr T GREM_VECTORCALL pow(T a, T b) noexcept
Calculate the result of raising a given value to a given power.
Definition math.hpp:1179
mat< 2, 2, int > imat2
Definition math.hpp:764
qua< float64_t > f64quat
Definition math.hpp:896
vec< 3, int32_t > i32vec3
Definition math.hpp:415
vec< 2, uint8_t > u8vec2
Definition math.hpp:402
GREM_ALWAYS_INLINE constexpr vec< N, T > GREM_VECTORCALL abs(vec< N, T > a)
Definition math.hpp:1386
mat< 1, 1, unsigned > umat1
Definition math.hpp:767
GREM_ALWAYS_INLINE vec< 3, T > GREM_VECTORCALL convertPitchYawAnglesToZDirection(T pitchAngle, T yawAngle)
Definition math.hpp:3327
GREM_ALWAYS_INLINE constexpr T GREM_VECTORCALL exp(T a) noexcept
Calculate the result of Euler's number raised to a given power.
Definition math.hpp:1154
mat< 1, 1, int32_t > i32mat1
Definition math.hpp:787
vec< 1, bool > bvec1
Definition math.hpp:369
GREM_ALWAYS_INLINE constexpr T expDecay(T value, T targetValue, Frequency decayRate, Duration deltaTime)
Exponentially decay a value towards a target value over a given time.
Definition math.hpp:4118
vec< 1, bool16_t > b16vec1
Definition math.hpp:377
GREM_ALWAYS_INLINE qua< T > GREM_VECTORCALL angleAxis(T angle, vec< 3, T > axis)
Definition math.hpp:3245
GREM_ALWAYS_INLINE constexpr T clampLength(T value, T maxLength)
Get a value with the same sign as a given value, but whose magnitude has been clamped to a maximum le...
Definition math.hpp:4025
GREM_ALWAYS_INLINE constexpr T GREM_VECTORCALL step(T edge, T value)
Evaluate a step function with a given edge value.
Definition math.hpp:3642
GREM_ALWAYS_INLINE constexpr vec< N, T > GREM_VECTORCALL acosh(vec< N, T > a)
Definition math.hpp:1392
vec< 2, bool8_t > b8vec2
Definition math.hpp:374
vec< 2, bool > bvec2
Definition math.hpp:370
vec< 4, int16_t > i16vec4
Definition math.hpp:408
GREM_ALWAYS_INLINE constexpr vec< N, T > flipX(vec< N, T > a)
Get a vector flipped along the X axis.
Definition math.hpp:3930
vec< 1, bool8_t > b8vec1
Definition math.hpp:373
qua< float16_t > f16quat
Definition math.hpp:894
GREM_ALWAYS_INLINE vec< 2, T > GREM_VECTORCALL convertAnglesToForwardDirection(T rollAngle)
Definition math.hpp:3336
GREM_ALWAYS_INLINE constexpr T GREM_VECTORCALL product(vec< 1, T > a)
Definition math.hpp:1876
GREM_ALWAYS_INLINE vec< 2, T > GREM_VECTORCALL convertZDirectionToPitchYawAngles(vec< 3, T > z)
Definition math.hpp:3307
vec< 3, float > vec3
Definition math.hpp:439
mat< 4, 4, float64_t > f64mat4
Definition math.hpp:822
mat< 4, 4, uint64_t > u64mat4
Definition math.hpp:802
GREM_ALWAYS_INLINE mat< 4, 4, T > GREM_VECTORCALL frustum(T left, T right, T bottom, T top, T nearZ, T farZ)
Definition math.hpp:3025
vec< 4, bool16_t > b16vec4
Definition math.hpp:380
vec< 3, unsigned > uvec3
Definition math.hpp:395
mat< 4, 4, float32_t > f32mat4
Definition math.hpp:818
mat< 3, 3, int8_t > i8mat3
Definition math.hpp:773
vec< 4, uint8_t > u8vec4
Definition math.hpp:404
GREM_ALWAYS_INLINE constexpr Optional< DecomposeMagnitudeAngleResult< T > > tryDecomposeMagnitudeAngle(vec< 2, T > a)
Definition math.hpp:2189
GREM_ALWAYS_INLINE constexpr vec< N, T > GREM_VECTORCALL fma(vec< N, T > a, vec< N, T > b, vec< N, T > c)
Definition math.hpp:1431
vec< 1, ssize_t > izvec1
Definition math.hpp:429
GREM_ALWAYS_INLINE constexpr Optional< DecomposeMagnitudeDirectionResult< N, T > > tryDecomposeMagnitudeDirection(vec< N, T > a)
Definition math.hpp:2169
vec< 4, unsigned > uvec4
Definition math.hpp:396
GREM_ALWAYS_INLINE mat< 3, 3, T > GREM_VECTORCALL translateRotate(vec< 2, T > translation, T rotation)
Create a combined translation and rotation matrix describing a 2D transformation.
Definition math.hpp:2724
vec< 1, bool32_t > b32vec1
Definition math.hpp:381
vec< 2, bool32_t > b32vec2
Definition math.hpp:382
constexpr auto rotate(forward_range auto &&range, auto middle)
Definition algorithms.hpp:641
GREM_ALWAYS_INLINE constexpr vec< N, T > GREM_VECTORCALL log1p(vec< N, T > a)
Definition math.hpp:1414
vec< 2, int64_t > i64vec2
Definition math.hpp:422
GREM_ALWAYS_INLINE constexpr T GREM_VECTORCALL minComponent(vec< 1, T > a)
Definition math.hpp:1898
GREM_ALWAYS_INLINE constexpr vec< N, T > GREM_VECTORCALL atanh(vec< N, T > a)
Definition math.hpp:1400
vec< 4, int64_t > i64vec4
Definition math.hpp:424
GREM_ALWAYS_INLINE T GREM_VECTORCALL getRoll(qua< T > orientation)
Definition math.hpp:3201
qua< float32_t > f32quat
Definition math.hpp:895
mat< 3, 3, float > mat3
Definition math.hpp:805
mat< 4, 4, uint32_t > u32mat4
Definition math.hpp:794
constexpr Offset2D operator*(Offset2D a, int32_t b) noexcept
Definition extents.hpp:692
GREM_ALWAYS_INLINE mat< 3, 3, T > GREM_VECTORCALL translateRotateScale(vec< 2, T > translation, T rotation, vec< 2, T > scale)
Create a combined translation, rotation and scale (TRS) matrix describing a 2D transformation.
Definition math.hpp:2702
GREM_ALWAYS_INLINE mat< 4, 4, T > GREM_VECTORCALL infinitePerspective(T verticalFieldOfView, T aspectRatio, T nearZ)
Definition math.hpp:3046
mat< 3, 3, float16_t > f16mat3
Definition math.hpp:813
GREM_ALWAYS_INLINE mat< 3, 3, T > GREM_VECTORCALL rotateScale(T rotation, vec< 2, T > scale)
Create a combined rotation and scale matrix describing a 2D transformation.
Definition math.hpp:2765
GREM_ALWAYS_INLINE vec< 2, T > GREM_VECTORCALL convertRollAngleToXDirection(T rollAngle)
Definition math.hpp:3313
GREM_ALWAYS_INLINE vec< 1, bool > GREM_VECTORCALL isinf(const vec< 1, T > &values)
Check if each component of a vector is infinity.
Definition math.hpp:3480
GREM_ALWAYS_INLINE constexpr T GREM_VECTORCALL distance2(T a, T b)
Definition math.hpp:2026
mat< 1, 1, int > imat1
Definition math.hpp:763
vec< 3, i16norm > i16vec3norm
Definition math.hpp:467
mat< 2, 2, uint16_t > u16mat2
Definition math.hpp:784
vec< 3, bool > bvec3
Definition math.hpp:371
GREM_ALWAYS_INLINE constexpr vec< N, T > GREM_VECTORCALL erfc(vec< N, T > a)
Definition math.hpp:1403
GREM_ALWAYS_INLINE constexpr vec< N, long > GREM_VECTORCALL lround(vec< N, T > a)
Definition math.hpp:1419
vec< 4, size_t > uzvec4
Definition math.hpp:436
vec< 4, u16norm > u16vec4norm
Definition math.hpp:472
GREM_ALWAYS_INLINE constexpr vec< N, T > reflect(vec< N, T > a, vec< N, T > normal)
Get a vector reflected against a plane with a given normal vector.
Definition math.hpp:3970
vec< 3, int8_t > i8vec3
Definition math.hpp:399
vec< 3, bool16_t > b16vec3
Definition math.hpp:379
vec< 3, float32_t > f32vec3
Definition math.hpp:451
T getAngleDifferenceAroundAxis(vec< 3, T > axis, vec< 3, T > a, vec< 3, T > b)
Get the smallest signed angle around an axis between two relative vectors.
Definition math.hpp:3385
vec< 4, uint16_t > u16vec4
Definition math.hpp:412
GREM_ALWAYS_INLINE constexpr T GREM_VECTORCALL convertRadiansToDegrees(T angleInRadians)
Definition math.hpp:3404
vec< 1, i16norm > i16vec1norm
Definition math.hpp:465
GREM_ALWAYS_INLINE constexpr DecomposeMagnitudeDirectionResult< N, T > decomposeMagnitudeDirection(vec< N, T > a)
Definition math.hpp:2163
mat< 2, 2, float32_t > f32mat2
Definition math.hpp:816
vec< 2, u16norm > u16vec2norm
Definition math.hpp:470
GREM_ALWAYS_INLINE constexpr Optional< vec< N, T > > GREM_VECTORCALL tryNormalize(vec< N, T > a)
Try to convert a vector to a unit vector of length 1 in the same direction.
Definition math.hpp:2082
vec< 3, float64_t > f64vec3
Definition math.hpp:455
vec< 2, u8norm > u8vec2norm
Definition math.hpp:462
constexpr bool equal(input_range auto &&rangeA, input_range auto &&rangeB)
Definition algorithms.hpp:358
GREM_ALWAYS_INLINE constexpr T GREM_VECTORCALL mix(T a, T b, T alpha)
Blend between two values based on an alpha value.
Definition math.hpp:3837
GREM_ALWAYS_INLINE constexpr T GREM_VECTORCALL fract(T a)
Definition math.hpp:1142
vec< 2, bool64_t > b64vec2
Definition math.hpp:386
GREM_ALWAYS_INLINE constexpr vec< N, T > GREM_VECTORCALL log2(vec< N, T > a)
Definition math.hpp:1415
GREM_ALWAYS_INLINE constexpr vec< N, T > GREM_VECTORCALL ceil(vec< N, T > a)
Definition math.hpp:1422
GREM_ALWAYS_INLINE constexpr vec< N, T > GREM_VECTORCALL expm1(vec< N, T > a)
Definition math.hpp:1411
GREM_ALWAYS_INLINE constexpr vec< N, T > GREM_VECTORCALL atan(vec< N, T > a)
Definition math.hpp:1399
vec< 2, ssize_t > izvec2
Definition math.hpp:430
qua< float > dquat
Definition math.hpp:893
vec< 1, uint16_t > u16vec1
Definition math.hpp:409
vec< 2, bool16_t > b16vec2
Definition math.hpp:378
vec< 4, uint32_t > u32vec4
Definition math.hpp:420
GREM_ALWAYS_INLINE constexpr vec< N, T > GREM_VECTORCALL trunc(vec< N, T > a)
Definition math.hpp:1420
mat< 3, 3, unsigned > umat3
Definition math.hpp:769
vec< 1, i8norm > i8vec1norm
Definition math.hpp:457
GREM_ALWAYS_INLINE mat< 4, 4, T > GREM_VECTORCALL perspective(T verticalFieldOfView, T aspectRatio, T nearZ, T farZ)
Definition math.hpp:3035
void unreachable()
Definition assertions.hpp:125
GREM_ALWAYS_INLINE mat< 4, 4, T > GREM_VECTORCALL ortho(T left, T right, T bottom, T top)
Definition math.hpp:3005
mat< 2, 2, float > mat2
Definition math.hpp:804
mat< 3, 3, float32_t > f32mat3
Definition math.hpp:817
mat< 4, 4, float16_t > f16mat4
Definition math.hpp:814
GREM_ALWAYS_INLINE T GREM_VECTORCALL convertForwardDirectionToAngles(vec< 2, T > forward)
Definition math.hpp:3351
vec< 1, float64_t > f64vec1
Definition math.hpp:453
GREM_ALWAYS_INLINE constexpr vec< N, T > GREM_VECTORCALL log10(vec< N, T > a)
Definition math.hpp:1413
mat< 2, 2, unsigned > umat2
Definition math.hpp:768
vec< 4, double > dvec4
Definition math.hpp:444
GREM_ALWAYS_INLINE constexpr vec< N, T > GREM_VECTORCALL fdim(vec< N, T > a, vec< N, T > b)
Definition math.hpp:1435
GREM_ALWAYS_INLINE constexpr decltype(auto) max(A &&a, B &&b)
Get the greater of two values, or the first value if they are equivalent.
Definition fundamentals.hpp:598
vec< 3, bool32_t > b32vec3
Definition math.hpp:383
vec< 3, uint64_t > u64vec3
Definition math.hpp:427
GREM_ALWAYS_INLINE constexpr T GREM_VECTORCALL unlerp(T value, T minValue, T maxValue)
Linearly convert a value from a specific range to the [0, 1] range.
Definition math.hpp:3799
mat< 1, 1, int64_t > i64mat1
Definition math.hpp:795
mat< 3, 3, int > imat3
Definition math.hpp:765
mat< 3, 3, double > dmat3
Definition math.hpp:809
GREM_ALWAYS_INLINE constexpr T GREM_VECTORCALL fmod(T a, T b) noexcept
Calculate the floating-point remainder of a scalar division.
Definition math.hpp:1192
GREM_ALWAYS_INLINE constexpr vec< N, T > GREM_VECTORCALL tanh(vec< N, T > a)
Definition math.hpp:1398
GREM_ALWAYS_INLINE constexpr vec< N, T > flipZ(vec< N, T > a)
Get a vector flipped along the Z axis.
Definition math.hpp:3956
GREM_ALWAYS_INLINE vec< N, bool > GREM_VECTORCALL signbit(vec< N, T > values)
Get the sign bits of the components of a vector.
Definition math.hpp:3584
GREM_ALWAYS_INLINE constexpr vec< N, T > GREM_VECTORCALL sinh(vec< N, T > a)
Definition math.hpp:1394
GREM_ALWAYS_INLINE constexpr bool GREM_VECTORCALL greaterThanEqual(T a, T b)
Definition math.hpp:1255
vec< 3, double > dvec3
Definition math.hpp:443
vec< 2, int32_t > i32vec2
Definition math.hpp:414
T getAngleDifference(T a, T b)
Get the smallest signed angle between two absolute angles.
Definition math.hpp:3370
vec< 4, u8norm > u8vec4norm
Definition math.hpp:464
DecomposeTranslationRotationScaleResult< 2, T > decomposeTranslationRotationScale(const mat< 3, 3, T > &a)
Decompose a combined translation, rotation and scale (TRS) matrix describing a 2D transformation into...
Definition math.hpp:3090
GREM_ALWAYS_INLINE qua< T > GREM_VECTORCALL convertAnglesToQuaternion(T pitchAngle, T yawAngle, T rollAngle)
Definition math.hpp:3271
mat< 2, 2, int32_t > i32mat2
Definition math.hpp:788
GREM_ALWAYS_INLINE T GREM_VECTORCALL convertXDirectionToRollAngle(vec< 2, T > x)
Definition math.hpp:3295
GREM_ALWAYS_INLINE constexpr vec< N, T > GREM_VECTORCALL round(vec< N, T > a)
Definition math.hpp:1418
mat< 1, 1, uint32_t > u32mat1
Definition math.hpp:791
vec< 2, float16_t > f16vec2
Definition math.hpp:446
GREM_ALWAYS_INLINE constexpr vec< N, T > GREM_VECTORCALL tan(vec< N, T > a)
Definition math.hpp:1397
GREM_ALWAYS_INLINE qua< T > GREM_VECTORCALL convert3x3MatrixToQuaternion(const mat< 3, 3, T > &a)
Definition math.hpp:2569
GREM_ALWAYS_INLINE constexpr vec< N, T > GREM_VECTORCALL asinh(vec< N, T > a)
Definition math.hpp:1396
vec< 3, u16norm > u16vec3norm
Definition math.hpp:471
GREM_ALWAYS_INLINE qua< T > GREM_VECTORCALL rotation(vec< 3, T > from, vec< 3, T > to)
Definition math.hpp:3214
vec< 1, int32_t > i32vec1
Definition math.hpp:413
GREM_ALWAYS_INLINE constexpr bool GREM_VECTORCALL not_(bool a)
Definition math.hpp:1259
vec< 4, float16_t > f16vec4
Definition math.hpp:448
GREM_ALWAYS_INLINE constexpr T GREM_VECTORCALL exp2(T a) noexcept
Calculate the result of 2 raised to a given power.
Definition math.hpp:1166
GREM_ALWAYS_INLINE constexpr vec< 2, T > rotate90DegreesClockwise(vec< 2, T > a)
Get a 2D vector rotated 90 degrees clockwise.
Definition math.hpp:3918
GREM_ALWAYS_INLINE constexpr T GREM_VECTORCALL inversesqrt(T a)
Get the reciprocal of the square root of a value.
Definition math.hpp:1136
mat< 4, 4, float > mat4
Definition math.hpp:806
GREM_ALWAYS_INLINE constexpr qua< T > GREM_VECTORCALL conjugate(qua< T > a)
Definition math.hpp:2260
vec< 2, float32_t > f32vec2
Definition math.hpp:450
vec< 1, uint8_t > u8vec1
Definition math.hpp:401
vec< 1, float32_t > f32vec1
Definition math.hpp:449
GREM_ALWAYS_INLINE constexpr T GREM_VECTORCALL getAngle(vec< 2, T > a)
Get the absolute angle of a 2-dimensional vector, in radians.
Definition math.hpp:2136
mat< 2, 2, float64_t > f64mat2
Definition math.hpp:820
GREM_ALWAYS_INLINE vec< 1, bool > GREM_VECTORCALL isnan(const vec< 1, T > &values)
Check if each component of a vector is NaN (not a number).
Definition math.hpp:3532
mat< 4, 4, int > imat4
Definition math.hpp:766
mat< 4, 4, int32_t > i32mat4
Definition math.hpp:790
GREM_ALWAYS_INLINE constexpr mat< 1, 1, T > GREM_VECTORCALL inverse(const mat< 1, 1, T > &a)
Definition math.hpp:2267
GREM_ALWAYS_INLINE T GREM_VECTORCALL convertYDirectionToRollAngle(vec< 2, T > y)
Definition math.hpp:3301
GREM_ALWAYS_INLINE constexpr vec< N, T > GREM_VECTORCALL logb(vec< N, T > a)
Definition math.hpp:1416
vec< 1, int64_t > i64vec1
Definition math.hpp:421
GREM_ALWAYS_INLINE vec< 3, T > GREM_VECTORCALL getAxis(qua< T > orientation)
Definition math.hpp:3182
StringViewBase< char, std::char_traits< char > > StringView
Definition StringView.hpp:16
mat< 1, 1, double > dmat1
Definition math.hpp:807
GREM_ALWAYS_INLINE constexpr vec< N, T > GREM_VECTORCALL acos(vec< N, T > a)
Definition math.hpp:1391
mat< 3, 3, int64_t > i64mat3
Definition math.hpp:797
GREM_ALWAYS_INLINE constexpr vec< N, T > GREM_VECTORCALL cosh(vec< N, T > a)
Definition math.hpp:1390
mat< 2, 2, uint32_t > u32mat2
Definition math.hpp:792
vec< 2, unsigned > uvec2
Definition math.hpp:394
mat< 4, 4, unsigned > umat4
Definition math.hpp:770
GREM_ALWAYS_INLINE constexpr decltype(auto) min(A &&a, B &&b)
Get the smaller of two values, or the first value if they are equivalent.
Definition fundamentals.hpp:585
GREM_ALWAYS_INLINE constexpr T GREM_VECTORCALL sign(T a)
Get the sign multiplier of a scalar.
Definition math.hpp:1204
vec< 1, uint32_t > u32vec1
Definition math.hpp:417
mat< 3, 3, int32_t > i32mat3
Definition math.hpp:789
GREM_ALWAYS_INLINE constexpr bool GREM_VECTORCALL all(bool a)
Definition math.hpp:1285
vec< 3, int > ivec3
Definition math.hpp:391
vec< 3, int16_t > i16vec3
Definition math.hpp:407
vec< 1, int8_t > i8vec1
Definition math.hpp:397
GREM_ALWAYS_INLINE constexpr T GREM_VECTORCALL length(T a)
Definition math.hpp:2001
vec< 1, u16norm > u16vec1norm
Definition math.hpp:469
mat< 2, 2, float16_t > f16mat2
Definition math.hpp:812
vec< 1, u8norm > u8vec1norm
Definition math.hpp:461
GREM_ALWAYS_INLINE constexpr vec< N, T > GREM_VECTORCALL cbrt(vec< N, T > a)
Definition math.hpp:1401
vec< 4, float32_t > f32vec4
Definition math.hpp:452
mat< 3, 3, float64_t > f64mat3
Definition math.hpp:821
GREM_ALWAYS_INLINE constexpr T GREM_VECTORCALL convertDegreesToRadians(T angleInDegrees)
Definition math.hpp:3390
vec< 3, float16_t > f16vec3
Definition math.hpp:447
GREM_ALWAYS_INLINE constexpr Optional< T > GREM_VECTORCALL tryGetAngle(vec< 2, T > a)
Try to get the absolute angle of a 2-dimensional vector, in radians.
Definition math.hpp:2149
GREM_ALWAYS_INLINE mat< 3, 3, T > GREM_VECTORCALL convertQuaternionTo3x3Matrix(qua< T > a)
Definition math.hpp:2530
vec< 1, bool64_t > b64vec1
Definition math.hpp:385
mat< 4, 4, uint16_t > u16mat4
Definition math.hpp:786
mat< 1, 1, float > mat1
Definition math.hpp:803
GREM_ALWAYS_INLINE constexpr T GREM_VECTORCALL sum(vec< 1, T > a)
Definition math.hpp:1854
GREM_ALWAYS_INLINE constexpr vec< N, T > GREM_VECTORCALL log(vec< N, T > a)
Definition math.hpp:1412
mat< 3, 3, uint8_t > u8mat3
Definition math.hpp:777
mat< 1, 1, int16_t > i16mat1
Definition math.hpp:779
GREM_ALWAYS_INLINE constexpr bool GREM_VECTORCALL any(bool a)
Definition math.hpp:1272
vec< 2, i8norm > i8vec2norm
Definition math.hpp:458
vec< 1, unsigned > uvec1
Definition math.hpp:393
GREM_ALWAYS_INLINE constexpr mat< 3, 3, T > GREM_VECTORCALL scale(vec< 2, T > scale)
Create a scale matrix describing a 2D scale.
Definition math.hpp:2665
mat< 3, 3, uint64_t > u64mat3
Definition math.hpp:801
vec< 3, size_t > uzvec3
Definition math.hpp:435
vec< 2, uint32_t > u32vec2
Definition math.hpp:418
mat< 2, 2, int64_t > i64mat2
Definition math.hpp:796
GREM_ALWAYS_INLINE constexpr DecomposeMagnitudeAngleResult< T > decomposeMagnitudeAngle(vec< 2, T > a)
Definition math.hpp:2184
vec< 2, double > dvec2
Definition math.hpp:442
mat< 1, 1, float64_t > f64mat1
Definition math.hpp:819
vec< 2, int16_t > i16vec2
Definition math.hpp:406
GREM_ALWAYS_INLINE T GREM_VECTORCALL getYaw(qua< T > orientation)
Definition math.hpp:3195
GREM_ALWAYS_INLINE mat< 4, 4, T > GREM_VECTORCALL convertQuaternionTo4x4Matrix(qua< T > a)
Definition math.hpp:2548
GREM_ALWAYS_INLINE constexpr T GREM_VECTORCALL maxComponent(vec< 1, T > a)
Definition math.hpp:1920
vec< 3, ssize_t > izvec3
Definition math.hpp:431
GREM_ALWAYS_INLINE vec< 1, bool > GREM_VECTORCALL isfinite(const vec< 1, T > &values)
Check if each component of a vector is finite.
Definition math.hpp:3428
vec< 1, uint64_t > u64vec1
Definition math.hpp:425
mat< 4, 4, int16_t > i16mat4
Definition math.hpp:782
GREM_ALWAYS_INLINE vec< 2, T > GREM_VECTORCALL convertRollAngleToYDirection(T rollAngle)
Definition math.hpp:3320
vec< 4, int8_t > i8vec4
Definition math.hpp:400
GREM_ALWAYS_INLINE constexpr mat< 3, 3, T > GREM_VECTORCALL shear(vec< 2, T > shear)
Create a shear matrix describing a 2D shear.
Definition math.hpp:2681
mat< 2, 2, uint8_t > u8mat2
Definition math.hpp:776
GREM_ALWAYS_INLINE constexpr T moveTowards(T value, T targetValue, T delta)
Move a value linearly towards a target by some distance, without overshoot.
Definition math.hpp:4077
vec< 2, int > ivec2
Definition math.hpp:390
mat< 1, 1, uint64_t > u64mat1
Definition math.hpp:799
vec< 1, int > ivec1
Definition math.hpp:389
mat< 3, 3, uint16_t > u16mat3
Definition math.hpp:785
GREM_ALWAYS_INLINE constexpr T select(bool condition, T ifTrue, T ifFalse)
Choose between two values based on a condition.
Definition math.hpp:927
GREM_ALWAYS_INLINE constexpr T GREM_VECTORCALL dot(vec< 1, T > a, vec< 1, T > b)
Definition math.hpp:1942
GREM_ALWAYS_INLINE qua< T > GREM_VECTORCALL convert4x4MatrixToQuaternion(const mat< 4, 4, T > &a)
Definition math.hpp:2600
vec< 3, bool8_t > b8vec3
Definition math.hpp:375
GREM_ALWAYS_INLINE constexpr vec< 2, T > rotate90DegreesCounterclockwise(vec< 2, T > a)
Get a 2D vector rotated 90 degrees counterclockwise.
Definition math.hpp:3906
T angle
Definition math.hpp:2180
T magnitude
Definition math.hpp:2179
vec< N, T > direction
Definition math.hpp:2159
T magnitude
Definition math.hpp:2158
vec< 2, T > translation
Extracted translation vector.
Definition math.hpp:3066
vec< 2, T > scale
Extracted scale vector.
Definition math.hpp:3068
T rotation
Extracted rotation angle.
Definition math.hpp:3067
vec< 3, T > scale
Extracted scale vector.
Definition math.hpp:3075
qua< T > rotation
Extracted rotation quaternion.
Definition math.hpp:3074
vec< 3, T > translation
Extracted translation vector.
Definition math.hpp:3073
Result of the decomposeTranslationRotationScale() function.
Definition math.hpp:3062
Definition fundamentals.hpp:27
GREM_ALWAYS_INLINE constexpr iA2B10G10R10vec4norm() noexcept=default
GREM_ALWAYS_INLINE constexpr iA2B10G10R10vec4norm(float x, vec2 yz, float w) noexcept
Definition math.hpp:506
GREM_ALWAYS_INLINE constexpr iA2B10G10R10vec4norm(vec< 4, U > v) noexcept
Definition math.hpp:485
GREM_ALWAYS_INLINE constexpr iA2B10G10R10vec4norm(float value) noexcept
Definition math.hpp:488
GREM_ALWAYS_INLINE constexpr iA2B10G10R10vec4norm(vec2 xy, vec2 zw) noexcept
Definition math.hpp:500
GREM_ALWAYS_INLINE constexpr iA2B10G10R10vec4norm(vec3 xyz, float w) noexcept
Definition math.hpp:494
GREM_ALWAYS_INLINE constexpr iA2B10G10R10vec4norm(float x, float y, vec2 zw) noexcept
Definition math.hpp:509
GREM_ALWAYS_INLINE constexpr size_t size() const noexcept
Definition math.hpp:542
GREM_ALWAYS_INLINE constexpr float operator[](size_t i) const
Definition math.hpp:538
static constexpr size_t RANK
Definition math.hpp:475
GREM_ALWAYS_INLINE constexpr bool operator==(const iA2B10G10R10vec4norm &) const noexcept=default
GREM_ALWAYS_INLINE constexpr iA2B10G10R10vec4norm(vec2 xy, float z, float w) noexcept
Definition math.hpp:503
GREM_ALWAYS_INLINE constexpr iA2B10G10R10vec4norm(float x, vec3 yzw) noexcept
Definition math.hpp:497
GREM_ALWAYS_INLINE constexpr iA2B10G10R10vec4norm(float x, float y, float z, float w) noexcept
Definition math.hpp:491
GREM_ALWAYS_INLINE constexpr mat() noexcept=default
GREM_ALWAYS_INLINE constexpr mat(vec< 4, T > i, vec< 4, T > j, vec< 4, T > k, vec< 4, T > l) noexcept
Definition math.hpp:702
GREM_ALWAYS_INLINE constexpr mat(vec< 3, T > i, vec< 3, T > j, vec< 3, T > k) noexcept
Definition math.hpp:699
GREM_ALWAYS_INLINE constexpr mat(T value) noexcept
Definition math.hpp:678
GREM_ALWAYS_INLINE constexpr mat(T ix, T iy, T iz, T jx, T jy, T jz, T kx, T ky, T kz) noexcept
Definition math.hpp:687
GREM_ALWAYS_INLINE constexpr const Component & operator[](size_t i) const
Definition math.hpp:753
GREM_ALWAYS_INLINE constexpr mat(vec< 1, T > i) noexcept
Definition math.hpp:693
GREM_ALWAYS_INLINE constexpr size_t size() const noexcept
Definition math.hpp:758
GREM_ALWAYS_INLINE constexpr bool operator==(const mat &) const noexcept=default
GREM_ALWAYS_INLINE constexpr mat(const mat< N, N, T > &m) noexcept
Definition math.hpp:706
static constexpr size_t RANK
Definition math.hpp:665
vec< R, T > Component
Definition math.hpp:664
GREM_ALWAYS_INLINE constexpr mat(T ix, T iy, T jx, T jy) noexcept
Definition math.hpp:684
GREM_ALWAYS_INLINE constexpr mat(T ix, T iy, T iz, T iw, T jx, T jy, T jz, T jw, T kx, T ky, T kz, T kw, T lx, T ly, T lz, T lw) noexcept
Definition math.hpp:690
GREM_ALWAYS_INLINE constexpr mat(vec< 2, T > i, vec< 2, T > j) noexcept
Definition math.hpp:696
GREM_ALWAYS_INLINE constexpr Component & operator[](size_t i)
Definition math.hpp:748
GREM_ALWAYS_INLINE constexpr Component & operator[](size_t i)
Definition math.hpp:857
float y
Definition math.hpp:830
float w
Definition math.hpp:832
GREM_ALWAYS_INLINE constexpr const Component & operator[](size_t i) const
Definition math.hpp:872
GREM_ALWAYS_INLINE constexpr size_t size() const noexcept
Definition math.hpp:887
float x
Definition math.hpp:829
T Component
Definition math.hpp:826
GREM_ALWAYS_INLINE constexpr qua(vec< 3, T > xyz, T w) noexcept
Definition math.hpp:849
static constexpr size_t RANK
Definition math.hpp:827
float z
Definition math.hpp:831
GREM_ALWAYS_INLINE constexpr qua() noexcept=default
GREM_ALWAYS_INLINE constexpr qua(T x, T y, T z, T w) noexcept
Definition math.hpp:843
GREM_ALWAYS_INLINE constexpr bool operator==(const qua &) const noexcept=default
GREM_ALWAYS_INLINE constexpr bool operator==(const uA2B10G10R10vec4norm &) const noexcept=default
GREM_ALWAYS_INLINE constexpr uA2B10G10R10vec4norm(float value) noexcept
Definition math.hpp:594
GREM_ALWAYS_INLINE constexpr uA2B10G10R10vec4norm(float x, vec3 yzw) noexcept
Definition math.hpp:603
static constexpr size_t RANK
Definition math.hpp:581
GREM_ALWAYS_INLINE constexpr uA2B10G10R10vec4norm(float x, vec2 yz, float w) noexcept
Definition math.hpp:612
GREM_ALWAYS_INLINE constexpr float operator[](size_t i) const
Definition math.hpp:636
GREM_ALWAYS_INLINE constexpr uA2B10G10R10vec4norm(vec2 xy, float z, float w) noexcept
Definition math.hpp:609
GREM_ALWAYS_INLINE constexpr uA2B10G10R10vec4norm() noexcept=default
GREM_ALWAYS_INLINE constexpr uA2B10G10R10vec4norm(vec< 4, U > v) noexcept
Definition math.hpp:591
GREM_ALWAYS_INLINE constexpr uA2B10G10R10vec4norm(float x, float y, float z, float w) noexcept
Definition math.hpp:597
GREM_ALWAYS_INLINE constexpr uA2B10G10R10vec4norm(vec3 xyz, float w) noexcept
Definition math.hpp:600
GREM_ALWAYS_INLINE constexpr uA2B10G10R10vec4norm(vec2 xy, vec2 zw) noexcept
Definition math.hpp:606
GREM_ALWAYS_INLINE constexpr uA2B10G10R10vec4norm(float x, float y, vec2 zw) noexcept
Definition math.hpp:615
GREM_ALWAYS_INLINE constexpr size_t size() const noexcept
Definition math.hpp:640
T x
Definition math.hpp:65
T Component
Definition math.hpp:62
GREM_ALWAYS_INLINE constexpr vec(T value) noexcept
Definition math.hpp:73
static constexpr size_t RANK
Definition math.hpp:63
GREM_ALWAYS_INLINE constexpr bool operator==(const vec &) const noexcept=default
GREM_ALWAYS_INLINE constexpr vec() noexcept=default
GREM_ALWAYS_INLINE constexpr Component & operator[](size_t i)
Definition math.hpp:78
GREM_ALWAYS_INLINE constexpr const Component & operator[](size_t i) const
Definition math.hpp:90
GREM_ALWAYS_INLINE constexpr size_t size() const noexcept
Definition math.hpp:102
GREM_ALWAYS_INLINE constexpr const Component & operator[](size_t i) const
Definition math.hpp:150
GREM_ALWAYS_INLINE constexpr bool operator==(const vec &) const noexcept=default
GREM_ALWAYS_INLINE constexpr size_t size() const noexcept
Definition math.hpp:163
T y
Definition math.hpp:113
T x
Definition math.hpp:112
T Component
Definition math.hpp:109
GREM_ALWAYS_INLINE constexpr vec(T x, T y) noexcept
Definition math.hpp:126
GREM_ALWAYS_INLINE constexpr vec(T value) noexcept
Definition math.hpp:122
GREM_ALWAYS_INLINE constexpr vec() noexcept=default
GREM_ALWAYS_INLINE constexpr Component & operator[](size_t i)
Definition math.hpp:137
static constexpr size_t RANK
Definition math.hpp:110
GREM_ALWAYS_INLINE constexpr Component & operator[](size_t i)
Definition math.hpp:217
GREM_ALWAYS_INLINE constexpr vec(T x, T y, T z) noexcept
Definition math.hpp:190
T x
Definition math.hpp:173
GREM_ALWAYS_INLINE constexpr vec() noexcept=default
GREM_ALWAYS_INLINE constexpr bool operator==(const vec &) const noexcept=default
static constexpr size_t RANK
Definition math.hpp:171
T y
Definition math.hpp:174
GREM_ALWAYS_INLINE constexpr vec(T value) noexcept
Definition math.hpp:185
GREM_ALWAYS_INLINE constexpr vec(T x, vec< 2, T > yz) noexcept
Definition math.hpp:200
T Component
Definition math.hpp:170
T z
Definition math.hpp:175
GREM_ALWAYS_INLINE constexpr vec(vec< 2, T > xy, T z) noexcept
Definition math.hpp:195
GREM_ALWAYS_INLINE constexpr const Component & operator[](size_t i) const
Definition math.hpp:231
GREM_ALWAYS_INLINE constexpr size_t size() const noexcept
Definition math.hpp:245
GREM_ALWAYS_INLINE constexpr Component & operator[](size_t i)
Definition math.hpp:334
GREM_ALWAYS_INLINE constexpr vec(T x, T y, vec< 2, T > zw) noexcept
Definition math.hpp:311
GREM_ALWAYS_INLINE constexpr bool operator==(const vec &) const noexcept=default
T y
Definition math.hpp:256
GREM_ALWAYS_INLINE constexpr vec(vec< 2, T > xy, T z, T w) noexcept
Definition math.hpp:299
GREM_ALWAYS_INLINE constexpr vec(T x, vec< 2, T > yz, T w) noexcept
Definition math.hpp:305
GREM_ALWAYS_INLINE constexpr vec(T x, T y, T z, T w) noexcept
Definition math.hpp:275
T z
Definition math.hpp:257
GREM_ALWAYS_INLINE constexpr vec() noexcept=default
GREM_ALWAYS_INLINE constexpr vec(vec< 2, T > xy, vec< 2, T > zw) noexcept
Definition math.hpp:293
GREM_ALWAYS_INLINE constexpr vec(T value) noexcept
Definition math.hpp:269
GREM_ALWAYS_INLINE constexpr vec(vec< 3, T > xyz, T w) noexcept
Definition math.hpp:281
GREM_ALWAYS_INLINE constexpr vec(T x, vec< 3, T > yzw) noexcept
Definition math.hpp:287
T Component
Definition math.hpp:252
static constexpr size_t RANK
Definition math.hpp:253
GREM_ALWAYS_INLINE constexpr const Component & operator[](size_t i) const
Definition math.hpp:349
T w
Definition math.hpp:258
GREM_ALWAYS_INLINE constexpr size_t size() const noexcept
Definition math.hpp:364
T x
Definition math.hpp:255