17#if defined(NNM_BOUNDS_CHECK)
19#define NNM_BOUNDS_CHECK_ASSERT(msg, expression) \
21 throw std::out_of_range(msg);
23#define NNM_BOUNDS_CHECK_ASSERT(msg, expression)
33template <
typename Real>
36 return static_cast<Real
>(3.141592653589793238462643383279502);
44template <
typename Real>
47 return static_cast<Real
>(0.00001);
56template <
typename Num>
57constexpr Num
sign(
const Num value)
59 if (value <
static_cast<Num
>(0)) {
60 return static_cast<Num
>(-1);
62 return static_cast<Num
>(1);
71template <
typename Num>
72constexpr Num
abs(
const Num value)
74 if (value <
static_cast<Num
>(0)) {
87template <
typename Num>
88constexpr Num
max(
const Num a,
const Num b)
104template <
typename Num,
typename... Rest>
105constexpr Num
max(
const Num first,
const Rest... rest)
107 Num max_value = first;
108 max_value =
max(first,
max(rest...));
118template <
typename Real>
123 return abs(value) <= tolerance;
133template <
typename Real>
141 return abs(a - b) <= tolerance;
151template <
typename Real>
164template <
typename Real>
177template <
typename Real>
190template <
typename Real>
202template <
typename Real>
205 return value < static_cast<Real>(0) && !
approx_zero(value);
214template <
typename Real>
217 return value >
static_cast<Real
>(0) && !
approx_zero(value);
226template <
typename Real>
229 return value <= static_cast<Real>(0) ||
approx_zero(value);
238template <
typename Real>
241 return value >=
static_cast<Real
>(0) ||
approx_zero(value);
250template <
typename Real>
253 return std::ceil(value);
264template <
typename Num>
282template <
typename Real>
285 return std::sqrt(value);
295template <
typename Real>
296Real
pow(
const Real base,
const Real power)
298 return std::pow(base, power);
307template <
typename Num>
308constexpr Num
sqrd(
const Num value)
310 return value * value;
320template <
typename Real>
321Real
modf(
const Real dividend,
const Real divisor)
323 const Real result = std::fmod(dividend, divisor);
324 const Real zero =
static_cast<Real
>(0);
325 if ((result < zero && divisor > zero) || (result > zero && divisor < zero)) {
326 return result + divisor;
338template <
typename Int>
339constexpr Int
mod(
const Int dividend,
const Int divisor)
341 const Int result = dividend % divisor;
342 if ((result < 0 && divisor > 0) || (result > 0 && divisor < 0)) {
343 return result + divisor;
355template <
typename Real>
356Real
remf(
const Real dividend,
const Real divisor)
358 return std::fmod(dividend, divisor);
368template <
typename Int>
369constexpr Int
rem(
const Int dividend,
const Int divisor)
371 return dividend % divisor;
380template <
typename Real>
394template <
typename Real>
397 const Real two_pi =
static_cast<Real
>(2) *
pi<Real>();
399 return modf(angle - from, two_pi) <=
modf(to - from, two_pi);
401 return modf(angle - from, two_pi) >=
modf(to - from, two_pi);
410template <
typename Real>
413 return std::floor(value);
424template <
typename Real>
425constexpr Real
lerp(
const Real from,
const Real to,
const Real weight)
427 return from + weight * (to - from);
438template <
typename Real>
439constexpr Real
lerp_clamped(
const Real from,
const Real to,
const Real weight)
441 if (weight >=
static_cast<Real
>(1)) {
444 if (weight <=
static_cast<Real
>(0)) {
447 return lerp(from, to, weight);
456template <
typename Real>
459 return std::sin(value);
468template <
typename Real>
471 return std::cos(value);
480template <
typename Real>
483 return std::tan(value);
492template <
typename Real>
495 return std::round(value);
504template <
typename Real>
507 return std::atan(value);
517template <
typename Real>
518Real
atan2(
const Real y,
const Real x)
520 return std::atan2(y, x);
529template <
typename Real>
541template <
typename Real>
553template <
typename Real>
556 return std::asin(value);
565template <
typename Real>
568 return std::acos(value);
578template <
typename Num>
579constexpr Num
min(
const Num a,
const Num b)
595template <
typename Num,
typename... Rest>
596constexpr Num
min(
const Num first,
const Rest... rest)
598 Num min_value = first;
599 min_value =
min(first,
min(rest...));
609template <
typename Real>
612 return std::log2(value);
615template <
typename Real>
619template <
typename Int>
631template <
typename Real>
635template <
typename Int>
647template <
typename Real>
651template <
typename Real>
655template <
typename Real>
659template <
typename Real>
663template <
typename Real>
667template <
typename Real>
671template <
typename Real>
675template <
typename Real>
679template <
typename Real>
688template <
typename Real>
698 :
x { static_cast<Real>(0) }
699 ,
y { static_cast<Real>(0) }
708 template <
typename Int>
716 template <
typename Other>
718 :
x { static_cast<Real>(vector.
x) }
719 ,
y { static_cast<Real>(vector.
y) }
741 return { value, value };
750 return all(
static_cast<Real
>(0));
759 return all(
static_cast<Real
>(1));
768 return {
static_cast<Real
>(1),
static_cast<Real
>(0) };
777 return {
static_cast<Real
>(0),
static_cast<Real
>(1) };
863 const Real diff_x = to.
x -
x;
864 const Real diff_y = to.
y -
y;
916 if (length ==
static_cast<Real
>(0)) {
970 return x * other.
x +
y * other.
y;
980 return x * other.
y -
y * other.
x;
997 const Real
dot = this->
dot(normal);
999 result.
x =
x -
static_cast<Real
>(2) * normal.
x *
dot;
1000 result.
y =
y -
static_cast<Real
>(2) * normal.
y *
dot;
1012 if (onto_length_sqrd ==
static_cast<Real
>(0)) {
1015 const Real
scale =
dot(onto) / onto_length_sqrd;
1016 return onto *
scale;
1025 return {
static_cast<Real
>(1) /
x,
static_cast<Real
>(1) /
y };
1037 return static_cast<Real
>(0);
1039 const Real cos_angle =
nnm::clamp(
dot(other) / lengths,
static_cast<Real
>(-1),
static_cast<Real
>(1));
1040 const Real angle =
acos(cos_angle);
1041 return cross(other) <
static_cast<Real
>(0) ? -angle : angle;
1188 [[nodiscard]]
constexpr Real
max()
const
1206 [[nodiscard]]
constexpr Real
min()
const
1300 [[nodiscard]]
const Real*
end()
const
1328 [[nodiscard]]
constexpr const Real&
at(
const uint8_t index)
const
1346 constexpr Real&
at(
const uint8_t index)
1364 [[nodiscard]]
constexpr const Real&
operator[](
const uint8_t index)
const
1402 return x == other.
x &&
y == other.
y;
1412 return x != other.
x ||
y != other.
y;
1422 return {
x + other.
x,
y + other.
y };
1444 return {
x - other.
x,
y - other.
y };
1466 return {
x * other.
x,
y * other.
y };
1495 return {
x * value,
y * value };
1517 return {
x / other.
x,
y / other.
y };
1539 return {
x / value,
y / value };
1591 [[nodiscard]]
explicit constexpr operator bool()
const
1593 return x != 0 ||
y != 0;
1604template <
typename Real>
1607 return { value * vector.
x, value * vector.
y };
1617template <
typename Real>
1620 return { value / vector.
x, value / vector.
y };
1627template <
typename Int>
1647 template <
typename Real>
1649 :
x { static_cast<Int>(vector.
x) }
1650 ,
y { static_cast<Int>(vector.
y) }
1672 return { value, value };
1757 return x * other.
x +
y * other.
y;
1767 return x * other.
y -
y * other.
x;
1777 return cross(other) == 0;
1787 return dot(other) == 0;
1804 [[nodiscard]]
constexpr Int
max()
const
1822 [[nodiscard]]
constexpr Int
min()
const
1897 [[nodiscard]]
const Int*
end()
const
1925 [[nodiscard]]
constexpr const Int&
at(
const uint8_t index)
const
1943 constexpr Int&
at(
const uint8_t index)
1961 [[nodiscard]]
constexpr const Int&
operator[](
const uint8_t index)
const
1999 return x == other.
x &&
y == other.
y;
2009 return x != other.
x ||
y != other.
y;
2019 return {
x + other.
x,
y + other.
y };
2041 return {
x - other.
x,
y - other.
y };
2063 return {
x * other.
x,
y * other.
y };
2085 return {
x * value,
y * value };
2107 return {
x / other.
x,
y / other.
y };
2129 return {
x / value,
y / value };
2151 return {
x % other.
x,
y % other.
y };
2173 return {
x % value,
y % value };
2225 [[nodiscard]]
explicit constexpr operator bool()
const
2227 return x != 0 ||
y != 0;
2237 size_t seed = std::hash<Int>()(vector.x);
2238 seed ^= std::hash<Int>()(vector.y) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
2251template <
typename Int>
2254 return { value * vector.
x, value * vector.
y };
2264template <
typename Int>
2267 return { value / vector.
x, value / vector.
y };
2277template <
typename Int>
2280 return { value % vector.
x, value % vector.
y };
2287template <
typename Real>
2298 :
x { static_cast<Real>(0) }
2299 ,
y { static_cast<Real>(0) }
2300 ,
z { static_cast<Real>(0) }
2309 template <
typename Int>
2317 template <
typename Other>
2319 :
x { static_cast<Real>(vector.
x) }
2320 ,
y { static_cast<Real>(vector.
y) }
2321 ,
z { static_cast<Real>(vector.
z) }
2357 return { value, value, value };
2366 return all(
static_cast<Real
>(0));
2375 return all(
static_cast<Real
>(1));
2384 return {
static_cast<Real
>(1),
static_cast<Real
>(0),
static_cast<Real
>(0) };
2393 return {
static_cast<Real
>(0),
static_cast<Real
>(1),
static_cast<Real
>(0) };
2402 return {
static_cast<Real
>(0),
static_cast<Real
>(0),
static_cast<Real
>(1) };
2479 const Real diff_x = to.
x -
x;
2480 const Real diff_y = to.
y -
y;
2481 const Real diff_z = to.
z -
z;
2532 if (length ==
static_cast<Real
>(0)) {
2588 return x * other.
x +
y * other.
y +
z * other.
z;
2598 return {
y * other.
z -
z * other.
y,
z * other.
x -
x * other.
z,
x * other.
y -
y * other.
x };
2616 const Real
dot = this->
dot(normal);
2617 result.
x =
x -
static_cast<Real
>(2) * normal.
x *
dot;
2618 result.
y =
y -
static_cast<Real
>(2) * normal.
y *
dot;
2619 result.
z =
z -
static_cast<Real
>(2) * normal.
z *
dot;
2631 if (onto_length_sqrd ==
static_cast<Real
>(0)) {
2634 const Real
scale =
dot(onto) / onto_length_sqrd;
2635 return onto *
scale;
2644 return {
static_cast<Real
>(1) /
x,
static_cast<Real
>(1) /
y,
static_cast<Real
>(1) /
z };
2685 return cross(other);
2846 [[nodiscard]]
constexpr Real
max()
const
2864 [[nodiscard]]
constexpr Real
min()
const
2885 uint8_t max_axis = 0;
2903 uint8_t max_axis = 0;
2905 if (y_abs > max_val) {
2922 uint8_t min_axis = 0;
2940 uint8_t min_axis = 0;
2942 if (y_abs < min_val) {
2993 [[nodiscard]]
const Real*
end()
const
3021 [[nodiscard]]
constexpr const Real&
at(
const uint8_t index)
const
3041 constexpr Real&
at(
const uint8_t index)
3061 [[nodiscard]]
constexpr const Real&
operator[](
const uint8_t index)
const
3103 return x == other.
x &&
y == other.
y &&
z == other.
z;
3113 return x != other.
x ||
y != other.
y ||
z != other.
z;
3123 return {
x + other.
x,
y + other.
y,
z + other.
z };
3146 return {
x - other.
x,
y - other.
y,
z - other.
z };
3169 return {
x * other.
x,
y * other.
y,
z * other.
z };
3199 return {
x * value,
y * value,
z * value };
3222 return {
x / other.
x,
y / other.
y,
z / other.
z };
3245 return {
x / value,
y / value,
z / value };
3276 return { -
x, -
y, -
z };
3286 for (uint8_t i = 0; i < 3; ++i) {
3287 if (
at(i) < other.
at(i)) {
3290 if (
at(i) > other.
at(i)) {
3300 [[nodiscard]]
explicit constexpr operator bool()
const
3302 return x !=
static_cast<Real
>(0) ||
y !=
static_cast<Real
>(0) ||
z !=
static_cast<Real
>(0);
3313template <
typename Real>
3316 return { value * vector.
x, value * vector.
y, value * vector.
z };
3326template <
typename Real>
3329 return { value / vector.
x, value / vector.
y, value / vector.
z };
3336template <
typename Int>
3358 template <
typename Real>
3360 :
x { static_cast<Int>(vector.
x) }
3361 ,
y { static_cast<Int>(vector.
y) }
3362 ,
z { static_cast<Int>(vector.
z) }
3398 return { value, value, value };
3492 return x * other.
x +
y * other.
y +
z * other.
z;
3502 return {
y * other.
z -
z * other.
y,
z * other.
x -
x * other.
z,
x * other.
y -
y * other.
x };
3522 return dot(other) == 0;
3533 return cross(other);
3540 [[nodiscard]]
constexpr Int
max()
const
3558 [[nodiscard]]
constexpr Int
min()
const
3579 uint8_t max_axis = 0;
3597 uint8_t max_axis = 0;
3599 if (y_abs > max_val) {
3616 uint8_t min_axis = 0;
3634 uint8_t min_axis = 0;
3636 if (y_abs < min_val) {
3668 [[nodiscard]]
const Int*
end()
const
3696 [[nodiscard]]
constexpr const Int&
at(
const uint8_t index)
const
3716 constexpr Int&
at(
const uint8_t index)
3736 [[nodiscard]]
constexpr const Int&
operator[](
const uint8_t index)
const
3778 return x == other.
x &&
y == other.
y &&
z == other.
z;
3788 return x != other.
x ||
y != other.
y ||
z != other.
z;
3798 return {
x + other.
x,
y + other.
y,
z + other.
z };
3821 return {
x - other.
x,
y - other.
y,
z - other.
z };
3844 return {
x * other.
x,
y * other.
y,
z * other.
z };
3867 return {
x * value,
y * value,
z * value };
3890 return {
x / other.
x,
y / other.
y,
z / other.
z };
3913 return {
x / value,
y / value,
z / value };
3936 return {
x % other.
x,
y % other.
y,
z % other.
z };
3959 return {
x % value,
y % value,
z % value };
3990 return { -
x, -
y, -
z };
4000 for (uint8_t i = 0; i < 3; ++i) {
4001 if (
at(i) < other.
at(i)) {
4004 if (
at(i) > other.
at(i)) {
4014 [[nodiscard]]
constexpr explicit operator bool()
const
4016 return x != 0 ||
y != 0 ||
z != 0;
4026 size_t seed = std::hash<Int>()(vector.x);
4027 seed ^= std::hash<Int>()(vector.y) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
4028 seed ^= std::hash<Int>()(vector.z) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
4041template <
typename Int>
4044 return { value * vector.
x, value * vector.
y, value * vector.
z };
4054template <
typename Int>
4057 return { value / vector.
x, value / vector.
y, value / vector.
z };
4067template <
typename Int>
4070 return { value % vector.
x, value % vector.
y, value % vector.
z };
4077template <
typename Real>
4089 :
x { static_cast<Real>(0) }
4090 ,
y { static_cast<Real>(0) }
4091 ,
z { static_cast<Real>(0) }
4092 ,
w { static_cast<Real>(0) }
4101 template <
typename Other>
4103 :
x { static_cast<Real>(vector.
x) }
4104 ,
y { static_cast<Real>(vector.
y) }
4105 ,
z { static_cast<Real>(vector.
z) }
4106 ,
w { static_cast<Real>(vector.
w) }
4144 constexpr Vector4(
const Real
x,
const Real
y,
const Real
z,
const Real
w)
4166 return { value, value, value, value };
4175 return all(
static_cast<Real
>(0));
4184 return all(
static_cast<Real
>(1));
4193 return {
static_cast<Real
>(1),
static_cast<Real
>(0),
static_cast<Real
>(0),
static_cast<Real
>(0) };
4202 return {
static_cast<Real
>(0),
static_cast<Real
>(1),
static_cast<Real
>(0),
static_cast<Real
>(0) };
4211 return {
static_cast<Real
>(0),
static_cast<Real
>(0),
static_cast<Real
>(1),
static_cast<Real
>(0) };
4220 return {
static_cast<Real
>(0),
static_cast<Real
>(0),
static_cast<Real
>(0),
static_cast<Real
>(1) };
4300 if (length ==
static_cast<Real
>(0)) {
4360 return x * other.
x +
y * other.
y +
z * other.
z +
w * other.
w;
4377 static_cast<Real
>(1) /
x,
static_cast<Real
>(1) /
y,
static_cast<Real
>(1) /
z,
static_cast<Real
>(1) /
w
4400 [[nodiscard]]
constexpr Real
max()
const
4418 [[nodiscard]]
constexpr Real
min()
const
4439 uint8_t max_axis = 0;
4457 uint8_t max_axis = 0;
4459 if (y_abs > max_val) {
4464 if (z_abs > max_val) {
4481 uint8_t min_axis = 0;
4503 uint8_t min_axis = 0;
4505 if (y_abs < min_val) {
4510 if (z_abs < min_val) {
4571 [[nodiscard]]
const Real*
end()
const
4599 [[nodiscard]]
constexpr const Real&
at(
const uint8_t index)
const
4621 constexpr Real&
at(
const uint8_t index)
4643 [[nodiscard]]
constexpr const Real&
operator[](
const uint8_t index)
const
4689 return x == other.
x &&
y == other.
y &&
z == other.
z &&
w == other.
w;
4699 return x != other.
x ||
y != other.
y ||
z != other.
z ||
w != other.
w;
4709 return {
x + other.
x,
y + other.
y,
z + other.
z,
w + other.
w };
4733 return {
x - other.
x,
y - other.
y,
z - other.
z,
w - other.
w };
4757 return {
x * other.
x,
y * other.
y,
z * other.
z,
w * other.
w };
4788 return {
x * value,
y * value,
z * value,
w * value };
4812 return {
x / other.
x,
y / other.
y,
z / other.
z,
w / other.
w };
4836 return {
x / value,
y / value,
z / value,
w / value };
4860 for (uint8_t i = 0; i < 4; ++i) {
4861 if (
at(i) < other.
at(i)) {
4864 if (
at(i) > other.
at(i)) {
4877 return {
x,
y,
z,
w };
4886 return { -
x, -
y, -
z, -
w };
4892 [[nodiscard]]
explicit constexpr operator bool()
const
4894 return x !=
static_cast<Real
>(0) ||
y !=
static_cast<Real
>(0) ||
z !=
static_cast<Real
>(0)
4895 ||
w !=
static_cast<Real
>(0);
4906template <
typename Real>
4909 return { value * vector.
x, value * vector.
y, value * vector.
z, value * vector.
w };
4919template <
typename Real>
4922 return { value / vector.
x, value / vector.
y, value / vector.
z, value / vector.
w };
4929template <
typename Real>
4941 :
x { static_cast<Real>(0) }
4942 ,
y { static_cast<Real>(0) }
4943 ,
z { static_cast<Real>(0) }
4944 ,
w { static_cast<Real>(1) }
4953 template <
typename Other>
4955 :
x { static_cast<Real>(quaternion.
x) }
4956 ,
y { static_cast<Real>(quaternion.
y) }
4957 ,
z { static_cast<Real>(quaternion.
z) }
4958 ,
w { static_cast<Real>(quaternion.
w) }
4995 return {
static_cast<Real
>(0),
static_cast<Real
>(0),
static_cast<Real
>(0),
static_cast<Real
>(1) };
5007 const Real half_sin =
sin(
angle /
static_cast<Real
>(2));
5009 result.
x = norm.
x * half_sin;
5010 result.
y = norm.
y * half_sin;
5011 result.
z = norm.
z * half_sin;
5012 result.
w =
cos(
angle /
static_cast<Real
>(2));
5027 const Real dot =
clamp(from_norm.
dot(to_norm),
static_cast<Real
>(-1),
static_cast<Real
>(1));
5049 const Real sin_half_angle =
sqrt(
static_cast<Real
>(1) -
sqrd(relative.
w));
5050 if (sin_half_angle ==
static_cast<Real
>(0)) {
5064 dot =
clamp(dot,
static_cast<Real
>(-1),
static_cast<Real
>(1));
5065 return static_cast<Real
>(2) *
acos(dot);
5074 const Real sin_half_angle =
sqrt(
static_cast<Real
>(1) -
sqrd(
w));
5075 if (sin_half_angle ==
static_cast<Real
>(0)) {
5087 return static_cast<Real
>(2) *
acos(
w);
5096 return { -
x, -
y, -
z,
w };
5127 const Real dot =
clamp(vector.
dot(vector_to),
static_cast<Real
>(-1),
static_cast<Real
>(1));
5130 if (sin_angle ==
static_cast<Real
>(0)) {
5134 (vector *
sin((
static_cast<Real
>(1) - weight) *
angle) + vector_to *
sin(weight *
angle)) / sin_angle);
5174 [[nodiscard]]
constexpr const Real&
at(
const uint8_t index)
const
5196 constexpr Real&
at(
const uint8_t index)
5218 [[nodiscard]]
constexpr const Real&
operator[](
const uint8_t index)
const
5264 return x == other.
x &&
y == other.
y &&
z == other.
z &&
w == other.
w;
5274 return x != other.
x ||
y != other.
y ||
z != other.
z ||
w != other.
w;
5285 vector.
x =
w * other.
x +
x * other.
w +
y * other.
z -
z * other.
y;
5286 vector.
y =
w * other.
y -
x * other.
z +
y * other.
w +
z * other.
x;
5287 vector.
z =
w * other.
z +
x * other.
y -
y * other.
x +
z * other.
w;
5288 vector.
w =
w * other.
w -
x * other.
x -
y * other.
y -
z * other.
z;
5299 *
this = *
this * other;
5316 [[nodiscard]]
explicit constexpr operator bool()
const
5318 return x !=
static_cast<Real
>(0) ||
y !=
static_cast<Real
>(0) ||
z !=
static_cast<Real
>(0)
5319 ||
w !=
static_cast<Real
>(0);
5327template <
typename Real>
5336 :
columns { {
static_cast<Real
>(1),
static_cast<Real
>(0) }, {
static_cast<Real
>(0),
static_cast<Real
>(1) } }
5345 template <
typename Other>
5348 {
static_cast<Real
>(matrix.columns[1].x),
static_cast<Real
>(matrix.columns[1].y) } }
5358 :
columns { column0, column1 }
5369 constexpr Matrix2(
const Real col0_row0,
const Real col0_row1,
const Real col1_row0,
const Real col1_row1)
5370 :
columns { { col0_row0, col0_row1 }, { col1_row0, col1_row1 } }
5381 return { { value, value }, { value, value } };
5390 return all(
static_cast<Real
>(0));
5399 return all(
static_cast<Real
>(1));
5408 return { {
static_cast<Real
>(1),
static_cast<Real
>(0) }, {
static_cast<Real
>(0),
static_cast<Real
>(1) } };
5415 [[nodiscard]]
constexpr Real
trace()
const
5417 return at(0, 0) +
at(1, 1);
5426 return at(0, 0) *
at(1, 1) -
at(1, 0) *
at(0, 1);
5435 [[nodiscard]]
constexpr Real
minor_at(
const uint8_t column,
const uint8_t row)
const
5438 const uint8_t other_column = (column + 1) % 2;
5439 const uint8_t other_row = (row + 1) % 2;
5440 return at(other_column, other_row);
5450 for (uint8_t c = 0; c < 2; ++c) {
5451 for (uint8_t r = 0; r < 2; ++r) {
5464 [[nodiscard]]
constexpr Real
cofactor_at(
const uint8_t column,
const uint8_t row)
const
5467 return ((column + row) % 2 == 0 ?
static_cast<Real
>(1) :
static_cast<Real
>(-1)) *
minor_at(column, row);
5485 return { {
at(0, 0),
at(1, 0) }, {
at(0, 1),
at(1, 1) } };
5510 [[nodiscard]]
constexpr std::optional<Matrix2>
inverse()
const
5513 if (det ==
static_cast<Real
>(0)) {
5514 return std::nullopt;
5526 for (uint8_t c = 0; c < 2; ++c) {
5527 for (uint8_t r = 0; r < 2; ++r) {
5542 for (uint8_t c = 0; c < 2; ++c) {
5543 for (uint8_t r = 0; r < 2; ++r) {
5580 [[nodiscard]]
constexpr const Real&
at(
const uint8_t column,
const uint8_t row)
const
5592 constexpr Real&
at(
const uint8_t column,
const uint8_t row)
5611 [[nodiscard]]
const Real*
end()
const
5663 for (uint8_t i = 0; i < 2; ++i) {
5664 if (
at(i) != other.
at(i)) {
5678 for (uint8_t i = 0; i < 2; ++i) {
5679 if (
at(i) != other.
at(i)) {
5694 for (uint8_t c = 0; c < 2; ++c) {
5695 result.
at(c) =
at(c) + other.
at(c);
5707 for (uint8_t c = 0; c < 2; ++c) {
5708 at(c) += other.
at(c);
5721 for (uint8_t c = 0; c < 2; ++c) {
5722 result.
at(c) =
at(c) - other.
at(c);
5734 for (uint8_t c = 0; c < 2; ++c) {
5735 at(c) -= other.
at(c);
5747 auto result =
zero();
5748 for (uint8_t c = 0; c < 2; ++c) {
5749 for (uint8_t r = 0; r < 2; ++r) {
5750 for (uint8_t i = 0; i < 2; ++i) {
5751 result.at(c, r) +=
at(i, r) * other.
at(c, i);
5765 *
this = *
this * other;
5777 for (uint8_t r = 0; r < 2; ++r) {
5778 result.
at(r) =
at(0, r) * vector.
at(0) +
at(1, r) * vector.
at(1);
5790 return {
at(0) * value,
at(1) * value };
5812 return {
at(0) / value,
at(1) / value };
5834 for (uint8_t i = 0; i < 4; ++i) {
5835 if (
at(i) < other.
at(i)) {
5838 if (
at(i) != other.
at(i)) {
5848 constexpr explicit operator bool()
const
5850 for (uint8_t c = 0; c < 2; ++c) {
5851 for (uint8_t r = 0; r < 2; ++r) {
5852 if (
at(c, r) != 0) {
5868template <
typename Real>
5872 for (uint8_t c = 0; c < 2; ++c) {
5873 for (uint8_t r = 0; r < 2; ++r) {
5874 result.
at(c, r) = value * matrix.
at(c, r);
5887template <
typename Real>
5891 for (uint8_t c = 0; c < 2; ++c) {
5892 for (uint8_t r = 0; r < 2; ++r) {
5893 result.
at(c, r) = value / matrix.
at(c, r);
5903template <
typename Real>
5921 template <
typename Other>
5953 return Basis2({ { factor.
x,
static_cast<Real
>(0) }, {
static_cast<Real
>(0), factor.
y } });
5963 return Basis2({ {
static_cast<Real
>(1),
static_cast<Real
>(0) }, { factor,
static_cast<Real
>(1) } });
5973 return Basis2({ {
static_cast<Real
>(1), factor }, {
static_cast<Real
>(0),
static_cast<Real
>(1) } });
5980 [[nodiscard]]
constexpr Real
trace()
const
5991 return matrix.determinant();
6007 [[nodiscard]]
constexpr std::optional<Basis2>
inverse()
const
6012 return std::nullopt;
6019 [[nodiscard]]
constexpr bool valid()
const
6021 return matrix.determinant() !=
static_cast<Real
>(0);
6131 for (uint8_t c = 0; c < 2; ++c) {
6167 [[nodiscard]]
constexpr const Real&
at(
const uint8_t column,
const uint8_t row)
const
6170 return matrix[column][row];
6179 constexpr Real&
at(
const uint8_t column,
const uint8_t row)
6182 return matrix[column][row];
6242template <
typename Real>
6251 :
columns { {
static_cast<Real
>(1),
static_cast<Real
>(0),
static_cast<Real
>(0) },
6252 {
static_cast<Real
>(0),
static_cast<Real
>(1),
static_cast<Real
>(0) },
6253 {
static_cast<Real
>(0),
static_cast<Real
>(0),
static_cast<Real
>(1) } }
6262 template <
typename Other>
6265 static_cast<Real
>(matrix.
columns[0].y),
6266 static_cast<Real
>(matrix.
columns[0].z) },
6267 {
static_cast<Real
>(matrix.columns[1].x),
6268 static_cast<Real
>(matrix.columns[1].y),
6269 static_cast<Real
>(matrix.columns[1].z) },
6270 {
static_cast<Real
>(matrix.columns[2].x),
6271 static_cast<Real
>(matrix.columns[2].y),
6272 static_cast<Real
>(matrix.columns[2].z) } }
6283 :
columns { column0, column1, column2 }
6300 const Real col0_row0,
6301 const Real col0_row1,
6302 const Real col0_row2,
6303 const Real col1_row0,
6304 const Real col1_row1,
6305 const Real col1_row2,
6306 const Real col2_row0,
6307 const Real col2_row1,
6308 const Real col2_row2)
6309 :
columns { { col0_row0, col0_row1, col0_row2 },
6310 { col1_row0, col1_row1, col1_row2 },
6311 { col2_row0, col2_row1, col2_row2 } }
6322 return { { value, value, value }, { value, value, value }, { value, value, value } };
6331 return all(
static_cast<Real
>(0));
6340 return all(
static_cast<Real
>(1));
6349 return { {
static_cast<Real
>(1),
static_cast<Real
>(0),
static_cast<Real
>(0) },
6350 {
static_cast<Real
>(0),
static_cast<Real
>(1),
static_cast<Real
>(0) },
6351 {
static_cast<Real
>(0),
static_cast<Real
>(0),
static_cast<Real
>(1) } };
6358 [[nodiscard]]
constexpr Real
trace()
const
6360 return at(0, 0) +
at(1, 1) +
at(2, 2);
6369 Real det =
static_cast<Real
>(0);
6370 for (uint8_t c = 0; c < 3; ++c) {
6371 const Real det_minor =
minor_at(c, 0);
6372 det += (c % 2 == 0 ?
static_cast<Real
>(1) : -
static_cast<Real
>(1)) *
at(c, 0) * det_minor;
6386 uint8_t minor_col = 0;
6387 for (uint8_t c = 0; c < 3; ++c) {
6391 uint8_t minor_row = 0;
6392 for (uint8_t r = 0; r < 3; ++r) {
6396 minor_matrix[minor_col][minor_row] =
at(c, r);
6401 return minor_matrix;
6410 [[nodiscard]]
constexpr Real
minor_at(
const uint8_t column,
const uint8_t row)
const
6423 for (uint8_t c = 0; c < 3; ++c) {
6424 for (uint8_t r = 0; r < 3; ++r) {
6437 [[nodiscard]]
constexpr Real
cofactor_at(
const uint8_t column,
const uint8_t row)
const
6440 return ((column + row) % 2 == 0 ?
static_cast<Real
>(1) :
static_cast<Real
>(-1)) *
minor_at(column, row);
6450 for (uint8_t c = 0; c < 3; ++c) {
6451 for (uint8_t r = 0; r < 3; ++r) {
6464 return { {
at(0, 0),
at(1, 0),
at(2, 0) }, {
at(0, 1),
at(1, 1),
at(2, 1) }, {
at(0, 2),
at(1, 2),
at(2, 2) } };
6489 [[nodiscard]]
constexpr std::optional<Matrix3>
inverse()
const
6492 if (det ==
static_cast<Real
>(0)) {
6493 return std::nullopt;
6505 for (uint8_t c = 0; c < 3; ++c) {
6506 for (uint8_t r = 0; r < 3; ++r) {
6521 for (uint8_t c = 0; c < 3; ++c) {
6522 for (uint8_t r = 0; r < 3; ++r) {
6559 [[nodiscard]]
constexpr const Real&
at(
const uint8_t column,
const uint8_t row)
const
6571 constexpr Real&
at(
const uint8_t column,
const uint8_t row)
6590 [[nodiscard]]
const Real*
end()
const
6642 for (uint8_t i = 0; i < 3; ++i) {
6643 if (
at(i) != other.
at(i)) {
6657 for (uint8_t i = 0; i < 3; ++i) {
6658 if (
at(i) != other.
at(i)) {
6673 for (uint8_t c = 0; c < 3; ++c) {
6674 result.
at(c) =
at(c) + other.
at(c);
6686 for (uint8_t c = 0; c < 3; ++c) {
6687 at(c) += other.
at(c);
6700 for (uint8_t c = 0; c < 3; ++c) {
6701 result.
at(c) =
at(c) - other.
at(c);
6713 for (uint8_t c = 0; c < 3; ++c) {
6714 at(c) -= other.
at(c);
6726 auto result =
zero();
6727 for (uint8_t c = 0; c < 3; ++c) {
6728 for (uint8_t r = 0; r < 3; ++r) {
6729 for (uint8_t i = 0; i < 3; ++i) {
6730 result.at(c, r) +=
at(i, r) * other.
at(c, i);
6744 *
this = *
this * other;
6756 for (uint8_t r = 0; r < 3; ++r) {
6757 for (uint8_t c = 0; c < 3; ++c) {
6758 result.at(r) +=
at(c, r) * vector.
at(c);
6771 return {
at(0) * value,
at(1) * value,
at(2) * value };
6794 return {
at(0) / value,
at(1) / value,
at(2) / value };
6817 for (uint8_t i = 0; i < 3; ++i) {
6818 if (
at(i) < other.
at(i)) {
6821 if (
at(i) != other.
at(i)) {
6831 constexpr explicit operator bool()
const
6833 for (uint8_t c = 0; c < 3; ++c) {
6834 if (!
static_cast<bool>(
at(c))) {
6849template <
typename Real>
6853 for (uint8_t c = 0; c < 3; ++c) {
6854 for (uint8_t r = 0; r < 3; ++r) {
6855 result.
at(c, r) = value * matrix.
at(c, r);
6868template <
typename Real>
6872 for (uint8_t c = 0; c < 3; ++c) {
6873 for (uint8_t r = 0; r < 3; ++r) {
6874 result.
at(c, r) = value / matrix.
at(c, r);
6884template <
typename Real>
6902 template <
typename Other>
6926 for (uint8_t c = 0; c < 2; ++c) {
6927 for (uint8_t r = 0; r < 2; ++r) {
7000 [[nodiscard]]
constexpr Real
trace()
const
7011 return matrix.determinant();
7027 [[nodiscard]]
constexpr std::optional<Transform2>
inverse()
const
7032 return std::nullopt;
7039 [[nodiscard]]
constexpr bool valid()
const
7041 return basis().valid();
7050 return valid() &&
matrix.at(0, 2) ==
static_cast<Real
>(0) &&
matrix.at(1, 2) ==
static_cast<Real
>(0)
7051 &&
matrix.at(2, 2) ==
static_cast<Real
>(1);
7230 [[nodiscard]]
constexpr const Real&
at(
const uint8_t column,
const uint8_t row)
const
7233 return matrix.at(column, row);
7242 constexpr Real&
at(
const uint8_t column,
const uint8_t row)
7245 return matrix.at(column, row);
7305template <
typename Real>
7323 template <
typename Other>
7348 const Matrix3<Real> k_matrix { {
static_cast<Real
>(0), norm.
z, -norm.
y },
7349 { -norm.
z,
static_cast<Real
>(0), norm.
x },
7350 { norm.
y, -norm.
x,
static_cast<Real
>(0) } };
7352 + (
static_cast<Real
>(1) -
cos(angle)) * k_matrix * k_matrix;
7365 const Real one =
static_cast<Real
>(1);
7366 const Real two =
static_cast<Real
>(2);
7368 matrix.at(0, 1) = two * (q.
x * q.
y + q.
z * q.
w);
7369 matrix.at(0, 2) = two * (q.
x * q.
z - q.
y * q.
w);
7370 matrix.at(1, 0) = two * (q.
x * q.
y - q.
z * q.
w);
7371 matrix.at(1, 2) = two * (q.
y * q.
z + q.
x * q.
w);
7372 matrix.at(2, 0) = two * (q.
x * q.
z + q.
y * q.
w);
7374 matrix.at(2, 1) = two * (q.
y * q.
z - q.
x * q.
w);
7387 { { factor.
x,
static_cast<Real
>(0),
static_cast<Real
>(0) },
7388 {
static_cast<Real
>(0), factor.
y,
static_cast<Real
>(0) },
7389 {
static_cast<Real
>(0),
static_cast<Real
>(0), factor.
z } });
7401 { {
static_cast<Real
>(1), factor_y, factor_z },
7402 {
static_cast<Real
>(0),
static_cast<Real
>(1),
static_cast<Real
>(0) },
7403 {
static_cast<Real
>(0),
static_cast<Real
>(0),
static_cast<Real
>(1) } });
7415 { {
static_cast<Real
>(1),
static_cast<Real
>(0),
static_cast<Real
>(0) },
7416 { factor_x,
static_cast<Real
>(1), factor_z },
7417 {
static_cast<Real
>(0),
static_cast<Real
>(0),
static_cast<Real
>(1) } });
7429 { {
static_cast<Real
>(1),
static_cast<Real
>(0),
static_cast<Real
>(0) },
7430 {
static_cast<Real
>(0),
static_cast<Real
>(1),
static_cast<Real
>(0) },
7431 { factor_x, factor_y,
static_cast<Real
>(1) } });
7438 [[nodiscard]]
constexpr Real
trace()
const
7449 return matrix.determinant();
7465 [[nodiscard]]
constexpr std::optional<Basis3>
inverse()
const
7470 return std::nullopt;
7477 [[nodiscard]]
constexpr bool valid()
const
7479 return matrix.determinant() !=
static_cast<Real
>(0);
7550 [[nodiscard]]
constexpr Basis3 shear_x(
const Real factor_y,
const Real factor_z)
const
7572 [[nodiscard]]
constexpr Basis3 shear_y(
const Real factor_x,
const Real factor_z)
const
7594 [[nodiscard]]
constexpr Basis3 shear_z(
const Real factor_x,
const Real factor_y)
const
7648 return matrix.at(column);
7659 return matrix.at(column);
7668 [[nodiscard]]
constexpr const Real&
at(
const uint8_t column,
const uint8_t row)
const
7671 return matrix.at(column, row);
7680 constexpr Real&
at(
const uint8_t column,
const uint8_t row)
7683 return matrix.at(column, row);
7743template <
typename Real>
7755 :
columns { {
static_cast<Real
>(1),
static_cast<Real
>(0),
static_cast<Real
>(0),
static_cast<Real
>(0) },
7756 {
static_cast<Real
>(0),
static_cast<Real
>(1),
static_cast<Real
>(0),
static_cast<Real
>(0) },
7757 {
static_cast<Real
>(0),
static_cast<Real
>(0),
static_cast<Real
>(1),
static_cast<Real
>(0) },
7758 {
static_cast<Real
>(0),
static_cast<Real
>(0),
static_cast<Real
>(0),
static_cast<Real
>(1) } }
7768 template <
typename Other>
7771 static_cast<Real
>(matrix.
columns[0].y),
7772 static_cast<Real
>(matrix.
columns[0].z),
7773 static_cast<Real
>(matrix.
columns[0].w) },
7774 {
static_cast<Real
>(matrix.columns[1].x),
7775 static_cast<Real
>(matrix.columns[1].y),
7776 static_cast<Real
>(matrix.columns[1].z),
7777 static_cast<Real
>(matrix.columns[1].w) },
7778 {
static_cast<Real
>(matrix.columns[2].x),
7779 static_cast<Real
>(matrix.columns[2].y),
7780 static_cast<Real
>(matrix.columns[2].z),
7781 static_cast<Real
>(matrix.columns[2].w) },
7782 {
static_cast<Real
>(matrix.columns[3].x),
7783 static_cast<Real
>(matrix.columns[3].y),
7784 static_cast<Real
>(matrix.columns[3].z),
7785 static_cast<Real
>(matrix.columns[3].w) } }
7801 :
columns { column0, column1, column2, column3 }
7825 const Real col0_row0,
7826 const Real col0_row1,
7827 const Real col0_row2,
7828 const Real col0_row3,
7829 const Real col1_row0,
7830 const Real col1_row1,
7831 const Real col1_row2,
7832 const Real col1_row3,
7833 const Real col2_row0,
7834 const Real col2_row1,
7835 const Real col2_row2,
7836 const Real col2_row3,
7837 const Real col3_row0,
7838 const Real col3_row1,
7839 const Real col3_row2,
7840 const Real col3_row3)
7841 :
columns { { col0_row0, col0_row1, col0_row2, col0_row3 },
7842 { col1_row0, col1_row1, col1_row2, col1_row3 },
7843 { col2_row0, col2_row1, col2_row2, col2_row3 },
7844 { col3_row0, col3_row1, col3_row2, col3_row3 } }
7855 return { { value, value, value, value },
7856 { value, value, value, value },
7857 { value, value, value, value },
7858 { value, value, value, value } };
7867 return all(
static_cast<Real
>(0));
7876 return all(
static_cast<Real
>(1));
7885 return { {
static_cast<Real
>(1),
static_cast<Real
>(0),
static_cast<Real
>(0),
static_cast<Real
>(0) },
7886 {
static_cast<Real
>(0),
static_cast<Real
>(1),
static_cast<Real
>(0),
static_cast<Real
>(0) },
7887 {
static_cast<Real
>(0),
static_cast<Real
>(0),
static_cast<Real
>(1),
static_cast<Real
>(0) },
7888 {
static_cast<Real
>(0),
static_cast<Real
>(0),
static_cast<Real
>(0),
static_cast<Real
>(1) } };
7895 [[nodiscard]]
constexpr Real
trace()
const
7897 return at(0, 0) +
at(1, 1) +
at(2, 2) +
at(3, 3);
7906 Real det =
static_cast<Real
>(0);
7907 for (uint8_t c = 0; c < 4; ++c) {
7908 const Real det_minor =
minor_at(c, 0);
7909 det += (c % 2 == 0 ?
static_cast<Real
>(1) : -
static_cast<Real
>(1)) *
at(c, 0) * det_minor;
7924 uint8_t minor_col = 0;
7925 for (uint8_t c = 0; c < 4; ++c) {
7929 uint8_t minor_row = 0;
7930 for (uint8_t r = 0; r < 4; ++r) {
7934 minor_matrix[minor_col][minor_row] =
at(c, r);
7939 return minor_matrix;
7948 [[nodiscard]]
constexpr Real
minor_at(
const uint8_t column,
const uint8_t row)
const
7961 for (uint8_t c = 0; c < 4; ++c) {
7962 for (uint8_t r = 0; r < 4; ++r) {
7975 [[nodiscard]]
constexpr Real
cofactor_at(
const uint8_t column,
const uint8_t row)
const
7978 return ((column + row) % 2 == 0 ?
static_cast<Real
>(1) :
static_cast<Real
>(-1)) *
minor_at(column, row);
7988 for (uint8_t c = 0; c < 4; ++c) {
7989 for (uint8_t r = 0; r < 4; ++r) {
8002 return { {
at(0, 0),
at(1, 0),
at(2, 0),
at(3, 0) },
8003 {
at(0, 1),
at(1, 1),
at(2, 1),
at(3, 1) },
8004 {
at(0, 2),
at(1, 2),
at(2, 2),
at(3, 2) },
8005 {
at(0, 3),
at(1, 3),
at(2, 3),
at(3, 3) } };
8030 [[nodiscard]]
constexpr std::optional<Matrix4>
inverse()
const
8033 if (det ==
static_cast<Real
>(0)) {
8034 return std::nullopt;
8046 for (uint8_t c = 0; c < 4; ++c) {
8060 for (uint8_t c = 0; c < 4; ++c) {
8096 [[nodiscard]]
constexpr const Real&
at(
const uint8_t column,
const uint8_t row)
const
8108 constexpr Real&
at(
const uint8_t column,
const uint8_t row)
8127 [[nodiscard]]
const Real*
end()
const
8179 for (uint8_t i = 0; i < 4; ++i) {
8180 if (
at(i) != other.
at(i)) {
8194 for (uint8_t i = 0; i < 4; ++i) {
8195 if (
at(i) != other.
at(i)) {
8210 for (uint8_t c = 0; c < 4; ++c) {
8211 result.
at(c) =
at(c) + other.
at(c);
8223 for (uint8_t c = 0; c < 4; ++c) {
8224 at(c) += other.
at(c);
8237 for (uint8_t c = 0; c < 4; ++c) {
8238 result.
at(c) =
at(c) - other.
at(c);
8250 for (uint8_t c = 0; c < 4; ++c) {
8251 at(c) -= other.
at(c);
8263 auto result =
zero();
8264 for (uint8_t c = 0; c < 4; ++c) {
8265 for (uint8_t r = 0; r < 4; ++r) {
8266 for (uint8_t i = 0; i < 4; ++i) {
8267 result.at(c, r) +=
at(i, r) * other.
at(c, i);
8281 *
this = *
this * other;
8293 for (uint8_t r = 0; r < 4; ++r) {
8294 for (uint8_t c = 0; c < 4; ++c) {
8295 result.at(r) +=
at(c, r) * vector.
at(c);
8309 for (uint8_t c = 0; c < 4; ++c) {
8310 result.
at(c) =
at(c) * value;
8322 for (uint8_t c = 0; c < 4; ++c) {
8336 for (uint8_t c = 0; c < 4; ++c) {
8337 result.
at(c) =
at(c) / value;
8349 for (uint8_t c = 0; c < 4; ++c) {
8362 for (uint8_t i = 0; i < 4; ++i) {
8363 if (
at(i) < other.
at(i)) {
8366 if (
at(i) != other.
at(i)) {
8376 constexpr explicit operator bool()
const
8378 for (uint8_t c = 0; c < 4; ++c) {
8379 if (!
static_cast<bool>(
at(c))) {
8394template <
typename Real>
8398 for (uint8_t c = 0; c < 4; ++c) {
8399 for (uint8_t r = 0; r < 4; ++r) {
8400 result.
at(c, r) = value * matrix.
at(c, r);
8413template <
typename Real>
8417 for (uint8_t c = 0; c < 4; ++c) {
8418 for (uint8_t r = 0; r < 4; ++r) {
8419 result.
at(c, r) = value / matrix.
at(c, r);
8429template <
typename Real>
8450 template <
typename Other>
8474 for (uint8_t c = 0; c < 3; ++c) {
8475 for (uint8_t r = 0; r < 3; ++r) {
8580 const Real fov,
const Real aspect_ratio,
const Real near_clip,
const Real far_clip)
8583 const Real tan_half_fov =
tan(fov /
static_cast<Real
>(2));
8584 matrix.at(0, 0) =
static_cast<Real
>(1) / (aspect_ratio * tan_half_fov);
8585 matrix.at(1, 1) =
static_cast<Real
>(1) / tan_half_fov;
8586 matrix.at(2, 2) = -(far_clip + near_clip) / (far_clip - near_clip);
8587 matrix.at(2, 3) = -
static_cast<Real
>(1);
8588 matrix.at(3, 2) = -(
static_cast<Real
>(2) * far_clip * near_clip) / (far_clip - near_clip);
8601 const Real fov,
const Real aspect_ratio,
const Real near_clip,
const Real far_clip)
8604 const Real tan_half_fov =
tan(fov /
static_cast<Real
>(2));
8605 matrix.at(0, 0) =
static_cast<Real
>(1) / (aspect_ratio * tan_half_fov);
8606 matrix.at(1, 1) =
static_cast<Real
>(1) / tan_half_fov;
8607 matrix.at(2, 2) = -far_clip / (far_clip - near_clip);
8608 matrix.at(2, 3) = -
static_cast<Real
>(1);
8609 matrix.at(3, 2) = -(far_clip * near_clip) / (far_clip - near_clip);
8622 const Real fov,
const Real aspect_ratio,
const Real near_clip,
const Real far_clip)
8625 const Real tan_half_fov =
tan(fov /
static_cast<Real
>(2));
8626 matrix.at(0, 0) =
static_cast<Real
>(1) / (aspect_ratio * tan_half_fov);
8627 matrix.at(1, 1) =
static_cast<Real
>(1) / tan_half_fov;
8628 matrix.at(2, 2) = (far_clip + near_clip) / (far_clip - near_clip);
8629 matrix.at(2, 3) =
static_cast<Real
>(1);
8630 matrix.at(3, 2) = -(
static_cast<Real
>(2) * far_clip * near_clip) / (far_clip - near_clip);
8643 const Real fov,
const Real aspect_ratio,
const Real near_clip,
const Real far_clip)
8646 const Real tan_half_fov =
tan(fov /
static_cast<Real
>(2));
8647 matrix.at(0, 0) =
static_cast<Real
>(1) / (aspect_ratio * tan_half_fov);
8648 matrix.at(1, 1) =
static_cast<Real
>(1) / tan_half_fov;
8649 matrix.at(2, 2) = far_clip / (far_clip - near_clip);
8650 matrix.at(2, 3) =
static_cast<Real
>(1);
8651 matrix.at(3, 2) = -(far_clip * near_clip) / (far_clip - near_clip);
8666 const Real left,
const Real right,
const Real bottom,
const Real top,
const Real near_clip,
const Real far_clip)
8669 matrix.at(0, 0) =
static_cast<Real
>(2) / (right - left);
8670 matrix.at(1, 1) =
static_cast<Real
>(2) / (top - bottom);
8671 matrix.at(2, 2) = -
static_cast<Real
>(2) / (far_clip - near_clip);
8672 matrix.at(3, 0) = -(right + left) / (right - left);
8673 matrix.at(3, 1) = -(top + bottom) / (top - bottom);
8674 matrix.at(3, 2) = -(far_clip + near_clip) / (far_clip - near_clip);
8689 const Real left,
const Real right,
const Real bottom,
const Real top,
const Real near_clip,
const Real far_clip)
8692 matrix.at(0, 0) =
static_cast<Real
>(2) / (right - left);
8693 matrix.at(1, 1) =
static_cast<Real
>(2) / (top - bottom);
8694 matrix.at(2, 2) = -
static_cast<Real
>(1) / (far_clip - near_clip);
8695 matrix.at(3, 0) = -(right + left) / (right - left);
8696 matrix.at(3, 1) = -(top + bottom) / (top - bottom);
8697 matrix.at(3, 2) = -near_clip / (far_clip - near_clip);
8712 const Real left,
const Real right,
const Real bottom,
const Real top,
const Real near_clip,
const Real far_clip)
8715 matrix.at(0, 0) =
static_cast<Real
>(2) / (right - left);
8716 matrix.at(1, 1) =
static_cast<Real
>(2) / (top - bottom);
8717 matrix.at(2, 2) =
static_cast<Real
>(2) / (far_clip - near_clip);
8718 matrix.at(3, 0) = -(right + left) / (right - left);
8719 matrix.at(3, 1) = -(top + bottom) / (top - bottom);
8720 matrix.at(3, 2) = -(far_clip + near_clip) / (far_clip - near_clip);
8735 const Real left,
const Real right,
const Real bottom,
const Real top,
const Real near_clip,
const Real far_clip)
8738 matrix.at(0, 0) =
static_cast<Real
>(2) / (right - left);
8739 matrix.at(1, 1) =
static_cast<Real
>(2) / (top - bottom);
8740 matrix.at(2, 2) =
static_cast<Real
>(1) / (far_clip - near_clip);
8741 matrix.at(3, 0) = -(right + left) / (right - left);
8742 matrix.at(3, 1) = -(top + bottom) / (top - bottom);
8743 matrix.at(3, 2) = -near_clip / (far_clip - near_clip);
8751 [[nodiscard]]
constexpr Real
trace()
const
8762 return matrix.determinant();
8778 [[nodiscard]]
constexpr std::optional<Transform3>
inverse()
const
8783 return std::nullopt;
8790 [[nodiscard]]
constexpr bool valid()
const
8792 return basis().valid();
8801 return valid() &&
matrix.at(0, 3) ==
static_cast<Real
>(0) &&
matrix.at(1, 3) ==
static_cast<Real
>(0)
8802 &&
matrix.at(2, 3) ==
static_cast<Real
>(0) &&
matrix.at(3, 3) ==
static_cast<Real
>(1);
9009 return matrix.at(column);
9020 return matrix.at(column);
9029 [[nodiscard]]
constexpr const Real&
at(
const uint8_t column,
const uint8_t row)
const
9032 return matrix.at(column, row);
9041 constexpr Real&
at(
const uint8_t column,
const uint8_t row)
9044 return matrix.at(column, row);
9100template <
typename Real>
9101template <
typename Int>
9103 :
x { static_cast<Real>(vector.
x) }
9104 ,
y { static_cast<Real>(vector.
y) }
9108template <
typename Real>
9112 for (uint8_t c = 0; c < 2; ++c) {
9113 for (uint8_t r = 0; r < 2; ++r) {
9114 result.
at(c, r) =
at(c) * other.
at(r);
9120template <
typename Real>
9126template <
typename Real>
9132template <
typename Real>
9138template <
typename Real>
9144template <
typename Real>
9150template <
typename Real>
9156template <
typename Real>
9162template <
typename Real>
9168template <
typename Real>
9174template <
typename Real>
9177 return by.
matrix * *
this;
9180template <
typename Real>
9183 return (*
this - origin).
transform(by) + origin;
9186template <
typename Real>
9192template <
typename Real>
9195 return (*
this - origin).
transform(by, z) + origin;
9198template <
typename Real>
9202 result.
x =
x * matrix.
at(0, 0) +
y * matrix.
at(0, 1);
9203 result.
y =
x * matrix.
at(1, 0) +
y * matrix.
at(1, 1);
9207template <
typename Real>
9208template <
typename Int>
9210 :
x { static_cast<Real>(vector.
x) }
9211 ,
y { static_cast<Real>(vector.
y) }
9212 ,
z { static_cast<Real>(vector.
z) }
9216template <
typename Real>
9220 for (uint8_t c = 0; c < 3; ++c) {
9221 for (uint8_t r = 0; r < 3; ++r) {
9222 result.
at(c, r) =
at(c) * other.
at(r);
9228template <
typename Real>
9234template <
typename Real>
9240template <
typename Real>
9246template <
typename Real>
9252template <
typename Real>
9259template <
typename Real>
9265template <
typename Real>
9271template <
typename Real>
9277template <
typename Real>
9283template <
typename Real>
9289template <
typename Real>
9295template <
typename Real>
9301template <
typename Real>
9307template <
typename Real>
9310 return by.
matrix * *
this;
9313template <
typename Real>
9316 return (*
this - origin).
transform(by) + origin;
9319template <
typename Real>
9322 return by.
matrix * *
this;
9325template <
typename Real>
9328 return (*
this -
Vector3 { origin,
static_cast<Real
>(0) }).
transform(by) +
Vector3 { origin,
static_cast<Real
>(0) };
9331template <
typename Real>
9337template <
typename Real>
9340 return (*
this - origin).
transform(by, w) + origin;
9343template <
typename Real>
9346 auto result =
zero();
9347 for (uint8_t c = 0; c < 3; ++c) {
9348 for (uint8_t r = 0; r < 3; ++r) {
9349 result.at(c) +=
at(r) * matrix.
at(c, r);
9355template <
typename Real>
9358 return { quaternion.
x, quaternion.
y, quaternion.
z, quaternion.
w };
9361template <
typename Real>
9365 for (uint8_t c = 0; c < 4; ++c) {
9366 for (uint8_t r = 0; r < 4; ++r) {
9367 result.
at(c, r) =
at(c) * other.
at(r);
9373template <
typename Real>
9376 return by.
matrix * *
this;
9379template <
typename Real>
9382 return (*
this -
Vector4 { origin,
static_cast<Real
>(0) }).
transform(by) +
Vector4 { origin,
static_cast<Real
>(0) };
9385template <
typename Real>
9388 auto result =
zero();
9389 for (uint8_t c = 0; c < 4; ++c) {
9390 for (uint8_t r = 0; r < 4; ++r) {
9391 result.at(c) +=
at(r) * matrix.
at(c, r);
constexpr Real determinant() const
Definition nnm.hpp:5989
constexpr Basis2 scale(const Vector2< Real > &factor) const
Definition nnm.hpp:6049
constexpr Basis2(const Matrix2< Real > &matrix)
Definition nnm.hpp:5931
constexpr Basis2 shear_y_local(const Real factor) const
Definition nnm.hpp:6099
Matrix2< float > matrix
Definition nnm.hpp:5906
constexpr Basis2()
Definition nnm.hpp:5911
static constexpr Basis2 from_scale(const Vector2< Real > &factor)
Definition nnm.hpp:5951
constexpr Vector2< Real > & operator[](const uint8_t index)
Definition nnm.hpp:6201
constexpr Real trace() const
Definition nnm.hpp:5980
constexpr Basis2 shear_x_local(const Real factor) const
Definition nnm.hpp:6079
constexpr Real & at(const uint8_t column, const uint8_t row)
Definition nnm.hpp:6179
Basis2 rotate_local(const Real angle) const
Definition nnm.hpp:6039
static constexpr Basis2 from_shear_x(const Real factor)
Definition nnm.hpp:5961
Basis2 rotate(const Real angle) const
Definition nnm.hpp:6029
constexpr Basis2(const Basis2< Other > &basis)
Definition nnm.hpp:5922
constexpr const Real & at(const uint8_t column, const uint8_t row) const
Definition nnm.hpp:6167
static constexpr Basis2 from_shear_y(const Real factor)
Definition nnm.hpp:5971
constexpr bool operator!=(const Basis2 &other) const
Definition nnm.hpp:6222
constexpr Basis2 transform_local(const Basis2 &by) const
Definition nnm.hpp:6119
constexpr Basis2 shear_x(const Real factor) const
Definition nnm.hpp:6069
constexpr Basis2 shear_y(const Real factor) const
Definition nnm.hpp:6089
constexpr bool valid() const
Definition nnm.hpp:6019
constexpr bool operator<(const Basis2 &other) const
Definition nnm.hpp:6232
constexpr bool operator==(const Basis2 &other) const
Definition nnm.hpp:6212
constexpr bool approx_equal(const Basis2 &other) const
Definition nnm.hpp:6129
constexpr std::optional< Basis2 > inverse() const
Definition nnm.hpp:6007
constexpr Basis2 transform(const Basis2 &by) const
Definition nnm.hpp:6109
constexpr const Vector2< float > & at(const uint8_t column) const
Definition nnm.hpp:6144
constexpr Basis2 unchecked_inverse() const
Definition nnm.hpp:5998
constexpr Vector2< Real > & at(const uint8_t column)
Definition nnm.hpp:6155
static Basis2 from_rotation(const Real angle)
Definition nnm.hpp:5941
constexpr const Vector2< Real > & operator[](const uint8_t index) const
Definition nnm.hpp:6190
constexpr Basis2 scale_local(const Vector2< Real > &factor) const
Definition nnm.hpp:6059
constexpr Real trace() const
Definition nnm.hpp:7438
constexpr Basis3 shear_x(const Real factor_y, const Real factor_z) const
Definition nnm.hpp:7550
constexpr Basis3 rotate_quaternion(const Quaternion< Real > &quaternion) const
Definition nnm.hpp:7509
constexpr bool operator==(const Basis3 &other) const
Definition nnm.hpp:7713
static Basis3 from_rotation_axis_angle(const Vector3< Real > &axis, const Real angle)
Definition nnm.hpp:7344
constexpr Basis3 unchecked_inverse() const
Definition nnm.hpp:7456
Basis3 rotate_axis_angle_local(const Vector3< Real > &axis, const Real angle) const
Definition nnm.hpp:7499
constexpr const Vector3< Real > & at(const uint8_t column) const
Definition nnm.hpp:7645
constexpr bool approx_equal(const Basis3 &other) const
Definition nnm.hpp:7635
constexpr Basis3 shear_z(const Real factor_x, const Real factor_y) const
Definition nnm.hpp:7594
constexpr const Real & at(const uint8_t column, const uint8_t row) const
Definition nnm.hpp:7668
constexpr Basis3(const Basis3< Other > &basis)
Definition nnm.hpp:7324
constexpr Basis3 shear_z_local(const Real factor_x, const Real factor_y) const
Definition nnm.hpp:7605
Basis3 rotate_axis_angle(const Vector3< Real > &axis, const Real angle) const
Definition nnm.hpp:7488
constexpr Basis3()
Definition nnm.hpp:7313
constexpr Basis3 transform_local(const Basis3 &by) const
Definition nnm.hpp:7625
static constexpr Basis3 from_scale(const Vector3< Real > &factor)
Definition nnm.hpp:7384
constexpr Basis3(const Matrix3< Real > &matrix)
Definition nnm.hpp:7333
static constexpr Basis3 from_shear_x(const Real factor_y, const Real factor_z)
Definition nnm.hpp:7398
constexpr Basis3 shear_y(const Real factor_x, const Real factor_z) const
Definition nnm.hpp:7572
constexpr Real & at(const uint8_t column, const uint8_t row)
Definition nnm.hpp:7680
constexpr bool valid() const
Definition nnm.hpp:7477
constexpr bool operator<(const Basis3 &other) const
Definition nnm.hpp:7733
constexpr Basis3 scale(const Vector3< Real > &factor) const
Definition nnm.hpp:7529
constexpr std::optional< Basis3 > inverse() const
Definition nnm.hpp:7465
constexpr Vector3< Real > & at(const uint8_t column)
Definition nnm.hpp:7656
constexpr bool operator!=(const Basis3 &other) const
Definition nnm.hpp:7723
Matrix3< float > matrix
Definition nnm.hpp:7308
static constexpr Basis3 from_shear_z(const Real factor_x, const Real factor_y)
Definition nnm.hpp:7426
constexpr Basis3 shear_x_local(const Real factor_y, const Real factor_z) const
Definition nnm.hpp:7561
constexpr Basis3 scale_local(const Vector3< Real > &factor) const
Definition nnm.hpp:7539
constexpr Basis3 shear_y_local(const Real factor_x, const Real factor_z) const
Definition nnm.hpp:7583
static constexpr Basis3 from_shear_y(const Real factor_x, const Real factor_z)
Definition nnm.hpp:7412
constexpr Basis3 rotate_quaternion_local(const Quaternion< Real > &quaternion) const
Definition nnm.hpp:7519
static constexpr Basis3 from_rotation_quaternion(const Quaternion< Real > &quaternion)
Definition nnm.hpp:7361
constexpr const Vector3< Real > & operator[](const uint8_t index) const
Definition nnm.hpp:7691
constexpr Basis3 transform(const Basis3 &by) const
Definition nnm.hpp:7615
constexpr Real determinant() const
Definition nnm.hpp:7447
constexpr Vector3< Real > & operator[](const uint8_t index)
Definition nnm.hpp:7702
constexpr Vector2< Real > operator*(const Vector2< Real > &vector) const
Definition nnm.hpp:5774
constexpr bool operator!=(const Matrix2 &other) const
Definition nnm.hpp:5676
constexpr Matrix2 transpose() const
Definition nnm.hpp:5483
constexpr std::optional< Matrix2 > inverse() const
Definition nnm.hpp:5510
constexpr Matrix2 unchecked_inverse() const
Definition nnm.hpp:5501
static constexpr Matrix2 one()
Definition nnm.hpp:5397
constexpr Real determinant() const
Definition nnm.hpp:5424
constexpr Matrix2 operator-(const Matrix2 &other) const
Definition nnm.hpp:5718
constexpr bool approx_equal(const Matrix2 &other) const
Definition nnm.hpp:5524
constexpr Matrix2 operator/(const Real value) const
Definition nnm.hpp:5810
constexpr Matrix2(const Real col0_row0, const Real col0_row1, const Real col1_row0, const Real col1_row1)
Definition nnm.hpp:5369
constexpr const Vector2< Real > & operator[](const uint8_t column) const
Definition nnm.hpp:5639
constexpr Vector2< Real > & at(const uint8_t column)
Definition nnm.hpp:5568
static constexpr Matrix2 all(const Real value)
Definition nnm.hpp:5379
Vector2< float > columns[2]
Definition nnm.hpp:5330
constexpr Matrix2 cofactor() const
Definition nnm.hpp:5474
constexpr Vector2< Real > & operator[](const uint8_t column)
Definition nnm.hpp:5650
constexpr Real minor_at(const uint8_t column, const uint8_t row) const
Definition nnm.hpp:5435
constexpr Matrix2 & operator/=(const Real value)
Definition nnm.hpp:5820
constexpr Real & at(const uint8_t column, const uint8_t row)
Definition nnm.hpp:5592
constexpr Matrix2 & operator-=(const Matrix2 &other)
Definition nnm.hpp:5732
const Real * begin() const
Definition nnm.hpp:5602
static constexpr Matrix2 identity()
Definition nnm.hpp:5406
Real * end()
Definition nnm.hpp:5629
constexpr Matrix2(const Matrix2< Other > &matrix)
Definition nnm.hpp:5346
constexpr const Real & at(const uint8_t column, const uint8_t row) const
Definition nnm.hpp:5580
constexpr Matrix2 & operator+=(const Matrix2 &other)
Definition nnm.hpp:5705
const Real * end() const
Definition nnm.hpp:5611
constexpr bool operator==(const Matrix2 &other) const
Definition nnm.hpp:5661
constexpr Matrix2()
Definition nnm.hpp:5335
constexpr Matrix2 & operator*=(const Real value)
Definition nnm.hpp:5798
Real * begin()
Definition nnm.hpp:5620
static constexpr Matrix2 zero()
Definition nnm.hpp:5388
constexpr Matrix2 operator+(const Matrix2 &other) const
Definition nnm.hpp:5691
constexpr bool approx_zero() const
Definition nnm.hpp:5540
constexpr Matrix2 minor() const
Definition nnm.hpp:5447
constexpr Matrix2 adjugate() const
Definition nnm.hpp:5492
constexpr Matrix2 operator*(const Real value) const
Definition nnm.hpp:5788
constexpr Matrix2 operator*(const Matrix2 &other) const
Definition nnm.hpp:5745
constexpr Matrix2 & operator*=(const Matrix2 &other)
Definition nnm.hpp:5763
constexpr const Vector2< float > & at(const uint8_t column) const
Definition nnm.hpp:5557
constexpr Real trace() const
Definition nnm.hpp:5415
constexpr bool operator<(const Matrix2 &other) const
Definition nnm.hpp:5832
constexpr Real cofactor_at(const uint8_t column, const uint8_t row) const
Definition nnm.hpp:5464
constexpr Matrix2(const Vector2< Real > &column0, const Vector2< Real > &column1)
Definition nnm.hpp:5357
constexpr Matrix3 operator-(const Matrix3 &other) const
Definition nnm.hpp:6697
constexpr float minor_at(const uint8_t column, const uint8_t row) const
Definition nnm.hpp:6410
Real * begin()
Definition nnm.hpp:6599
constexpr std::optional< Matrix3 > inverse() const
Definition nnm.hpp:6489
static constexpr Matrix3 all(const Real value)
Definition nnm.hpp:6320
constexpr Matrix3 & operator*=(const Matrix3 &other)
Definition nnm.hpp:6742
constexpr const Real & at(const uint8_t column, const uint8_t row) const
Definition nnm.hpp:6559
constexpr Matrix3 transpose() const
Definition nnm.hpp:6462
constexpr Vector3< Real > & at(const uint8_t column)
Definition nnm.hpp:6547
constexpr Real determinant() const
Definition nnm.hpp:6367
constexpr bool operator<(const Matrix3 &other) const
Definition nnm.hpp:6815
constexpr Matrix3 operator*(const Matrix3 &other) const
Definition nnm.hpp:6724
constexpr Matrix3 & operator/=(const Real value)
Definition nnm.hpp:6802
constexpr Matrix3 operator/(const Real value) const
Definition nnm.hpp:6792
constexpr Real trace() const
Definition nnm.hpp:6358
Real * end()
Definition nnm.hpp:6608
constexpr Matrix3(const Matrix3< Other > &matrix)
Definition nnm.hpp:6263
constexpr Matrix3(const Real col0_row0, const Real col0_row1, const Real col0_row2, const Real col1_row0, const Real col1_row1, const Real col1_row2, const Real col2_row0, const Real col2_row1, const Real col2_row2)
Definition nnm.hpp:6299
constexpr Matrix3 & operator+=(const Matrix3 &other)
Definition nnm.hpp:6684
Vector3< float > columns[3]
Definition nnm.hpp:6245
constexpr Matrix3 & operator-=(const Matrix3 &other)
Definition nnm.hpp:6711
constexpr bool operator==(const Matrix3 &other) const
Definition nnm.hpp:6640
constexpr Matrix3 adjugate() const
Definition nnm.hpp:6471
constexpr const Vector3< Real > & operator[](const uint8_t column) const
Definition nnm.hpp:6618
constexpr Matrix3 minor() const
Definition nnm.hpp:6420
constexpr const Vector3< float > & at(const uint8_t column) const
Definition nnm.hpp:6536
const Real * end() const
Definition nnm.hpp:6590
constexpr Matrix3 operator*(const Real value) const
Definition nnm.hpp:6769
constexpr Matrix3 & operator*=(const Real value)
Definition nnm.hpp:6779
constexpr Matrix3 operator+(const Matrix3 &other) const
Definition nnm.hpp:6670
constexpr Real cofactor_at(const uint8_t column, const uint8_t row) const
Definition nnm.hpp:6437
constexpr bool approx_equal(const Matrix3 &other) const
Definition nnm.hpp:6503
constexpr Vector3< Real > operator*(const Vector3< Real > &vector) const
Definition nnm.hpp:6753
constexpr bool approx_zero() const
Definition nnm.hpp:6519
static constexpr Matrix3 identity()
Definition nnm.hpp:6347
const Real * begin() const
Definition nnm.hpp:6581
constexpr Matrix3 unchecked_inverse() const
Definition nnm.hpp:6480
constexpr Matrix3 cofactor() const
Definition nnm.hpp:6447
constexpr Matrix3(const Vector3< Real > &column0, const Vector3< Real > &column1, const Vector3< Real > &column2)
Definition nnm.hpp:6282
static constexpr Matrix3 zero()
Definition nnm.hpp:6329
constexpr Vector3< Real > & operator[](const uint8_t column)
Definition nnm.hpp:6629
constexpr Real & at(const uint8_t column, const uint8_t row)
Definition nnm.hpp:6571
constexpr Matrix3()
Definition nnm.hpp:6250
static constexpr Matrix3 one()
Definition nnm.hpp:6338
constexpr bool operator!=(const Matrix3 &other) const
Definition nnm.hpp:6655
constexpr Matrix2< Real > minor_matrix_at(const uint8_t column, const uint8_t row) const
Definition nnm.hpp:6383
static constexpr Matrix4 all(const Real value)
Definition nnm.hpp:7853
constexpr const Real & at(const uint8_t column, const uint8_t row) const
Definition nnm.hpp:8096
constexpr bool approx_equal(const Matrix4 &other) const
Definition nnm.hpp:8044
static constexpr Matrix4 one()
Definition nnm.hpp:7874
constexpr Vector4< Real > & operator[](const uint8_t index)
Definition nnm.hpp:8166
constexpr const Vector4< float > & at(const uint8_t column) const
Definition nnm.hpp:8073
constexpr Matrix4 adjugate() const
Definition nnm.hpp:8012
constexpr Matrix4 operator/(const Real value) const
Definition nnm.hpp:8333
const Real * end() const
Definition nnm.hpp:8127
constexpr Matrix3< Real > minor_matrix_at(const uint8_t column, const uint8_t row) const
Definition nnm.hpp:7920
constexpr Matrix4()
Definition nnm.hpp:7754
constexpr Matrix4 & operator*=(const Real value)
Definition nnm.hpp:8320
constexpr const Vector4< Real > & operator[](const uint8_t index) const
Definition nnm.hpp:8155
constexpr Matrix4 operator*(const Matrix4 &other) const
Definition nnm.hpp:8261
constexpr Matrix4(const Matrix4< Other > &matrix)
Definition nnm.hpp:7769
constexpr Matrix4 operator-(const Matrix4 &other) const
Definition nnm.hpp:8234
Real * end()
Definition nnm.hpp:8145
const Real * begin() const
Definition nnm.hpp:8118
constexpr Real cofactor_at(const uint8_t column, const uint8_t row) const
Definition nnm.hpp:7975
constexpr bool operator==(const Matrix4 &other) const
Definition nnm.hpp:8177
constexpr Matrix4(const Vector4< Real > &column0, const Vector4< Real > &column1, const Vector4< Real > &column2, const Vector4< Real > &column3)
Definition nnm.hpp:7796
constexpr bool operator<(const Matrix4 &other) const
Definition nnm.hpp:8360
Vector4< float > columns[4]
Definition nnm.hpp:7749
constexpr Matrix4(const Real col0_row0, const Real col0_row1, const Real col0_row2, const Real col0_row3, const Real col1_row0, const Real col1_row1, const Real col1_row2, const Real col1_row3, const Real col2_row0, const Real col2_row1, const Real col2_row2, const Real col2_row3, const Real col3_row0, const Real col3_row1, const Real col3_row2, const Real col3_row3)
Definition nnm.hpp:7824
constexpr Real trace() const
Definition nnm.hpp:7895
constexpr Matrix4 cofactor() const
Definition nnm.hpp:7985
constexpr Vector4< Real > & at(const uint8_t column)
Definition nnm.hpp:8084
constexpr Matrix4 unchecked_inverse() const
Definition nnm.hpp:8021
constexpr Matrix4 transpose() const
Definition nnm.hpp:8000
constexpr Matrix4 & operator+=(const Matrix4 &other)
Definition nnm.hpp:8221
constexpr Matrix4 operator+(const Matrix4 &other) const
Definition nnm.hpp:8207
constexpr Matrix4 minor() const
Definition nnm.hpp:7958
constexpr float minor_at(const uint8_t column, const uint8_t row) const
Definition nnm.hpp:7948
constexpr std::optional< Matrix4 > inverse() const
Definition nnm.hpp:8030
Real * begin()
Definition nnm.hpp:8136
constexpr bool operator!=(const Matrix4 &other) const
Definition nnm.hpp:8192
constexpr Real & at(const uint8_t column, const uint8_t row)
Definition nnm.hpp:8108
constexpr Matrix4 operator*(const Real value) const
Definition nnm.hpp:8306
static constexpr Matrix4 identity()
Definition nnm.hpp:7883
constexpr Matrix4 & operator*=(const Matrix4 &other)
Definition nnm.hpp:8279
constexpr Vector4< Real > operator*(const Vector4< Real > &vector) const
Definition nnm.hpp:8290
static constexpr Matrix4 zero()
Definition nnm.hpp:7865
constexpr Matrix4 & operator/=(const Real value)
Definition nnm.hpp:8347
constexpr Matrix4 & operator-=(const Matrix4 &other)
Definition nnm.hpp:8248
constexpr Real determinant() const
Definition nnm.hpp:7904
constexpr bool approx_zero() const
Definition nnm.hpp:8058
float w
Definition nnm.hpp:4935
static constexpr Quaternion identity()
Definition nnm.hpp:4993
constexpr Quaternion(const Quaternion< Other > &quaternion)
Definition nnm.hpp:4954
constexpr Real length_sqrd() const
Definition nnm.hpp:5103
constexpr Quaternion & operator*=(const Quaternion &other)
Definition nnm.hpp:5297
constexpr bool operator==(const Quaternion &other) const
Definition nnm.hpp:5262
float angle() const
Definition nnm.hpp:5085
Real angle_to(const Quaternion &to) const
Definition nnm.hpp:5061
static Quaternion from_axis_angle(const Vector3< Real > &axis, const Real angle)
Definition nnm.hpp:5004
constexpr Quaternion operator*(const Quaternion &other) const
Definition nnm.hpp:5282
float x
Definition nnm.hpp:4932
constexpr bool approx_equal(const Quaternion &other) const
Definition nnm.hpp:5163
Vector3< Real > axis_to(const Quaternion &to) const
Definition nnm.hpp:5046
float z
Definition nnm.hpp:4934
constexpr Quaternion rotate_quaternion(const Quaternion &by) const
Definition nnm.hpp:5153
constexpr Quaternion(const Vector4< Real > &vector)
Definition nnm.hpp:4966
Vector3< float > axis() const
Definition nnm.hpp:5072
constexpr Real & at(const uint8_t index)
Definition nnm.hpp:5196
constexpr Quaternion inverse() const
Definition nnm.hpp:5094
constexpr bool operator!=(const Quaternion &other) const
Definition nnm.hpp:5272
Real length() const
Definition nnm.hpp:5112
constexpr bool operator<(const Quaternion &other) const
Definition nnm.hpp:5308
constexpr Real & operator[](const uint8_t index)
Definition nnm.hpp:5240
Quaternion normalize() const
Definition nnm.hpp:5036
Quaternion slerp(const Quaternion &to, const Real weight) const
Definition nnm.hpp:5123
float y
Definition nnm.hpp:4933
constexpr Quaternion(const Real x, const Real y, const Real z, const Real w)
Definition nnm.hpp:4981
constexpr const Real & operator[](const uint8_t index) const
Definition nnm.hpp:5218
Quaternion rotate_axis_angle(const Vector3< Real > &axis, const Real angle) const
Definition nnm.hpp:5143
static Quaternion from_vector_to_vector(const Vector3< Real > &from, const Vector3< Real > &to)
Definition nnm.hpp:5022
constexpr const Real & at(const uint8_t index) const
Definition nnm.hpp:5174
constexpr Quaternion()
Definition nnm.hpp:4940
constexpr Real aspect_ratio() const
Definition nnm.hpp:820
Vector2 ceil() const
Definition nnm.hpp:793
constexpr bool operator==(const Vector2 &other) const
Definition nnm.hpp:1400
constexpr Vector2 operator/(const Real value) const
Definition nnm.hpp:1537
constexpr Vector2 transform_at(const Vector2 &origin, const Basis2< Real > &by) const
Definition nnm.hpp:9181
float y
Definition nnm.hpp:692
constexpr uint8_t min_index() const
Definition nnm.hpp:1248
constexpr bool perpendicular(const Vector2 &other) const
Definition nnm.hpp:1069
constexpr bool approx_zero() const
Definition nnm.hpp:1282
constexpr Vector2 shear_y(Real factor) const
Definition nnm.hpp:9163
constexpr Vector2 & operator-=(const Vector2 &other)
Definition nnm.hpp:1452
constexpr Vector2(const Vector2i< Int > &vector)
Definition nnm.hpp:9102
constexpr Real & at(const uint8_t index)
Definition nnm.hpp:1346
static constexpr Vector2 axis_y()
Definition nnm.hpp:775
Vector2 rotate(Real angle) const
Definition nnm.hpp:9127
Vector2 normalize() const
Definition nnm.hpp:933
constexpr float min() const
Definition nnm.hpp:1206
constexpr uint8_t max_index() const
Definition nnm.hpp:1224
constexpr Real cross(const Vector2 &other) const
Definition nnm.hpp:978
constexpr Vector2 abs() const
Definition nnm.hpp:784
constexpr Real abs_max() const
Definition nnm.hpp:1197
constexpr uint8_t abs_min_index() const
Definition nnm.hpp:1260
constexpr Vector2 operator+() const
Definition nnm.hpp:1558
const Real * begin() const
Definition nnm.hpp:1291
constexpr Vector2 & operator/=(const Real value)
Definition nnm.hpp:1547
constexpr uint8_t abs_max_index() const
Definition nnm.hpp:1236
constexpr Vector2 project(const Vector2 &onto) const
Definition nnm.hpp:1009
constexpr Real & operator[](const uint8_t index)
Definition nnm.hpp:1382
constexpr Vector2()
Definition nnm.hpp:697
constexpr Vector2(const Vector2< Other > &vector)
Definition nnm.hpp:717
constexpr const Real & operator[](const uint8_t index) const
Definition nnm.hpp:1364
constexpr Vector2 lerp_clamped(const Vector2 &to, const Real weight) const
Definition nnm.hpp:958
static constexpr Vector2 all(const Real value)
Definition nnm.hpp:739
constexpr Vector2 & operator*=(const Real value)
Definition nnm.hpp:1503
Real angle_to(const Vector2 &to) const
Definition nnm.hpp:1049
constexpr Vector2 operator-() const
Definition nnm.hpp:1567
constexpr Real length_sqrd() const
Definition nnm.hpp:892
constexpr Matrix2< Real > outer(const Vector2 &other) const
Definition nnm.hpp:9109
constexpr Vector2(const Real x, const Real y)
Definition nnm.hpp:728
Vector2 direction(const Vector2 &to) const
Definition nnm.hpp:841
constexpr Vector2 & operator+=(const Vector2 &other)
Definition nnm.hpp:1430
constexpr Vector2 shear_x(Real factor) const
Definition nnm.hpp:9151
constexpr Real dot(const Vector2 &other) const
Definition nnm.hpp:968
Real angle_between(const Vector2 &other) const
Definition nnm.hpp:1033
constexpr Vector2 lerp(const Vector2 &to, const Real weight) const
Definition nnm.hpp:947
constexpr Vector2 operator*(const Real value) const
Definition nnm.hpp:1493
Real distance(const Vector2 &to) const
Definition nnm.hpp:873
constexpr Vector2 clamp(const Vector2 &min, const Vector2 &max) const
Definition nnm.hpp:831
constexpr Vector2 operator+(const Vector2 &other) const
Definition nnm.hpp:1420
constexpr Real manhattan_distance(const Vector2 &to) const
Definition nnm.hpp:883
static constexpr Vector2 axis_x()
Definition nnm.hpp:766
float x
Definition nnm.hpp:691
constexpr Vector2 & operator*=(const Vector2 &other)
Definition nnm.hpp:1474
constexpr bool approx_equal(const Vector2 &other) const
Definition nnm.hpp:1273
constexpr const Real & at(const uint8_t index) const
Definition nnm.hpp:1328
constexpr Vector2 reflect(const Vector2 &normal) const
Definition nnm.hpp:995
constexpr Vector2 operator*(const Vector2 &other) const
Definition nnm.hpp:1464
constexpr bool operator!=(const Vector2 &other) const
Definition nnm.hpp:1410
constexpr Vector2 inverse() const
Definition nnm.hpp:1023
Vector2 round() const
Definition nnm.hpp:811
Real * end()
Definition nnm.hpp:1318
constexpr Vector2 shear_y_at(const Vector2 &origin, Real factor) const
Definition nnm.hpp:9169
constexpr Vector2 scale_at(const Vector2 &origin, const Vector2 &factor) const
Definition nnm.hpp:9145
constexpr bool operator<(const Vector2 &other) const
Definition nnm.hpp:1577
constexpr Vector2 operator/(const Vector2 &other) const
Definition nnm.hpp:1515
Vector2 floor() const
Definition nnm.hpp:802
static constexpr Vector2 zero()
Definition nnm.hpp:748
static constexpr Vector2 one()
Definition nnm.hpp:757
constexpr float max() const
Definition nnm.hpp:1188
constexpr Vector2 & operator/=(const Vector2 &other)
Definition nnm.hpp:1525
constexpr Vector2 shear_x_at(const Vector2 &origin, Real factor) const
Definition nnm.hpp:9157
Vector2 clamp_length(const Real min, const Real max) const
Definition nnm.hpp:913
constexpr Real abs_min() const
Definition nnm.hpp:1215
constexpr Vector2 transform(const Basis2< Real > &by) const
Definition nnm.hpp:9175
constexpr Vector2 scale(const Vector2 &factor) const
constexpr Vector2 transform_at(const Vector2 &origin, const Transform2< Real > &by, Real z=static_cast< Real >(1)) const
Definition nnm.hpp:9193
Real length() const
Definition nnm.hpp:901
constexpr Real distance_sqrd(const Vector2 &to) const
Definition nnm.hpp:861
constexpr Vector2 translate(const Vector2 &by) const
Definition nnm.hpp:9121
constexpr Vector2 transform(const Transform2< Real > &by, Real z=static_cast< Real >(1)) const
Definition nnm.hpp:9187
Real * begin()
Definition nnm.hpp:1309
Vector2 rotate_at(const Vector2 &origin, Real angle) const
Definition nnm.hpp:9133
constexpr bool parallel(const Vector2 &other) const
Definition nnm.hpp:1059
constexpr Vector2 arbitrary_perpendicular() const
Definition nnm.hpp:1079
const Real * end() const
Definition nnm.hpp:1300
constexpr Vector2 operator*(const Matrix2< Real > &matrix) const
Definition nnm.hpp:9199
constexpr Vector2 direction_unnormalized(const Vector2 &to) const
Definition nnm.hpp:851
constexpr Vector2 operator-(const Vector2 &other) const
Definition nnm.hpp:1442
constexpr uint8_t abs_min_index() const
Definition nnm.hpp:1876
constexpr uint8_t abs_max_index() const
Definition nnm.hpp:1852
int x
Definition nnm.hpp:1630
constexpr Int abs_max() const
Definition nnm.hpp:1813
constexpr Int & operator[](const uint8_t index)
Definition nnm.hpp:1979
constexpr Vector2i & operator-=(const Vector2i &other)
Definition nnm.hpp:2049
constexpr Int manhattan_distance(const Vector2i &to) const
Definition nnm.hpp:1736
constexpr uint8_t max_index() const
Definition nnm.hpp:1840
constexpr Int abs_min() const
Definition nnm.hpp:1831
constexpr Vector2i operator-(const Vector2i &other) const
Definition nnm.hpp:2039
constexpr int max() const
Definition nnm.hpp:1804
constexpr Vector2i operator%(const Int value) const
Definition nnm.hpp:2171
constexpr Vector2i operator+() const
Definition nnm.hpp:2192
constexpr Vector2i arbitrary_perpendicular() const
Definition nnm.hpp:1795
int y
Definition nnm.hpp:1631
constexpr Vector2i & operator*=(const Int value)
Definition nnm.hpp:2093
static constexpr Vector2i axis_x()
Definition nnm.hpp:1697
static constexpr Vector2i axis_y()
Definition nnm.hpp:1706
Int * begin()
Definition nnm.hpp:1906
constexpr Vector2i()
Definition nnm.hpp:1636
constexpr bool operator<(const Vector2i &other) const
Definition nnm.hpp:2211
constexpr Vector2i operator*(const Int value) const
Definition nnm.hpp:2083
constexpr uint8_t min_index() const
Definition nnm.hpp:1864
static constexpr Vector2i zero()
Definition nnm.hpp:1679
constexpr const Int & operator[](const uint8_t index) const
Definition nnm.hpp:1961
constexpr Vector2i & operator/=(const Int value)
Definition nnm.hpp:2137
constexpr bool operator!=(const Vector2i &other) const
Definition nnm.hpp:2007
constexpr Vector2i(const Vector2< Real > &vector)
Definition nnm.hpp:1648
constexpr Vector2i operator/(const Int value) const
Definition nnm.hpp:2127
constexpr Vector2i abs() const
Definition nnm.hpp:1715
constexpr bool perpendicular(const Vector2i &other) const
Definition nnm.hpp:1785
constexpr const Int & at(const uint8_t index) const
Definition nnm.hpp:1925
static constexpr Vector2i one()
Definition nnm.hpp:1688
constexpr bool parallel(const Vector2i &other) const
Definition nnm.hpp:1775
constexpr bool operator==(const Vector2i &other) const
Definition nnm.hpp:1997
constexpr Vector2i & operator%=(const Vector2i &other)
Definition nnm.hpp:2159
constexpr Vector2i operator/(const Vector2i &other) const
Definition nnm.hpp:2105
constexpr Vector2i & operator+=(const Vector2i &other)
Definition nnm.hpp:2027
constexpr Vector2i operator*(const Vector2i &other) const
Definition nnm.hpp:2061
constexpr Int cross(const Vector2i &other) const
Definition nnm.hpp:1765
constexpr Vector2i & operator%=(const Int value)
Definition nnm.hpp:2181
const Int * end() const
Definition nnm.hpp:1897
constexpr Int dot(const Vector2i &other) const
Definition nnm.hpp:1755
const Int * begin() const
Definition nnm.hpp:1888
constexpr Vector2i clamp(const Vector2i &min, const Vector2i &max) const
Definition nnm.hpp:1726
constexpr Vector2i & operator*=(const Vector2i &other)
Definition nnm.hpp:2071
constexpr Int & at(const uint8_t index)
Definition nnm.hpp:1943
constexpr Vector2i operator%(const Vector2i &other) const
Definition nnm.hpp:2149
constexpr Vector2i(const Int x, const Int y)
Definition nnm.hpp:1659
constexpr Vector2i operator-() const
Definition nnm.hpp:2201
constexpr Vector2i operator+(const Vector2i &other) const
Definition nnm.hpp:2017
constexpr Vector2i & operator/=(const Vector2i &other)
Definition nnm.hpp:2115
constexpr Int length_sqrd() const
Definition nnm.hpp:1745
static constexpr Vector2i all(Int value)
Definition nnm.hpp:1670
Int * end()
Definition nnm.hpp:1915
constexpr int min() const
Definition nnm.hpp:1822
constexpr Real distance_sqrd(const Vector3 &to) const
Definition nnm.hpp:2477
constexpr Vector3 operator*(const Vector3 &other) const
Definition nnm.hpp:3167
constexpr Vector3 operator/(const Real value) const
Definition nnm.hpp:3243
Real distance(const Vector3 &to) const
Definition nnm.hpp:2490
Real angle(const Vector3 &to) const
Definition nnm.hpp:2652
Vector3 floor() const
Definition nnm.hpp:2427
constexpr Vector3 operator+() const
Definition nnm.hpp:3265
constexpr uint8_t max_index() const
Definition nnm.hpp:2882
constexpr float min() const
Definition nnm.hpp:2864
constexpr bool operator<(const Vector3 &other) const
Definition nnm.hpp:3284
constexpr Vector3 inverse() const
Definition nnm.hpp:2642
constexpr Vector3 scale(const Vector3 &factor) const
constexpr Vector3 lerp_clamped(const Vector3 &to, const Real weight) const
Definition nnm.hpp:2574
constexpr Vector3(const Real x, const Real y, const Real z)
Definition nnm.hpp:2343
Vector3 rotate_axis_angle(const Vector3 &axis, Real angle) const
Definition nnm.hpp:9235
static constexpr Vector3 axis_x()
Definition nnm.hpp:2382
constexpr Vector3 clamp(const Vector3 &min, const Vector3 &max) const
Definition nnm.hpp:2447
constexpr Vector3 shear_z(Real factor_x, Real factor_y) const
Definition nnm.hpp:9296
constexpr uint8_t abs_max_index() const
Definition nnm.hpp:2900
constexpr Vector3 transform(const Basis3< Real > &by) const
Definition nnm.hpp:9308
float x
Definition nnm.hpp:2290
static constexpr Vector3 axis_y()
Definition nnm.hpp:2391
constexpr Vector3(const Vector3i< Int > &vector)
Definition nnm.hpp:9209
constexpr Vector3 translate(const Vector3 &by) const
Definition nnm.hpp:9229
constexpr bool operator==(const Vector3 &other) const
Definition nnm.hpp:3101
constexpr Vector3 rotate_quaternion_at(const Vector3 &origin, const Quaternion< Real > &quaternion) const
Definition nnm.hpp:9253
Vector3 clamp_length(const Real min, const Real max) const
Definition nnm.hpp:2529
constexpr Vector3()
Definition nnm.hpp:2297
static constexpr Vector3 one()
Definition nnm.hpp:2373
Real * begin()
Definition nnm.hpp:3002
constexpr Vector3 shear_z_at(const Vector3 &origin, Real factor_x, Real factor_y) const
Definition nnm.hpp:9302
constexpr Vector3 transform_at(const Vector2< Real > &origin, const Transform2< Real > &by) const
Definition nnm.hpp:9326
static constexpr Vector3 zero()
Definition nnm.hpp:2364
float z
Definition nnm.hpp:2292
constexpr Vector3 & operator-=(const Vector3 &other)
Definition nnm.hpp:3154
constexpr Vector3 rotate_quaternion(const Quaternion< Real > &quaternion) const
Definition nnm.hpp:9247
constexpr Real dot(const Vector3 &other) const
Definition nnm.hpp:2586
constexpr bool perpendicular(const Vector3 &other) const
Definition nnm.hpp:2672
static constexpr Vector3 axis_z()
Definition nnm.hpp:2400
constexpr Vector3 shear_x(Real factor_y, Real factor_z) const
Definition nnm.hpp:9272
constexpr Vector2< Real > xy() const
Definition nnm.hpp:2975
Real length() const
Definition nnm.hpp:2518
constexpr Vector3 operator-(const Vector3 &other) const
Definition nnm.hpp:3144
float y
Definition nnm.hpp:2291
constexpr Matrix3< Real > outer(const Vector3 &other) const
Definition nnm.hpp:9217
constexpr Vector3 operator-() const
Definition nnm.hpp:3274
constexpr Vector3 operator*(const Real value) const
Definition nnm.hpp:3197
static constexpr Vector3 all(Real value)
Definition nnm.hpp:2355
Vector3 ceil() const
Definition nnm.hpp:2418
constexpr Vector3 & operator*=(const Real value)
Definition nnm.hpp:3207
constexpr bool approx_equal(const Vector3 &other) const
Definition nnm.hpp:2957
constexpr Vector3 abs() const
Definition nnm.hpp:2409
constexpr Vector3 shear_x_at(const Vector3 &origin, Real factor_y, Real factor_z) const
Definition nnm.hpp:9278
constexpr Vector3(const Vector2< Real > &vector, const Real z)
Definition nnm.hpp:2330
constexpr Vector3 & operator+=(const Vector3 &other)
Definition nnm.hpp:3131
constexpr Real & at(const uint8_t index)
Definition nnm.hpp:3041
Vector3 direction(const Vector3 &to) const
Definition nnm.hpp:2457
constexpr bool parallel(const Vector3 &other) const
Definition nnm.hpp:2662
constexpr uint8_t abs_min_index() const
Definition nnm.hpp:2937
constexpr const Real & operator[](const uint8_t index) const
Definition nnm.hpp:3061
constexpr Real manhattan_distance(const Vector3 &to) const
Definition nnm.hpp:2500
constexpr Vector3 operator/(const Vector3 &other) const
Definition nnm.hpp:3220
constexpr Vector3 & operator*=(const Vector3 &other)
Definition nnm.hpp:3177
constexpr bool operator!=(const Vector3 &other) const
Definition nnm.hpp:3111
constexpr const Real & at(const uint8_t index) const
Definition nnm.hpp:3021
constexpr Real abs_min() const
Definition nnm.hpp:2873
constexpr bool approx_zero() const
Definition nnm.hpp:2966
constexpr Real abs_max() const
Definition nnm.hpp:2855
constexpr Real & operator[](const uint8_t index)
Definition nnm.hpp:3081
constexpr Vector3 & operator/=(const Vector3 &other)
Definition nnm.hpp:3230
const Real * end() const
Definition nnm.hpp:2993
constexpr Vector3 shear_y(Real factor_x, Real factor_z) const
Definition nnm.hpp:9284
constexpr Vector3 & operator/=(const Real value)
Definition nnm.hpp:3253
Vector3 round() const
Definition nnm.hpp:2436
constexpr Vector3 scale_at(const Vector3 &origin, const Vector3 &factor) const
Definition nnm.hpp:9266
Vector3 normalize() const
Definition nnm.hpp:2549
constexpr Vector3 lerp(const Vector3 &to, const Real weight) const
Definition nnm.hpp:2563
constexpr Vector3 arbitrary_perpendicular() const
Definition nnm.hpp:2682
constexpr Vector3(const Vector3< Other > &vector)
Definition nnm.hpp:2318
constexpr uint8_t min_index() const
Definition nnm.hpp:2919
Vector3 rotate_axis_angle_at(const Vector3 &origin, const Vector3 &axis, Real angle) const
Definition nnm.hpp:9241
Real * end()
Definition nnm.hpp:3011
constexpr Vector3 reflect(const Vector3 &normal) const
Definition nnm.hpp:2613
constexpr Real length_sqrd() const
Definition nnm.hpp:2509
constexpr Vector3 transform_at(const Vector3 &origin, const Transform3< Real > &by, Real w=static_cast< Real >(1)) const
Definition nnm.hpp:9338
constexpr Vector3 transform(const Transform3< Real > &by, Real w=static_cast< Real >(1)) const
Definition nnm.hpp:9332
constexpr Vector3 direction_unnormalized(const Vector3 &to) const
Definition nnm.hpp:2467
constexpr Vector3 cross(const Vector3 &other) const
Definition nnm.hpp:2596
constexpr Vector3 project(const Vector3 &onto) const
Definition nnm.hpp:2628
constexpr Vector3 shear_y_at(const Vector3 &origin, Real factor_x, Real factor_z) const
Definition nnm.hpp:9290
constexpr float max() const
Definition nnm.hpp:2846
constexpr Vector3 transform_at(const Vector3 &origin, const Basis3< Real > &by) const
Definition nnm.hpp:9314
constexpr Vector3 operator*(const Matrix3< Real > &matrix) const
Definition nnm.hpp:9344
const Real * begin() const
Definition nnm.hpp:2984
constexpr Vector3 operator+(const Vector3 &other) const
Definition nnm.hpp:3121
constexpr Vector3 transform(const Transform2< Real > &by) const
Definition nnm.hpp:9320
constexpr Vector3i(const Vector2i< Int > &vector, const Int z)
Definition nnm.hpp:3371
constexpr Vector3i abs() const
Definition nnm.hpp:3450
constexpr Int abs_min() const
Definition nnm.hpp:3567
constexpr const Int & at(const uint8_t index) const
Definition nnm.hpp:3696
constexpr Vector3i & operator/=(const Int value)
Definition nnm.hpp:3921
constexpr Int manhattan_distance(const Vector3i &to) const
Definition nnm.hpp:3471
const Int * begin() const
Definition nnm.hpp:3659
constexpr Vector3i operator%(const Int value) const
Definition nnm.hpp:3957
constexpr Vector3i operator/(const Int value) const
Definition nnm.hpp:3911
static constexpr Vector3i zero()
Definition nnm.hpp:3405
constexpr uint8_t max_index() const
Definition nnm.hpp:3576
const Int * end() const
Definition nnm.hpp:3668
constexpr uint8_t abs_max_index() const
Definition nnm.hpp:3594
constexpr Vector3i & operator%=(const Vector3i &other)
Definition nnm.hpp:3944
constexpr Int & at(const uint8_t index)
Definition nnm.hpp:3716
int z
Definition nnm.hpp:3341
static constexpr Vector3i all(const Int value)
Definition nnm.hpp:3396
constexpr Vector3i operator/(const Vector3i &other) const
Definition nnm.hpp:3888
constexpr Vector3i & operator%=(const Int value)
Definition nnm.hpp:3967
constexpr Vector3i(const Vector3< Real > &vector)
Definition nnm.hpp:3359
constexpr bool perpendicular(const Vector3i &other) const
Definition nnm.hpp:3520
static constexpr Vector3i axis_y()
Definition nnm.hpp:3432
constexpr Vector3i operator+() const
Definition nnm.hpp:3979
constexpr int min() const
Definition nnm.hpp:3558
constexpr Int length_sqrd() const
Definition nnm.hpp:3480
constexpr Vector3i operator%(const Vector3i &other) const
Definition nnm.hpp:3934
constexpr Vector3i operator+(const Vector3i &other) const
Definition nnm.hpp:3796
constexpr Vector3i operator*(const Int value) const
Definition nnm.hpp:3865
constexpr Vector3i & operator+=(const Vector3i &other)
Definition nnm.hpp:3806
constexpr Int abs_max() const
Definition nnm.hpp:3549
constexpr Vector3i & operator*=(const Vector3i &other)
Definition nnm.hpp:3852
constexpr Vector3i(const Int x, const Int y, const Int z)
Definition nnm.hpp:3384
constexpr Vector3i cross(const Vector3i &other) const
Definition nnm.hpp:3500
constexpr Vector3i clamp(const Vector3i &min, const Vector3i &max) const
Definition nnm.hpp:3461
constexpr Vector3i()
Definition nnm.hpp:3346
constexpr bool operator==(const Vector3i &other) const
Definition nnm.hpp:3776
constexpr Vector3i & operator*=(const Int value)
Definition nnm.hpp:3875
static constexpr Vector3i one()
Definition nnm.hpp:3414
static constexpr Vector3i axis_x()
Definition nnm.hpp:3423
int x
Definition nnm.hpp:3339
constexpr Vector3i operator-() const
Definition nnm.hpp:3988
constexpr bool parallel(const Vector3i &other) const
Definition nnm.hpp:3510
constexpr Vector3i & operator-=(const Vector3i &other)
Definition nnm.hpp:3829
Int * begin()
Definition nnm.hpp:3677
constexpr int max() const
Definition nnm.hpp:3540
constexpr const Int & operator[](const uint8_t index) const
Definition nnm.hpp:3736
constexpr Vector2i< Int > xy() const
Definition nnm.hpp:3650
constexpr Int & operator[](const uint8_t index)
Definition nnm.hpp:3756
constexpr Vector3i & operator/=(const Vector3i &other)
Definition nnm.hpp:3898
constexpr Vector3i operator*(const Vector3i &other) const
Definition nnm.hpp:3842
static constexpr Vector3i axis_z()
Definition nnm.hpp:3441
constexpr bool operator!=(const Vector3i &other) const
Definition nnm.hpp:3786
constexpr Vector3i operator-(const Vector3i &other) const
Definition nnm.hpp:3819
constexpr uint8_t abs_min_index() const
Definition nnm.hpp:3631
constexpr bool operator<(const Vector3i &other) const
Definition nnm.hpp:3998
int y
Definition nnm.hpp:3340
Int * end()
Definition nnm.hpp:3686
constexpr uint8_t min_index() const
Definition nnm.hpp:3613
constexpr Vector3i arbitrary_perpendicular() const
Definition nnm.hpp:3530
constexpr Int dot(const Vector3i &other) const
Definition nnm.hpp:3490
constexpr const Real & operator[](const uint8_t index) const
Definition nnm.hpp:4643
constexpr Real abs_min() const
Definition nnm.hpp:4427
Vector4 floor() const
Definition nnm.hpp:4245
const Real * end() const
Definition nnm.hpp:4571
constexpr float min() const
Definition nnm.hpp:4418
float x
Definition nnm.hpp:4080
constexpr Vector4 operator+(const Vector4 &other) const
Definition nnm.hpp:4707
constexpr Real dot(const Vector4 &other) const
Definition nnm.hpp:4358
constexpr Vector4 operator*(const Vector4 &other) const
Definition nnm.hpp:4755
Real length() const
Definition nnm.hpp:4286
constexpr Vector2< Real > xy() const
Definition nnm.hpp:4544
constexpr float max() const
Definition nnm.hpp:4400
constexpr Vector4 & operator+=(const Vector4 &other)
Definition nnm.hpp:4717
constexpr uint8_t max_index() const
Definition nnm.hpp:4436
constexpr Vector4 abs() const
Definition nnm.hpp:4227
Real * begin()
Definition nnm.hpp:4580
static constexpr Vector4 one()
Definition nnm.hpp:4182
constexpr Vector4 & operator*=(const Vector4 &other)
Definition nnm.hpp:4765
constexpr bool operator!=(const Vector4 &other) const
Definition nnm.hpp:4697
constexpr Real & at(const uint8_t index)
Definition nnm.hpp:4621
Real * end()
Definition nnm.hpp:4589
constexpr Real abs_max() const
Definition nnm.hpp:4409
static constexpr Vector4 axis_w()
Definition nnm.hpp:4218
constexpr Vector4 operator-(const Vector4 &other) const
Definition nnm.hpp:4731
static constexpr Vector4 from_quaternion(const Quaternion< Real > &quaternion)
Definition nnm.hpp:9356
constexpr Matrix4< Real > outer(const Vector4 &other) const
Definition nnm.hpp:9362
constexpr uint8_t min_index() const
Definition nnm.hpp:4478
constexpr Vector4 operator/(const Vector4 &other) const
Definition nnm.hpp:4810
Vector4 normalize() const
Definition nnm.hpp:4317
static constexpr Vector4 axis_z()
Definition nnm.hpp:4209
static constexpr Vector4 all(const Real value)
Definition nnm.hpp:4164
constexpr Vector4 & operator-=(const Vector4 &other)
Definition nnm.hpp:4741
constexpr Vector4 operator+() const
Definition nnm.hpp:4875
Vector4 round() const
Definition nnm.hpp:4254
constexpr Real & operator[](const uint8_t index)
Definition nnm.hpp:4665
static constexpr Vector4 axis_y()
Definition nnm.hpp:4200
constexpr Real length_sqrd() const
Definition nnm.hpp:4277
constexpr Vector4 lerp_clamped(const Vector4 &to, const Real weight) const
Definition nnm.hpp:4345
float z
Definition nnm.hpp:4082
constexpr Vector4()
Definition nnm.hpp:4088
constexpr uint8_t abs_max_index() const
Definition nnm.hpp:4454
constexpr const Real & at(const uint8_t index) const
Definition nnm.hpp:4599
constexpr Vector4 & operator/=(const Real value)
Definition nnm.hpp:4844
constexpr bool operator==(const Vector4 &other) const
Definition nnm.hpp:4687
constexpr bool operator<(const Vector4 &other) const
Definition nnm.hpp:4858
static constexpr Vector4 zero()
Definition nnm.hpp:4173
constexpr Vector4 & operator*=(const Real value)
Definition nnm.hpp:4796
constexpr Vector4 transform(const Transform3< Real > &by) const
Definition nnm.hpp:9374
constexpr Vector4 lerp(const Vector4 &to, const Real weight) const
Definition nnm.hpp:4331
constexpr Vector4 operator-() const
Definition nnm.hpp:4884
constexpr Vector4 inverse() const
Definition nnm.hpp:4374
constexpr Vector4 clamp(const Vector4 &min, const Vector4 &max) const
Definition nnm.hpp:4265
static constexpr Vector4 axis_x()
Definition nnm.hpp:4191
constexpr Vector4 operator*(const Matrix4< Real > &matrix) const
Definition nnm.hpp:9386
constexpr Vector4(const Vector3< Real > &vector, const Real w)
Definition nnm.hpp:4129
constexpr Vector4(const Vector2< Real > &vector, const Real z, const Real w)
Definition nnm.hpp:4116
float y
Definition nnm.hpp:4081
constexpr Vector4 operator*(const Real value) const
Definition nnm.hpp:4786
constexpr Vector4(const Real x, const Real y, const Real z, const Real w)
Definition nnm.hpp:4144
constexpr Vector4 & operator/=(const Vector4 &other)
Definition nnm.hpp:4820
const Real * begin() const
Definition nnm.hpp:4562
constexpr Vector4 transform_at(const Vector3< Real > &origin, const Transform3< Real > &by) const
Definition nnm.hpp:9380
constexpr bool approx_zero() const
Definition nnm.hpp:4535
Vector4 ceil() const
Definition nnm.hpp:4236
float w
Definition nnm.hpp:4083
constexpr Vector4(const Vector4< Other > &vector)
Definition nnm.hpp:4102
constexpr bool approx_equal(const Vector4 &other) const
Definition nnm.hpp:4525
constexpr Vector3< Real > xyz() const
Definition nnm.hpp:4553
Vector4 clamp_length(const Real min, const Real max) const
Definition nnm.hpp:4297
constexpr uint8_t abs_min_index() const
Definition nnm.hpp:4500
constexpr Vector4 operator/(const Real value) const
Definition nnm.hpp:4834
constexpr Num max(const Num a, const Num b)
Definition nnm.hpp:88
Vector3i< uint32_t > Vector3u32
Definition nnm.hpp:645
constexpr Num abs(const Num value)
Definition nnm.hpp:72
constexpr bool approx_equal(const Real a, const Real b)
Definition nnm.hpp:134
constexpr Num clamp(const Num value, const Num min, const Num max)
Definition nnm.hpp:265
constexpr Real lerp(const Real from, const Real to, const Real weight)
Definition nnm.hpp:425
Vector2i< uint64_t > Vector2u64
Definition nnm.hpp:630
Vector3< float > Vector3f
Definition nnm.hpp:633
Vector4< double > Vector4d
Definition nnm.hpp:650
Real acos(const Real value)
Definition nnm.hpp:566
Vector2i< int > Vector2ii
Definition nnm.hpp:621
constexpr bool approx_less(const Real a, const Real b)
Definition nnm.hpp:152
constexpr bool approx_less_zero(const Real value)
Definition nnm.hpp:203
Vector2< Real > constexpr operator*(const Real value, const Vector2< Real > &vector)
Definition nnm.hpp:1605
constexpr Real degrees(const Real radians)
Definition nnm.hpp:542
bool angle_in_range(const Real angle, const Real from, const Real to)
Definition nnm.hpp:395
constexpr Int mod(const Int dividend, const Int divisor)
Definition nnm.hpp:339
Quaternion< float > QuaternionF
Definition nnm.hpp:653
constexpr Num sqrd(const Num value)
Definition nnm.hpp:308
Basis3< float > Basis3f
Definition nnm.hpp:673
Vector2< double > Vector2d
Definition nnm.hpp:618
Vector3< double > Vector3d
Definition nnm.hpp:634
Vector3i< int64_t > Vector3i64
Definition nnm.hpp:641
constexpr Real epsilon()
Definition nnm.hpp:45
Vector2i< int32_t > Vector2i32
Definition nnm.hpp:624
Quaternion< double > QuaternionD
Definition nnm.hpp:654
Vector3i< uint8_t > Vector3u8
Definition nnm.hpp:643
Transform3< float > Transform3f
Definition nnm.hpp:681
Real pow(const Real base, const Real power)
Definition nnm.hpp:296
Vector2i< uint8_t > Vector2u8
Definition nnm.hpp:627
Real tan(const Real value)
Definition nnm.hpp:481
Real asin(const Real value)
Definition nnm.hpp:554
Vector2i< uint32_t > Vector2u32
Definition nnm.hpp:629
constexpr bool approx_greater_equal_zero(const Real value)
Definition nnm.hpp:239
Vector3i< int > Vector3ii
Definition nnm.hpp:637
constexpr Int rem(const Int dividend, const Int divisor)
Definition nnm.hpp:369
Vector2< Real > constexpr operator/(const Real value, const Vector2< Real > &vector)
Definition nnm.hpp:1618
constexpr bool approx_less_equal_zero(const Real value)
Definition nnm.hpp:227
Vector2i< int16_t > Vector2i16
Definition nnm.hpp:623
constexpr bool approx_greater(const Real a, const Real b)
Definition nnm.hpp:165
Matrix4< float > Matrix4f
Definition nnm.hpp:677
constexpr Num sign(const Num value)
Definition nnm.hpp:57
Real atan2(const Real y, const Real x)
Definition nnm.hpp:518
Real cos(const Real value)
Definition nnm.hpp:469
Transform2< double > Transform2d
Definition nnm.hpp:670
constexpr bool approx_greater_equal(const Real a, const Real b)
Definition nnm.hpp:191
constexpr Real radians(const Real degrees)
Definition nnm.hpp:530
Real sin(const Real value)
Definition nnm.hpp:457
Basis3< double > Basis3d
Definition nnm.hpp:674
Vector3i< uint16_t > Vector3u16
Definition nnm.hpp:644
Real log2(const Real value)
Definition nnm.hpp:610
Vector2i< uint16_t > Vector2u16
Definition nnm.hpp:628
Real floor(const Real value)
Definition nnm.hpp:411
constexpr bool approx_less_equal(const Real a, const Real b)
Definition nnm.hpp:178
Transform3< double > Transform3d
Definition nnm.hpp:682
Matrix4< double > Matrix4d
Definition nnm.hpp:678
Real modf(const Real dividend, const Real divisor)
Definition nnm.hpp:321
Real normalize_angle(const Real angle)
Definition nnm.hpp:381
Real atan(const Real value)
Definition nnm.hpp:505
Vector2i< int8_t > Vector2i8
Definition nnm.hpp:622
Vector3i< int16_t > Vector3i16
Definition nnm.hpp:639
Vector2i< unsigned int > Vector2iu
Definition nnm.hpp:626
Vector2< float > Vector2f
Definition nnm.hpp:617
Vector3i< int8_t > Vector3i8
Definition nnm.hpp:638
constexpr Real lerp_clamped(const Real from, const Real to, const Real weight)
Definition nnm.hpp:439
Vector3i< uint64_t > Vector3u64
Definition nnm.hpp:646
Basis2< double > Basis2d
Definition nnm.hpp:662
Matrix2< float > Matrix2f
Definition nnm.hpp:657
Real sqrt(const Real value)
Definition nnm.hpp:283
Matrix2< double > Matrix2d
Definition nnm.hpp:658
constexpr bool approx_zero(const Real value)
Definition nnm.hpp:119
Matrix3< double > Matrix3d
Definition nnm.hpp:666
Real remf(const Real dividend, const Real divisor)
Definition nnm.hpp:356
Basis2< float > Basis2f
Definition nnm.hpp:661
constexpr Vector2i< Int > operator%(const Int value, const Vector2i< Int > &vector)
Definition nnm.hpp:2278
constexpr Num min(const Num a, const Num b)
Definition nnm.hpp:579
Real ceil(const Real value)
Definition nnm.hpp:251
Matrix3< float > Matrix3f
Definition nnm.hpp:665
Vector4< float > Vector4f
Definition nnm.hpp:649
Vector2i< int64_t > Vector2i64
Definition nnm.hpp:625
Real round(const Real value)
Definition nnm.hpp:493
constexpr bool approx_greater_zero(const Real value)
Definition nnm.hpp:215
Vector3i< int32_t > Vector3i32
Definition nnm.hpp:640
Vector3i< unsigned int > Vector3iu
Definition nnm.hpp:642
constexpr Real pi()
Definition nnm.hpp:34
Transform2< float > Transform2f
Definition nnm.hpp:669
#define NNM_BOUNDS_CHECK_ASSERT(msg, expression)
Definition nnm.hpp:23
size_t operator()(const Vector2i &vector) const noexcept
Definition nnm.hpp:2234
size_t operator()(const Vector3i &vector) const noexcept
Definition nnm.hpp:4023