GREM 3.12.0
Game/Rendering Engine Modules for C++
Loading...
Searching...
No Matches
quantities.hpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2026 Ivar Härnqvist
2// SPDX-License-Identifier: MIT
3
4#ifndef GREM_PHYSICS_QUANTITIES_HPP
5#define GREM_PHYSICS_QUANTITIES_HPP
6
8
19#include <GREM/core/math.hpp>
22#include <GREM/core/time.hpp>
24
25#if defined(GREM_USE_SSE_INTRINSICS) && !defined(GREM_PHYSICS_USE_DOUBLE_PRECISION)
26#include <immintrin.h> // _MM_..., __m128..., _mm_...
27#endif
28
29#include <type_traits> // std::conditional_t, std::remove_..._t, std::bool_constant, std::false_type, std::true_type
30#include <utility> // std::declval
31
32namespace grem::physics {
33
39template <typename T>
40concept dimension = requires {
41 { std::remove_reference_t<T>::MASS } -> same_as<const int&>;
42 { std::remove_reference_t<T>::LENGTH } -> same_as<const int&>;
43 { std::remove_reference_t<T>::TIME } -> same_as<const int&>;
44} && !requires { typename std::remove_reference_t<T>::DimensionType; };
45
55template <int Mass, int Length, int Time>
56struct Dimension {
57 static constexpr int MASS = Mass;
58 static constexpr int LENGTH = Length;
59 static constexpr int TIME = Time;
60
67 [[nodiscard]] static constexpr auto getSIUnitSymbolString();
68
76 [[nodiscard]] consteval bool operator==(const Dimension& other) const noexcept {
77 (void)other;
78 return true;
79 }
80
88 template <int OtherMass, int OtherLength, int OtherTime>
89 [[nodiscard]] consteval bool operator==(const Dimension<OtherMass, OtherLength, OtherTime>& other) const noexcept {
90 (void)other;
91 return Mass == OtherMass && Length == OtherLength && Time == OtherTime;
92 }
93
100 [[nodiscard]] consteval auto operator+() const {
101 return Dimension{};
102 }
103
110 [[nodiscard]] consteval auto operator-() const {
111 return Dimension{};
112 }
113
122 [[nodiscard]] consteval auto operator+(const Dimension& other) const {
123 (void)other;
124 return Dimension{};
125 }
126
135 [[nodiscard]] consteval auto operator-(const Dimension& other) const {
136 (void)other;
137 return Dimension{};
138 }
139
148 template <int OtherMass, int OtherLength, int OtherTime>
149 [[nodiscard]] consteval auto operator*(const Dimension<OtherMass, OtherLength, OtherTime>& other) const {
150 (void)other;
152 }
153
162 template <int OtherMass, int OtherLength, int OtherTime>
163 [[nodiscard]] consteval auto operator/(const Dimension<OtherMass, OtherLength, OtherTime>& other) const {
164 (void)other;
165 return Dimension<Mass - OtherMass, Length - OtherLength, Time - OtherTime>{};
166 }
167
176 [[nodiscard]] friend consteval auto sqrt(const Dimension& dimension) {
177 static_assert((Mass / 2) * 2 == Mass, "Invalid mass dimension of square root.");
178 static_assert((Length / 2) * 2 == Length, "Invalid length dimension of square root.");
179 static_assert((Time / 2) * 2 == Time, "Invalid time dimension of square root.");
180 (void)dimension;
181 return Dimension<Mass / 2, Length / 2, Time / 2>{};
182 }
183};
184
186inline constexpr Dimension<1, 0, 0> MASS{};
187inline constexpr Dimension<0, 1, 0> LENGTH{};
188inline constexpr Dimension<0, 0, 1> TIME{};
189inline constexpr Dimension ANGLE = DIMENSIONLESS;
190inline constexpr Dimension AREA = LENGTH * LENGTH;
191inline constexpr Dimension VOLUME = LENGTH * LENGTH * LENGTH;
192inline constexpr Dimension DENSITY = MASS / VOLUME;
193inline constexpr Dimension FREQUENCY = DIMENSIONLESS / TIME;
194inline constexpr Dimension ABSEMENT = LENGTH * TIME;
196inline constexpr Dimension VELOCITY = LENGTH / TIME;
197inline constexpr Dimension ACCELERATION = VELOCITY / TIME;
198inline constexpr Dimension FORCE = MASS * ACCELERATION;
199inline constexpr Dimension TORQUE = FORCE * LENGTH;
200inline constexpr Dimension IMPULSE = FORCE * TIME;
201inline constexpr Dimension MOMENTUM = MASS * VELOCITY;
203inline constexpr Dimension ANGULAR_ABSEMENT = ANGLE * TIME;
204inline constexpr Dimension ANGULAR_VELOCITY = ANGLE / TIME;
206inline constexpr Dimension ANGULAR_IMPULSE = TORQUE * TIME;
212inline constexpr Dimension MASS_FLOW_RATE = MASS / TIME;
214inline constexpr Dimension WORK = FORCE * LENGTH;
215inline constexpr Dimension POWER = WORK / TIME;
216inline constexpr Dimension ENERGY = POWER * TIME;
217
218template <int Mass, int Length, int Time>
220 constexpr Dimension<Mass, Length, Time> D{};
221 if constexpr (D == DIMENSIONLESS) {
222 return StringView{};
223 } else if constexpr (D == ANGLE) {
224 return StringView{"rad"};
225 } else if constexpr (D == physics::MASS) {
226 return StringView{"kg"};
227 } else if constexpr (D == physics::LENGTH) {
228 return StringView{"m"};
229 } else if constexpr (D == physics::TIME) {
230 return StringView{"s"};
231 } else if constexpr (D == AREA) {
232 return StringView{"m^2"};
233 } else if constexpr (D == VOLUME) {
234 return StringView{"m^3"};
235 } else if constexpr (D == DENSITY) {
236 return StringView{"kg/m^3"};
237 } else if constexpr (D == FREQUENCY) {
238 return StringView{"Hz"};
239 } else if constexpr (D == ABSEMENT) {
240 return StringView{"m s"};
241 } else if constexpr (D == WAVENUMBER) {
242 return StringView{"m^-1"};
243 } else if constexpr (D == VELOCITY) {
244 return StringView{"m/s"};
245 } else if constexpr (D == ACCELERATION) {
246 return StringView{"m/s^2"};
247 } else if constexpr (D == FORCE) {
248 return StringView{"N"};
249 } else if constexpr (D == TORQUE) {
250 return StringView{"N m"};
251 } else if constexpr (D == IMPULSE) {
252 return StringView{"N s"};
253 } else if constexpr (D == MOMENTUM) {
254 return StringView{"kg m/s"};
255 } else if constexpr (D == MOMENT_OF_INERTIA) {
256 return StringView{"kg m^2"};
257 } else if constexpr (D == ANGULAR_ABSEMENT) {
258 return StringView{"rad s"};
259 } else if constexpr (D == ANGULAR_VELOCITY) {
260 return StringView{"rad/s"};
261 } else if constexpr (D == ANGULAR_ACCELERATION) {
262 return StringView{"rad/s^2"};
263 } else if constexpr (D == ANGULAR_IMPULSE) {
264 return StringView{"N m s"};
265 } else if constexpr (D == ANGULAR_MOMENTUM) {
266 return StringView{"kg m^2/s"};
267 } else if constexpr (D == INTEGRATED_POSITIONAL_IMPULSE) {
268 return StringView{"kg m"};
269 } else if constexpr (D == INTEGRATED_POSITIONAL_MOMENTUM) {
270 return StringView{"kg m"};
271 } else if constexpr (D == INTEGRATED_ROTATIONAL_IMPULSE) {
272 return StringView{"N m s^2"};
273 } else if constexpr (D == INTEGRATED_ROTATIONAL_MOMENTUM) {
274 return StringView{"kg m^2"};
275 } else if constexpr (D == MASS_FLOW_RATE) {
276 return StringView{"kg/s"};
277 } else if constexpr (D == VOLUMETRIC_FLOW_RATE) {
278 return StringView{"m^3/s"};
279 } else if constexpr (D == WORK) {
280 return StringView{"J"};
281 } else if constexpr (D == POWER) {
282 return StringView{"W"};
283 } else if constexpr (D == ENERGY) {
284 return StringView{"J"};
285 } else {
286 constexpr auto formatBaseUnit = [](String& output, int exponent, StringView string) -> void {
287 if (exponent != 0) {
288 if (!output.empty()) {
289 output.push_back(' ');
290 }
291 output.append(string);
292 if (exponent != 1) {
293 output.append(formatString("^{}", exponent));
294 }
295 }
296 };
297 String result{};
298 formatBaseUnit(result, Mass, "kg");
299 formatBaseUnit(result, Length, "m");
300 formatBaseUnit(result, Time, "s");
301 return result;
302 }
303}
304
310template <typename T>
311concept magnitude = requires {
312 { std::remove_reference_t<T>::VALUE } -> same_as<const long double&>;
313 { std::remove_reference_t<T>::IS_ABSOLUTE } -> same_as<const bool&>;
314} && !requires { typename std::remove_reference_t<T>::MagnitudeType; };
315
325template <long double Value, bool IsAbsolute = false>
326struct Magnitude {
327 static constexpr long double VALUE = Value;
328 static constexpr bool IS_ABSOLUTE = IsAbsolute;
329
337 [[nodiscard]] consteval bool operator==(const Magnitude& other) const noexcept {
338 (void)other;
339 return true;
340 }
341
349 template <long double OtherValue, bool OtherIsAbsolute>
350 [[nodiscard]] consteval bool operator==(const Magnitude<OtherValue, OtherIsAbsolute>& other) const noexcept {
351 (void)other;
352 return Value == OtherValue && IsAbsolute == OtherIsAbsolute;
353 }
354
363 [[nodiscard]] consteval auto operator+() const {
364 if (IsAbsolute) {
365 throw physics::Error{"Cannot unary-add a non-relative unit."};
366 }
367 return Magnitude{};
368 }
369
378 [[nodiscard]] consteval auto operator-() const {
379 if (IsAbsolute) {
380 throw physics::Error{"Cannot negate a non-relative unit."};
381 }
382 return Magnitude{};
383 }
384
396 template <long double OtherValue, bool OtherIsAbsolute>
397 [[nodiscard]] consteval auto operator+(const Magnitude<OtherValue, OtherIsAbsolute>& other) const {
398 (void)other;
399 if (Value != OtherValue) {
400 throw physics::Error{"Cannot add units of different magnitudes."};
401 }
402 if (IsAbsolute && OtherIsAbsolute) {
403 throw physics::Error{"Cannot add two non-relative units."};
404 }
406 }
407
419 template <long double OtherValue, bool OtherIsAbsolute>
420 [[nodiscard]] consteval auto operator-(const Magnitude<OtherValue, OtherIsAbsolute>& other) const {
421 (void)other;
422 if (Value != OtherValue) {
423 throw physics::Error{"Cannot subtract units of different magnitudes."};
424 }
425 if (!IsAbsolute && OtherIsAbsolute) {
426 throw physics::Error{"Cannot subtract a non-relative unit from a relative unit."};
427 }
429 }
430
442 template <long double OtherValue, bool OtherIsAbsolute>
443 [[nodiscard]] consteval auto operator*(const Magnitude<OtherValue, OtherIsAbsolute>& other) const {
444 (void)other;
445 if (IsAbsolute && OtherIsAbsolute) {
446 throw physics::Error{"Cannot multiply two non-relative units."};
447 }
449 }
450
462 template <long double OtherValue, bool OtherIsAbsolute>
463 [[nodiscard]] consteval auto operator/(const Magnitude<OtherValue, OtherIsAbsolute>& other) const {
464 (void)other;
465 if (IsAbsolute || OtherIsAbsolute) {
466 throw physics::Error{"Cannot divide non-relative units."};
467 }
468 return Magnitude<Value / OtherValue, false>{};
469 }
470
479 [[nodiscard]] friend consteval auto sqrt(const Magnitude& magnitude) {
480 (void)magnitude;
481 return Magnitude<grem::sqrt(Value), IsAbsolute>{};
482 }
483};
484
485namespace detail {
486
487template <typename UnitT>
488concept can_unary_add = !UnitT::MagnitudeType::IS_ABSOLUTE;
489
490template <typename UnitT>
491concept can_negate = !UnitT::MagnitudeType::IS_ABSOLUTE;
492
493template <typename UnitT1, typename... UnitTs>
494concept can_add = ((UnitT1::DIMENSION == UnitTs::DIMENSION) && ...) && ((UnitT1::MagnitudeType::VALUE == UnitTs::MagnitudeType::VALUE) && ...) &&
495 !(UnitT1::MagnitudeType::IS_ABSOLUTE && (UnitTs::MagnitudeType::IS_ABSOLUTE && ...));
496
497template <typename UnitT1, typename UnitT2>
498concept can_subtract = UnitT1::DIMENSION == UnitT2::DIMENSION && UnitT1::MagnitudeType::VALUE == UnitT2::MagnitudeType::VALUE &&
499 (UnitT1::MagnitudeType::IS_ABSOLUTE || !UnitT2::MagnitudeType::IS_ABSOLUTE);
500
501template <typename UnitT1, typename... UnitTs>
502concept can_multiply = !(UnitT1::MagnitudeType::IS_ABSOLUTE && (UnitTs::MagnitudeType::IS_ABSOLUTE && ...));
503
504template <typename UnitT1, typename UnitT2>
505concept can_divide = !UnitT1::MagnitudeType::IS_ABSOLUTE && !UnitT2::MagnitudeType::IS_ABSOLUTE;
506
507} // namespace detail
508
514template <typename T>
515concept unit = requires {
516 typename std::remove_reference_t<T>::DimensionType;
517 { std::remove_reference_t<T>::DIMENSION } -> dimension;
518 { std::remove_reference_t<T>::DIMENSION } -> same_as<const typename std::remove_reference_t<T>::DimensionType&>;
519 { std::remove_reference_t<T>::MAGNITUDE } -> magnitude;
520 { std::remove_reference_t<T>::MAGNITUDE } -> same_as<const typename std::remove_reference_t<T>::MagnitudeType&>;
521} && !requires { typename std::remove_reference_t<T>::Unit; };
522
524template <unit UnitT>
525struct canonical_unit {
526 using type = UnitT;
527};
529
535template <unit UnitT>
536using canonical_unit_t = typename canonical_unit<UnitT>::type;
537
544template <Dimension D, Magnitude M>
545struct BaseUnit {
546 using DimensionType = std::remove_cvref_t<decltype(D)>;
547 using MagnitudeType = std::remove_cvref_t<decltype(M)>;
548 static constexpr DimensionType DIMENSION = D;
549 static constexpr MagnitudeType MAGNITUDE = M;
550
557 [[nodiscard]] static constexpr auto getSymbolString() {
558 if constexpr (MagnitudeType::VALUE == 1.0l) {
559 return DimensionType::getSIUnitSymbolString();
560 } else {
561 return formatString("({} {})", MagnitudeType::VALUE, DimensionType::getSIUnitSymbolString());
562 }
563 }
564
572 template <unit OtherUnitT>
573 [[nodiscard]] consteval operator OtherUnitT() const
574 requires(OtherUnitT::DIMENSION == D && OtherUnitT::MagnitudeType::VALUE == MagnitudeType::VALUE && OtherUnitT::MagnitudeType::IS_ABSOLUTE && !MagnitudeType::IS_ABSOLUTE) {
575 return OtherUnitT{};
576 }
577
584 [[nodiscard]] consteval auto operator+() const {
585 static_assert(detail::can_unary_add<BaseUnit>, "This unit cannot be unary-added.");
587 }
588
595 [[nodiscard]] consteval auto operator-() const {
596 static_assert(detail::can_negate<BaseUnit>, "This unit cannot be negated.");
598 }
599
608 template <unit OtherUnitT>
609 [[nodiscard]] consteval auto operator+(const OtherUnitT& other) const {
610 static_assert(detail::can_add<BaseUnit, OtherUnitT>, "These units cannot be added.");
611 (void)other;
613 }
614
623 template <unit OtherUnitT>
624 [[nodiscard]] consteval auto operator-(const OtherUnitT& other) const {
625 static_assert(detail::can_subtract<BaseUnit, OtherUnitT>, "These units cannot be subtracted.");
626 (void)other;
627 return canonical_unit_t<BaseUnit<DIMENSION - OtherUnitT::DIMENSION, MAGNITUDE - OtherUnitT::MAGNITUDE>>{};
628 }
629
638 template <unit OtherUnitT>
639 [[nodiscard]] consteval auto operator*(const OtherUnitT& other) const {
640 static_assert(detail::can_multiply<BaseUnit, OtherUnitT>, "These units cannot be multiplied.");
641 (void)other;
643 }
644
653 template <unit OtherUnitT>
654 [[nodiscard]] consteval auto operator/(const OtherUnitT& other) const {
655 static_assert(detail::can_divide<BaseUnit, OtherUnitT>, "These units cannot be divided.");
656 (void)other;
657 return canonical_unit_t<BaseUnit<DIMENSION / OtherUnitT::DIMENSION, MAGNITUDE / OtherUnitT::MAGNITUDE>>{};
658 }
659};
660
669template <unit UnitT1, unit UnitT2>
670[[nodiscard]] consteval bool operator==(UnitT1 a, UnitT2 b) {
671 (void)a;
672 (void)b;
673 return UnitT1::DIMENSION == UnitT2::DIMENSION && UnitT1::MAGNITUDE == UnitT2::MAGNITUDE;
674}
675
687template <unit UnitT>
688[[nodiscard]] consteval auto operator+(const UnitT& a) requires(!UnitT::MagnitudeType::IS_ABSOLUTE) {
689 (void)a;
690 return UnitT{};
691}
692
704template <unit UnitT>
705[[nodiscard]] consteval auto operator-(const UnitT& a) requires(!UnitT::MagnitudeType::IS_ABSOLUTE) {
706 (void)a;
707 return UnitT{};
708}
709
721template <unit UnitT>
722[[nodiscard]] consteval auto operator+(const UnitT& a, const UnitT& b) requires(!UnitT::MagnitudeType::IS_ABSOLUTE) {
723 (void)a;
724 (void)b;
725 return UnitT{};
726}
727
739template <unit UnitT>
740[[nodiscard]] consteval auto operator-(const UnitT& a, const UnitT& b) requires(!UnitT::MagnitudeType::IS_ABSOLUTE) {
741 (void)a;
742 (void)b;
743 return UnitT{};
744}
745
758template <unit UnitT1, unit UnitlessT2>
759[[nodiscard]] consteval auto operator*(const UnitT1& a, const UnitlessT2& b)
760 requires(UnitlessT2::DIMENSION == DIMENSIONLESS && UnitlessT2::MagnitudeType::VALUE == 1.0l && !UnitlessT2::MagnitudeType::IS_ABSOLUTE) {
761 (void)a;
762 (void)b;
763 return UnitT1{};
764}
765
778template <unit UnitlessT1, unit UnitT2>
779[[nodiscard]] consteval auto operator*(const UnitlessT1& a, const UnitT2& b)
780 requires(UnitlessT1::DIMENSION == DIMENSIONLESS && UnitlessT1::MagnitudeType::VALUE == 1.0l && !UnitlessT1::MagnitudeType::IS_ABSOLUTE) {
781 (void)a;
782 (void)b;
783 return UnitT2{};
784}
785
798template <unit UnitT1, unit UnitlessT2>
799[[nodiscard]] consteval auto operator/(const UnitT1& a, const UnitlessT2& b)
800 requires(UnitlessT2::DIMENSION == DIMENSIONLESS && UnitlessT2::MagnitudeType::VALUE == 1.0l && !UnitlessT2::MagnitudeType::IS_ABSOLUTE) {
801 (void)a;
802 (void)b;
803 return UnitT1{};
804}
805
807template <unit UnitT>
808struct in_base_units {
809 using type = BaseUnit<UnitT::DIMENSION, UnitT::MAGNITUDE>;
810};
812
819template <unit UnitT>
820using in_base_units_t = typename in_base_units<UnitT>::type;
821
829template <typename UnitT1, typename... UnitTs>
830requires(detail::can_add<UnitT1, UnitTs...>) using BaseSum = BaseUnit<(UnitT1::DIMENSION + ... + UnitTs::DIMENSION), (UnitT1::MAGNITUDE + ... + UnitTs::MAGNITUDE)>;
831
839template <typename UnitT1, typename... UnitTs>
840using Sum = canonical_unit_t<BaseSum<UnitT1, UnitTs...>>;
841
849template <typename UnitT1, typename UnitT2>
850requires(detail::can_subtract<UnitT1, UnitT2>) using BaseDifference = BaseUnit<(UnitT1::DIMENSION - UnitT2::DIMENSION), (UnitT1::MAGNITUDE - UnitT2::MAGNITUDE)>;
851
859template <typename UnitT1, typename UnitT2>
861
869template <typename UnitT1, typename... UnitTs>
870requires(detail::can_multiply<UnitT1, UnitTs...>) using BaseProduct = BaseUnit<(UnitT1::DIMENSION * ... * UnitTs::DIMENSION), (UnitT1::MAGNITUDE * ... * UnitTs::MAGNITUDE)>;
871
879template <typename UnitT1, typename... UnitTs>
880using Product = canonical_unit_t<BaseProduct<UnitT1, UnitTs...>>;
881
888template <typename UnitT1, typename UnitT2>
889requires(detail::can_divide<UnitT1, UnitT2>) using BaseQuotient = BaseUnit<(UnitT1::DIMENSION / UnitT2::DIMENSION), (UnitT1::MAGNITUDE / UnitT2::MAGNITUDE)>;
890
898template <typename UnitT1, typename UnitT2>
900
908template <typename UnitT, long double Multiple>
910
918template <typename UnitT, long double Multiple>
920
931template <long double Multiple, unit UnitT>
932[[nodiscard]] consteval auto multipleOf(UnitT a) {
933 (void)a;
935}
936
943template <typename UnitT>
945
952template <typename UnitT>
954
963template <unit UnitT>
964[[nodiscard]] consteval auto relative(UnitT a) {
965 (void)a;
966 return Relative<UnitT>{};
967}
968
975template <typename UnitT>
977
984template <typename UnitT>
985struct Absolute : BaseAbsolute<UnitT> {
987 [[nodiscard]] static constexpr auto getSymbolString() {
989 }
990
991 using BaseAbsolute<UnitT>::BaseAbsolute;
992
998 consteval Absolute(UnitT other) {
999 (void)other;
1000 }
1001};
1002
1004template <Dimension D, Magnitude M>
1005requires(decltype(M)::IS_ABSOLUTE) struct canonical_unit<BaseUnit<D, M>> {
1006 using type = Absolute<Relative<BaseUnit<D, M>>>;
1007};
1009
1018template <unit UnitT>
1019[[nodiscard]] consteval auto absolute(UnitT a) {
1020 (void)a;
1021 return Absolute<UnitT>{};
1022}
1023
1030template <typename UnitT>
1031using BaseSqrt = BaseUnit<sqrt(UnitT::DIMENSION), sqrt(UnitT::MAGNITUDE)>;
1032
1039template <typename UnitT>
1041
1050template <unit UnitT>
1051[[nodiscard]] consteval auto sqrt(UnitT a) {
1052 (void)a;
1053 return Sqrt<UnitT>{};
1054}
1055
1062template <typename UnitT>
1063using BaseReciprocal = BaseUnit<DIMENSIONLESS / UnitT::DIMENSION, Magnitude<1.0l / UnitT::MagnitudeType::VALUE, UnitT::MagnitudeType::IS_ABSOLUTE>{}>;
1064
1071template <typename UnitT>
1073
1082template <unit UnitT>
1083[[nodiscard]] consteval auto per(UnitT a) {
1084 (void)a;
1085 return Reciprocal<UnitT>{};
1086}
1087
1093template <typename UnitT>
1095
1101template <typename UnitT>
1103
1111template <unit UnitT>
1112[[nodiscard]] consteval auto square(UnitT a) {
1113 (void)a;
1114 return Square<UnitT>{};
1115}
1116
1123template <typename UnitT>
1125
1132template <typename UnitT>
1134
1143template <unit UnitT>
1144[[nodiscard]] consteval auto cubic(UnitT a) {
1145 (void)a;
1146 return Cubic<UnitT>{};
1147}
1148
1155template <typename UnitT>
1156using BaseKilo = BaseMultipleOf<UnitT, 1000.0l>;
1157
1164template <typename UnitT>
1166
1175template <unit UnitT>
1176[[nodiscard]] consteval auto kilo(UnitT a) {
1177 (void)a;
1178 return Kilo<UnitT>{};
1179}
1180
1187template <typename UnitT>
1188using BaseDeci = BaseMultipleOf<UnitT, 0.1l>;
1189
1196template <typename UnitT>
1198
1207template <unit UnitT>
1208[[nodiscard]] consteval auto deci(UnitT a) {
1209 (void)a;
1210 return Deci<UnitT>{};
1211}
1212
1219template <typename UnitT>
1220using BaseCenti = BaseMultipleOf<UnitT, 0.01l>;
1221
1228template <typename UnitT>
1230
1239template <unit UnitT>
1240[[nodiscard]] consteval auto centi(UnitT a) {
1241 (void)a;
1242 return Centi<UnitT>{};
1243}
1244
1251template <typename UnitT>
1252using BaseMilli = BaseMultipleOf<UnitT, 0.001l>;
1253
1260template <typename UnitT>
1262
1271template <unit UnitT>
1272[[nodiscard]] consteval auto milli(UnitT a) {
1273 (void)a;
1274 return Milli<UnitT>{};
1275}
1276
1282template <Dimension D>
1283using BaseSIUnit = BaseUnit<D, Magnitude<1.0l>{}>;
1284
1290template <Dimension D>
1292
1298template <Dimension D>
1299inline constexpr SIUnit<D> SI_UNIT{};
1300
1301// Common unit definitions:
1303#define GREM_PRIVATE_PHYSICS_DEFINE_UNIT(Name, UPPERCASE_NAME, symbol, ...) \
1304 struct Name : __VA_ARGS__ { \
1305 [[nodiscard]] static constexpr StringView getSymbolString() { \
1306 return symbol; \
1307 } \
1308 }; \
1309 inline constexpr Name UPPERCASE_NAME{};
1310
1311#define GREM_PRIVATE_PHYSICS_DEFINE_CANONICAL_UNIT(Name, UPPERCASE_NAME, symbol, ...) \
1312 GREM_PRIVATE_PHYSICS_DEFINE_UNIT(Name, UPPERCASE_NAME, symbol, __VA_ARGS__) \
1313 template <> \
1314 struct canonical_unit<in_base_units_t<__VA_ARGS__>> { \
1315 using type = Name; \
1316 };
1317
1318GREM_PRIVATE_PHYSICS_DEFINE_CANONICAL_UNIT(Unitless, UNITLESS, {}, BaseSIUnit<DIMENSIONLESS>)
1319GREM_PRIVATE_PHYSICS_DEFINE_CANONICAL_UNIT(Percent, PERCENT, "%", BaseMultipleOf<Unitless, 0.01l>)
1320GREM_PRIVATE_PHYSICS_DEFINE_UNIT(Radians, RADIANS, "rad", BaseSIUnit<ANGLE>)
1321GREM_PRIVATE_PHYSICS_DEFINE_CANONICAL_UNIT(Degrees, DEGREES, "deg", BaseMultipleOf<Radians, 0.01745329251994329576923690768489l>)
1322GREM_PRIVATE_PHYSICS_DEFINE_CANONICAL_UNIT(Turns, TURNS, "turns", BaseMultipleOf<Radians, 6.28318530718l>)
1323GREM_PRIVATE_PHYSICS_DEFINE_CANONICAL_UNIT(Kilograms, KILOGRAMS, "kg", BaseSIUnit<MASS>)
1324GREM_PRIVATE_PHYSICS_DEFINE_CANONICAL_UNIT(Grams, GRAMS, "g", BaseMilli<Kilograms>)
1325GREM_PRIVATE_PHYSICS_DEFINE_CANONICAL_UNIT(Meters, METERS, "m", BaseSIUnit<LENGTH>)
1326GREM_PRIVATE_PHYSICS_DEFINE_CANONICAL_UNIT(Kilometers, KILOMETERS, "km", BaseKilo<Meters>)
1327GREM_PRIVATE_PHYSICS_DEFINE_CANONICAL_UNIT(Decimeters, DECIMETERS, "dm", BaseDeci<Meters>)
1328GREM_PRIVATE_PHYSICS_DEFINE_CANONICAL_UNIT(Centimeters, CENTIMETERS, "cm", BaseCenti<Meters>)
1329GREM_PRIVATE_PHYSICS_DEFINE_CANONICAL_UNIT(Millimeters, MILLIMETERS, "mm", BaseMilli<Meters>)
1330GREM_PRIVATE_PHYSICS_DEFINE_CANONICAL_UNIT(Seconds, SECONDS, "s", BaseSIUnit<TIME>)
1331GREM_PRIVATE_PHYSICS_DEFINE_CANONICAL_UNIT(Milliseconds, MILLISECONDS, "ms", BaseMilli<Seconds>)
1332GREM_PRIVATE_PHYSICS_DEFINE_CANONICAL_UNIT(Minutes, MINUTES, "min", BaseMultipleOf<Seconds, 60.0l>)
1333GREM_PRIVATE_PHYSICS_DEFINE_CANONICAL_UNIT(Hours, HOURS, "h", BaseMultipleOf<Minutes, 60.0l>)
1334GREM_PRIVATE_PHYSICS_DEFINE_CANONICAL_UNIT(SquareMeters, SQUARE_METERS, "m^2", BaseSquare<Meters>)
1335GREM_PRIVATE_PHYSICS_DEFINE_CANONICAL_UNIT(SquareKilometers, SQUARE_KILOMETERS, "km^2", BaseSquare<Kilometers>)
1336GREM_PRIVATE_PHYSICS_DEFINE_CANONICAL_UNIT(SquareDecimeters, SQUARE_DECIMETERS, "dm^2", BaseSquare<Decimeters>)
1337GREM_PRIVATE_PHYSICS_DEFINE_CANONICAL_UNIT(SquareCentimeters, SQUARE_CENTIMETERS, "cm^2", BaseSquare<Centimeters>)
1338GREM_PRIVATE_PHYSICS_DEFINE_CANONICAL_UNIT(SquareMillimeters, SQUARE_MILLIMETERS, "mm^2", BaseSquare<Millimeters>)
1339GREM_PRIVATE_PHYSICS_DEFINE_CANONICAL_UNIT(CubicMeters, CUBIC_METERS, "m^3", BaseCubic<Meters>)
1340GREM_PRIVATE_PHYSICS_DEFINE_UNIT(CubicDecimeters, CUBIC_DECIMETERS, "dm^3", BaseCubic<Decimeters>)
1341GREM_PRIVATE_PHYSICS_DEFINE_UNIT(CubicCentimeters, CUBIC_CENTIMETERS, "cm^3", BaseCubic<Centimeters>)
1342GREM_PRIVATE_PHYSICS_DEFINE_CANONICAL_UNIT(CubicMillimeters, CUBIC_MILLIMETERS, "mm^3", BaseCubic<Millimeters>)
1343GREM_PRIVATE_PHYSICS_DEFINE_CANONICAL_UNIT(Liters, LITERS, "l", CubicDecimeters)
1344GREM_PRIVATE_PHYSICS_DEFINE_CANONICAL_UNIT(Deciliters, DECILITERS, "dl", BaseDeci<Liters>)
1345GREM_PRIVATE_PHYSICS_DEFINE_CANONICAL_UNIT(Centiliters, CENTILITERS, "cl", BaseCenti<Liters>)
1346GREM_PRIVATE_PHYSICS_DEFINE_CANONICAL_UNIT(Milliliters, MILLILITERS, "ml", CubicCentimeters)
1347GREM_PRIVATE_PHYSICS_DEFINE_CANONICAL_UNIT(KilogramsPerCubicMeter, KILOGRAMS_PER_CUBIC_METER, "kg/m^3", BaseQuotient<Kilograms, CubicMeters>)
1348GREM_PRIVATE_PHYSICS_DEFINE_CANONICAL_UNIT(GramsPerCubicCentimeter, GRAMS_PER_CUBIC_CENTIMETER, "g/cm^3", BaseQuotient<Grams, CubicCentimeters>)
1349GREM_PRIVATE_PHYSICS_DEFINE_UNIT(PerSecond, PER_SECOND, "per second", BaseReciprocal<Seconds>)
1350GREM_PRIVATE_PHYSICS_DEFINE_CANONICAL_UNIT(PerMillisecond, PER_MILLISECOND, "per millisecond", BaseReciprocal<Milliseconds>)
1351GREM_PRIVATE_PHYSICS_DEFINE_CANONICAL_UNIT(PerMinute, PER_MINUTE, "per minute", BaseReciprocal<Minutes>)
1352GREM_PRIVATE_PHYSICS_DEFINE_CANONICAL_UNIT(PerHour, PER_HOUR, "per hour", BaseReciprocal<Hours>)
1353GREM_PRIVATE_PHYSICS_DEFINE_CANONICAL_UNIT(PerMeter, PER_METER, "per meter", BaseReciprocal<Meters>)
1354GREM_PRIVATE_PHYSICS_DEFINE_CANONICAL_UNIT(PerKilogram, PER_KILOGRAM, "per kilogram", BaseReciprocal<Kilograms>)
1355GREM_PRIVATE_PHYSICS_DEFINE_CANONICAL_UNIT(Hertz, HERTZ, "Hz", PerSecond)
1356GREM_PRIVATE_PHYSICS_DEFINE_CANONICAL_UNIT(MeterSeconds, METER_SECONDS, "m s", BaseProduct<Meters, Seconds>)
1357GREM_PRIVATE_PHYSICS_DEFINE_CANONICAL_UNIT(MetersPerSecond, METERS_PER_SECOND, "m/s", BaseQuotient<Meters, Seconds>)
1358GREM_PRIVATE_PHYSICS_DEFINE_CANONICAL_UNIT(DecimetersPerSecond, DECIMETERS_PER_SECOND, "dm/s", BaseQuotient<Decimeters, Seconds>)
1359GREM_PRIVATE_PHYSICS_DEFINE_CANONICAL_UNIT(CentimetersPerSecond, CENTIMETERS_PER_SECOND, "cm/s", BaseQuotient<Centimeters, Seconds>)
1360GREM_PRIVATE_PHYSICS_DEFINE_CANONICAL_UNIT(MillimetersPerSecond, MILLIMETERS_PER_SECOND, "mm/s", BaseQuotient<Millimeters, Seconds>)
1361GREM_PRIVATE_PHYSICS_DEFINE_CANONICAL_UNIT(KilometersPerHour, KILOMETERS_PER_HOUR, "km/h", BaseQuotient<Kilometers, Hours>)
1362GREM_PRIVATE_PHYSICS_DEFINE_CANONICAL_UNIT(MetersPerSecondSquared, METERS_PER_SECOND_SQUARED, "m/s^2", BaseQuotient<Meters, BaseSquare<Seconds>>)
1363GREM_PRIVATE_PHYSICS_DEFINE_UNIT(KilogramMetersPerSecondSquared, KILOGRAM_METERS_PER_SECOND_SQUARED, "kg m/s^2", BaseProduct<Kilograms, MetersPerSecondSquared>)
1364GREM_PRIVATE_PHYSICS_DEFINE_CANONICAL_UNIT(Newton, NEWTON, "N", KilogramMetersPerSecondSquared)
1365GREM_PRIVATE_PHYSICS_DEFINE_CANONICAL_UNIT(KilogramMeters, KILOGRAM_METERS, "kg m", BaseProduct<Kilograms, Meters>)
1366GREM_PRIVATE_PHYSICS_DEFINE_CANONICAL_UNIT(KilogramSquareMeters, KILOGRAM_SQUARE_METERS, "kg m^2", BaseProduct<Kilograms, SquareMeters>)
1367GREM_PRIVATE_PHYSICS_DEFINE_CANONICAL_UNIT(PerKilogramSquareMeter, PER_KILOGRAM_SQUARE_METER, "per kilogram square meter", BaseReciprocal<KilogramSquareMeters>)
1368GREM_PRIVATE_PHYSICS_DEFINE_CANONICAL_UNIT(NewtonMeters, NEWTON_METERS, "N m", BaseProduct<Newton, Meters>)
1369GREM_PRIVATE_PHYSICS_DEFINE_UNIT(KilogramSquareMetersPerSecondSquared, KILOGRAM_SQUARE_METERS_PER_SECOND_SQUARED, "kg m^s/s^2",
1370 BaseQuotient<KilogramSquareMeters, BaseSquare<Seconds>>)
1371GREM_PRIVATE_PHYSICS_DEFINE_CANONICAL_UNIT(NewtonSeconds, NEWTON_SECONDS, "N s", BaseProduct<Newton, Seconds>)
1372GREM_PRIVATE_PHYSICS_DEFINE_UNIT(KilogramMetersPerSecond, KILOGRAM_METERS_PER_SECOND, "kg m/s", BaseQuotient<KilogramMeters, Seconds>)
1373GREM_PRIVATE_PHYSICS_DEFINE_UNIT(RadianSeconds, RADIAN_SECONDS, "rad s", BaseProduct<Radians, Seconds>)
1374GREM_PRIVATE_PHYSICS_DEFINE_CANONICAL_UNIT(DegreeSeconds, DEGREE_SECONDS, "deg s", BaseProduct<Degrees, Seconds>)
1375GREM_PRIVATE_PHYSICS_DEFINE_CANONICAL_UNIT(TurnSeconds, TURN_SECONDS, "turns s", BaseProduct<Turns, Seconds>)
1376GREM_PRIVATE_PHYSICS_DEFINE_UNIT(RadiansPerSecond, RADIANS_PER_SECOND, "rad/s", BaseQuotient<Radians, Seconds>)
1377GREM_PRIVATE_PHYSICS_DEFINE_CANONICAL_UNIT(DegreesPerSecond, DEGREES_PER_SECOND, "deg/s", BaseQuotient<Degrees, Seconds>)
1378GREM_PRIVATE_PHYSICS_DEFINE_CANONICAL_UNIT(TurnsPerSecond, TURNS_PER_SECOND, "turns/s", BaseQuotient<Turns, Seconds>)
1379GREM_PRIVATE_PHYSICS_DEFINE_CANONICAL_UNIT(RevolutionsPerMinute, REVOLUTIONS_PER_MINUTE, "RPM", BaseQuotient<Turns, Minutes>)
1380GREM_PRIVATE_PHYSICS_DEFINE_CANONICAL_UNIT(RadiansPerSecondSquared, RADIANS_PER_SECOND_SQUARED, "rad/s^2", BaseQuotient<Radians, BaseSquare<Seconds>>)
1381GREM_PRIVATE_PHYSICS_DEFINE_CANONICAL_UNIT(NewtonMeterSeconds, NEWTON_METER_SECONDS, "N m s", BaseProduct<Newton, Meters, Seconds>)
1382GREM_PRIVATE_PHYSICS_DEFINE_UNIT(NewtonSecondsPerMeter, NEWTON_SECONDS_PER_METER, "N s/m", BaseQuotient<BaseProduct<Newton, Seconds>, Meters>)
1383GREM_PRIVATE_PHYSICS_DEFINE_UNIT(NewtonMeterSecondsPerRadian, NEWTON_METER_SECONDS_PER_RADIAN, "N m s/rad", BaseQuotient<BaseProduct<Newton, Meters, Seconds>, Radians>)
1384GREM_PRIVATE_PHYSICS_DEFINE_UNIT(KilogramSquareMetersPerSecond, KILOGRAM_SQUARE_METERS_PER_SECOND, "kg m^s/s", BaseQuotient<KilogramSquareMeters, Seconds>)
1385GREM_PRIVATE_PHYSICS_DEFINE_UNIT(NewtonMeterSecondsSquared, NEWTON_METER_SECONDS_SQUARED, "N m s^2", BaseProduct<Newton, Meters, BaseSquare<Seconds>>)
1386GREM_PRIVATE_PHYSICS_DEFINE_CANONICAL_UNIT(KilogramsPerSecond, KILOGRAMS_PER_SECOND, "kg/s", BaseQuotient<Kilograms, Seconds>)
1387GREM_PRIVATE_PHYSICS_DEFINE_CANONICAL_UNIT(CubicMetersPerSecond, CUBIC_METERS_PER_SECOND, "m^3/s", BaseQuotient<CubicMeters, Seconds>)
1388GREM_PRIVATE_PHYSICS_DEFINE_CANONICAL_UNIT(Watts, WATTS, "W", BaseQuotient<KilogramSquareMeters, Cubic<Seconds>>)
1389GREM_PRIVATE_PHYSICS_DEFINE_UNIT(KilogramSquareMetersPerSecondCubed, KILOGRAM_SQUARE_METERS_PER_SECOND_CUBED, "kg m^2/s^3", BaseQuotient<KilogramSquareMeters, Cubic<Seconds>>)
1390GREM_PRIVATE_PHYSICS_DEFINE_CANONICAL_UNIT(Kilowatts, KILOWATTS, "kW", BaseMultipleOf<Watts, 1000.0l>)
1391GREM_PRIVATE_PHYSICS_DEFINE_CANONICAL_UNIT(Megawatts, MEGAWATTS, "MW", BaseMultipleOf<Watts, 1000000.0l>)
1392GREM_PRIVATE_PHYSICS_DEFINE_UNIT(Joules, JOULES, "J", BaseQuotient<KilogramSquareMeters, BaseSquare<Seconds>>)
1393GREM_PRIVATE_PHYSICS_DEFINE_CANONICAL_UNIT(Kilojoules, KILOJOULES, "kJ", BaseMultipleOf<Joules, 1000.0l>)
1394GREM_PRIVATE_PHYSICS_DEFINE_CANONICAL_UNIT(Megajoules, MEGAJOULES, "MJ", BaseMultipleOf<Joules, 1000000.0l>)
1395GREM_PRIVATE_PHYSICS_DEFINE_CANONICAL_UNIT(KilowattHours, KILOWATT_HOURS, "kW h", BaseProduct<Kilowatts, Hours>)
1396GREM_PRIVATE_PHYSICS_DEFINE_CANONICAL_UNIT(MegawattHours, MEGAWATT_HOURS, "MW h", BaseProduct<Megawatts, Hours>)
1397GREM_PRIVATE_PHYSICS_DEFINE_CANONICAL_UNIT(NewtonPerMeter, NEWTON_PER_METER, "N/m", BaseQuotient<Newton, Meters>);
1398GREM_PRIVATE_PHYSICS_DEFINE_CANONICAL_UNIT(NewtonPerMillimeter, NEWTON_PER_MILLIMETER, "N/mm", BaseQuotient<Newton, Millimeters>);
1399GREM_PRIVATE_PHYSICS_DEFINE_CANONICAL_UNIT(MetersPerNewton, METERS_PER_NEWTON, "m/N", BaseQuotient<Meters, Newton>);
1400GREM_PRIVATE_PHYSICS_DEFINE_CANONICAL_UNIT(MillimetersPerNewton, MILLIMETERS_PER_NEWTON, "mm/N", BaseQuotient<Millimeters, Newton>);
1401
1402#undef GREM_PRIVATE_PHYSICS_DEFINE_UNIT
1403#undef GREM_PRIVATE_PHYSICS_DEFINE_CANONICAL_UNIT
1404
1405static_assert(sqrt(SQUARE_METERS) == METERS);
1406static_assert(sqrt(square(SQUARE_METERS)) == SQUARE_METERS);
1407static_assert(sqrt(square(square(SQUARE_METERS))) == square(SQUARE_METERS));
1409
1417struct Zero {
1425 GREM_ALWAYS_INLINE consteval explicit Zero(float value) {
1426 if (!(value == 0.0f)) {
1427 throw physics::Error{"Zero constructed from a non-zero value."};
1428 }
1429 }
1430
1438 GREM_ALWAYS_INLINE consteval explicit Zero(double value) {
1439 if (!(value == 0.0)) {
1440 throw physics::Error{"Zero constructed from a non-zero value."};
1441 }
1442 }
1443
1451 GREM_ALWAYS_INLINE consteval explicit Zero(int value) {
1452 if (value != 0) {
1453 throw physics::Error{"Zero constructed from a non-zero value."};
1454 }
1455 }
1456
1468 GREM_ALWAYS_INLINE consteval Zero(Zero* value) {
1469 if (value != nullptr) {
1470 throw physics::Error{"Zero constructed from a non-zero value."};
1471 }
1472 }
1473};
1474
1475#ifdef GREM_PHYSICS_USE_DOUBLE_PRECISION
1477using Scalar = double;
1478#else
1480using Scalar = float;
1481#endif
1482
1488template <size_t Index>
1490 static constexpr size_t INDEX = Index;
1491};
1492inline constexpr ComponentSwizzle<0> X{};
1493inline constexpr ComponentSwizzle<1> Y{};
1494inline constexpr ComponentSwizzle<2> Z{};
1495
1503template <size_t N, typename UnitT>
1505
1513template <size_t N, typename UnitT>
1514requires(N == 2 || N == 3) //
1515using AngularQuantity = std::conditional_t<N == 3, Quantity<3, UnitT>, Quantity<1, UnitT>>;
1516
1517template <typename UnitT>
1518struct Quantity<1, UnitT> {
1519 using Unit = UnitT;
1520 using DimensionType = typename Unit::DimensionType;
1521 using MagnitudeType = typename Unit::MagnitudeType;
1522 static constexpr size_t RANK = 1;
1523 static constexpr Unit UNIT{};
1524 static constexpr DimensionType DIMENSION{};
1525 static constexpr MagnitudeType MAGNITUDE{};
1526 static const Quantity MIN;
1527 static const Quantity MAX;
1531 static const Quantity INF;
1532 static const Quantity QUIET_NAN;
1533
1534 template <typename OtherUnitT>
1535 [[nodiscard]] GREM_ALWAYS_INLINE static constexpr Quantity reinterpret(Quantity<1, OtherUnitT> other) {
1536 return Quantity{other._private_value};
1537 }
1538
1539 [[nodiscard]] GREM_ALWAYS_INLINE static constexpr Quantity reinterpret(floating_point auto value) {
1540 return Quantity{value};
1541 }
1542
1543 Scalar _private_value{};
1544
1545 [[nodiscard]] constexpr Scalar _private_getUnderlyingValue() const {
1546 return _private_value;
1547 }
1548
1549 GREM_ALWAYS_INLINE constexpr Quantity() = default;
1550 GREM_ALWAYS_INLINE constexpr Quantity(const Quantity&) = default;
1551 GREM_ALWAYS_INLINE constexpr Quantity(Quantity&&) noexcept = default;
1552 GREM_ALWAYS_INLINE constexpr Quantity& operator=(const Quantity&) = default;
1553 GREM_ALWAYS_INLINE constexpr Quantity& operator=(Quantity&&) noexcept = default;
1554 GREM_ALWAYS_INLINE constexpr ~Quantity() = default;
1555
1557
1558 GREM_ALWAYS_INLINE constexpr Quantity(floating_point auto value) requires(DIMENSION == DIMENSIONLESS && MagnitudeType::VALUE == 1.0l)
1559 : _private_value(static_cast<Scalar>(value)) {}
1560
1561 template <unit OtherUnitT>
1563 requires(!same_as<OtherUnitT, UnitT> && OtherUnitT::DIMENSION == DIMENSION &&
1564 (OtherUnitT::MagnitudeType::IS_ABSOLUTE == MagnitudeType::IS_ABSOLUTE || !OtherUnitT::MagnitudeType::IS_ABSOLUTE))
1565 : Quantity(Quantity::reinterpret(q * static_cast<Scalar>(OtherUnitT::MagnitudeType::VALUE / MagnitudeType::VALUE))) {}
1566
1567 template <typename Rep, typename Period>
1568 GREM_ALWAYS_INLINE constexpr Quantity(const DurationBase<Rep, Period>& duration) requires(DIMENSION == TIME && MagnitudeType::VALUE == 1.0l && !MagnitudeType::IS_ABSOLUTE)
1569 : _private_value(duration_cast<DurationBase<Scalar, Ratio<1, 1>>>(duration).count() / static_cast<Scalar>(MagnitudeType::VALUE)) {}
1570
1572 _private_value = Scalar{};
1573 return *this;
1574 }
1575
1576 [[nodiscard]] GREM_ALWAYS_INLINE constexpr bool operator==(const Quantity& other) const noexcept {
1577 return _private_value == other._private_value;
1578 }
1579
1580 template <typename OtherUnitT>
1581 [[nodiscard]] GREM_ALWAYS_INLINE constexpr bool operator==(const Quantity<1, OtherUnitT>& other) const noexcept requires(UnitT{} == OtherUnitT{}) {
1582 return _private_value == other._private_value;
1583 }
1584
1585 [[nodiscard]] GREM_ALWAYS_INLINE constexpr auto operator<=>(const Quantity& other) const noexcept {
1586 return _private_value <=> other._private_value;
1587 }
1588
1589 template <typename OtherUnitT>
1590 [[nodiscard]] GREM_ALWAYS_INLINE constexpr auto operator<=>(const Quantity<1, OtherUnitT>& other) const noexcept requires(UnitT{} == OtherUnitT{}) {
1591 return _private_value <=> other._private_value;
1592 }
1593
1594 template <arithmetic Arithmetic>
1595 [[nodiscard]] GREM_ALWAYS_INLINE constexpr bool operator==(Arithmetic other) const noexcept requires(DIMENSION == DIMENSIONLESS && MagnitudeType::VALUE == 1.0l) {
1596 return _private_value == static_cast<Scalar>(other);
1597 }
1598
1599 template <arithmetic Arithmetic>
1600 [[nodiscard]] GREM_ALWAYS_INLINE constexpr auto operator<=>(Arithmetic other) const noexcept requires(DIMENSION == DIMENSIONLESS && MagnitudeType::VALUE == 1.0l) {
1601 return _private_value <=> static_cast<Scalar>(other);
1602 }
1603
1604 [[nodiscard]] GREM_ALWAYS_INLINE constexpr bool operator==(Zero) const noexcept {
1605 return *this == Quantity{};
1606 }
1607
1608 [[nodiscard]] GREM_ALWAYS_INLINE constexpr auto operator<=>(Zero) const noexcept {
1609 return *this <=> Quantity{};
1610 }
1611
1612 template <typename Rep, typename Period>
1613 [[nodiscard]] GREM_ALWAYS_INLINE constexpr bool operator==(const DurationBase<Rep, Period>& other) const noexcept requires(DIMENSION == TIME && !MagnitudeType::IS_ABSOLUTE) {
1614 if constexpr (floating_point<Rep>) {
1615 return DurationBase<Rep, Ratio<1, 1>>{*this} == duration_cast<DurationBase<Rep, Ratio<1, 1>>>(other);
1616 } else {
1617 return Duration{*this} == duration_cast<Duration>(other);
1618 }
1619 }
1620
1621 template <typename Rep, typename Period>
1622 [[nodiscard]] GREM_ALWAYS_INLINE constexpr auto operator<=>(const DurationBase<Rep, Period>& other) const noexcept requires(DIMENSION == TIME && !MagnitudeType::IS_ABSOLUTE) {
1623 if constexpr (floating_point<Rep>) {
1624 return DurationBase<Rep, Ratio<1, 1>>{*this} <=> duration_cast<DurationBase<Rep, Ratio<1, 1>>>(other);
1625 } else {
1626 return Duration{*this} <=> duration_cast<Duration>(other);
1627 }
1628 }
1629
1630 GREM_ALWAYS_INLINE constexpr operator float() const requires(DIMENSION == DIMENSIONLESS && MagnitudeType::VALUE == 1.0l) {
1631 return static_cast<float>(_private_value);
1632 }
1633
1634 GREM_ALWAYS_INLINE constexpr operator double() const requires(DIMENSION == DIMENSIONLESS && MagnitudeType::VALUE == 1.0l) {
1635 return static_cast<double>(_private_value);
1636 }
1637
1638 GREM_ALWAYS_INLINE constexpr operator DurationBase<float, Ratio<1, 1>>() const requires(DIMENSION == TIME && !MagnitudeType::IS_ABSOLUTE) {
1639 return DurationBase<float, Ratio<1, 1>>{_private_value * static_cast<Scalar>(MagnitudeType::VALUE)};
1640 }
1641
1642 GREM_ALWAYS_INLINE constexpr operator DurationBase<double, Ratio<1, 1>>() const requires(DIMENSION == TIME && !MagnitudeType::IS_ABSOLUTE) {
1643 return DurationBase<double, Ratio<1, 1>>{_private_value * static_cast<Scalar>(MagnitudeType::VALUE)};
1644 }
1645
1646 GREM_ALWAYS_INLINE constexpr operator Duration() const requires(DIMENSION == TIME && !MagnitudeType::IS_ABSOLUTE) {
1647 return duration_cast<Duration>(DurationBase<Scalar, Ratio<1, 1>>{_private_value * static_cast<Scalar>(MagnitudeType::VALUE)});
1648 }
1649
1650 template <unit OtherUnitT>
1651 [[nodiscard]] GREM_ALWAYS_INLINE constexpr Quantity<1, Unitless> in(OtherUnitT) const requires(OtherUnitT::DIMENSION == DIMENSION) {
1652 if constexpr (OtherUnitT::MagnitudeType::VALUE == MagnitudeType::VALUE) {
1653 return Quantity<1, Unitless>{_private_value};
1654 } else {
1655 constexpr Scalar factor = static_cast<Scalar>(MagnitudeType::VALUE / OtherUnitT::MagnitudeType::VALUE);
1656 return _private_getUnderlyingValue() * factor;
1657 }
1658 }
1659
1660 template <unit OtherUnitT>
1661 [[nodiscard]] GREM_ALWAYS_INLINE constexpr Quantity<1, OtherUnitT> as(OtherUnitT) const
1662 requires(OtherUnitT::DIMENSION == DIMENSION && (OtherUnitT::MagnitudeType::IS_ABSOLUTE == MagnitudeType::IS_ABSOLUTE || OtherUnitT::MagnitudeType::IS_ABSOLUTE)) {
1663 return *this;
1664 }
1665
1666 [[nodiscard]] GREM_ALWAYS_INLINE constexpr size_t size() const noexcept {
1667 return 1;
1668 }
1669
1670 [[nodiscard]] GREM_ALWAYS_INLINE size_t getMinIndex() const {
1671 return 0;
1672 }
1673
1674 [[nodiscard]] GREM_ALWAYS_INLINE size_t getMaxIndex() const {
1675 return 0;
1676 }
1677
1678private:
1679 template <size_t OtherN, typename OtherUnitT>
1680 friend struct Quantity;
1681
1682 GREM_ALWAYS_INLINE constexpr explicit Quantity(int value) requires(DIMENSION != DIMENSIONLESS || MagnitudeType::VALUE != 1.0l)
1683 : _private_value(static_cast<Scalar>(value)) {}
1684
1685 GREM_ALWAYS_INLINE constexpr explicit Quantity(floating_point auto value) requires(DIMENSION != DIMENSIONLESS || MagnitudeType::VALUE != 1.0l)
1686 : _private_value(static_cast<Scalar>(value)) {}
1687};
1688
1689template <typename UnitT>
1691
1692template <typename UnitT>
1694
1695template <typename UnitT>
1697
1698template <typename UnitT>
1700
1701template <typename UnitT>
1703
1704template <typename UnitT>
1706
1707template <typename UnitT>
1709
1718template <size_t N, typename UnitT, size_t Index>
1720public:
1721 static_assert(N == 2 || N == 3);
1722 static_assert(Index < N);
1723
1724 using Unit = UnitT;
1725 using DimensionType = typename Unit::DimensionType;
1726 using MagnitudeType = typename Unit::MagnitudeType;
1727 static constexpr size_t RANK = 1;
1728 static constexpr Unit UNIT{};
1729 static constexpr DimensionType DIMENSION{};
1730 static constexpr MagnitudeType MAGNITUDE{};
1731
1734
1735 GREM_ALWAYS_INLINE constexpr operator Quantity<1, UnitT>() const noexcept {
1736 return getValue();
1737 }
1738
1739 GREM_ALWAYS_INLINE constexpr operator float() const requires(UnitT::DIMENSION == DIMENSIONLESS && UnitT::MagnitudeType::VALUE == 1.0l) {
1740 return static_cast<float>(getValue());
1741 }
1742
1743 GREM_ALWAYS_INLINE constexpr operator double() const requires(UnitT::DIMENSION == DIMENSIONLESS && UnitT::MagnitudeType::VALUE == 1.0l) {
1744 return static_cast<double>(getValue());
1745 }
1746
1747 GREM_ALWAYS_INLINE constexpr operator DurationBase<float, Ratio<1, 1>>() const requires(UnitT{} == SECONDS) {
1748 return getValue();
1749 }
1750
1751 GREM_ALWAYS_INLINE constexpr operator DurationBase<double, Ratio<1, 1>>() const requires(UnitT{} == SECONDS) {
1752 return getValue();
1753 }
1754
1755 GREM_ALWAYS_INLINE constexpr operator Duration() const requires(UnitT::DIMENSION == TIME && !UnitT::MagnitudeType::IS_ABSOLUTE) {
1756 return getValue();
1757 }
1758
1759 template <size_t OtherN, typename OtherUnitT, size_t OtherIndex>
1760 [[nodiscard]] GREM_ALWAYS_INLINE constexpr bool operator==(const ConstComponentProxy<OtherN, OtherUnitT, OtherIndex>& other) const noexcept requires(UnitT{} == OtherUnitT{}) {
1761 return getValue() == Quantity<1, OtherUnitT>{other};
1762 }
1763
1764 template <size_t OtherN, typename OtherUnitT, size_t OtherIndex>
1765 [[nodiscard]] GREM_ALWAYS_INLINE constexpr auto operator<=>(const ConstComponentProxy<OtherN, OtherUnitT, OtherIndex>& other) const noexcept requires(UnitT{} == OtherUnitT{}) {
1766 return getValue() <=> Quantity<1, OtherUnitT>{other};
1767 }
1768
1769 template <typename OtherUnitT>
1770 [[nodiscard]] GREM_ALWAYS_INLINE constexpr bool operator==(const Quantity<1, OtherUnitT>& other) const noexcept requires(UnitT{} == OtherUnitT{}) {
1771 return getValue() == other;
1772 }
1773
1774 template <typename OtherUnitT>
1775 [[nodiscard]] GREM_ALWAYS_INLINE constexpr auto operator<=>(const Quantity<1, OtherUnitT>& other) const noexcept requires(UnitT{} == OtherUnitT{}) {
1776 return getValue() <=> other;
1777 }
1778
1779 template <arithmetic Arithmetic>
1780 [[nodiscard]] GREM_ALWAYS_INLINE constexpr bool operator==(Arithmetic other) const noexcept requires(UnitT::DIMENSION == DIMENSIONLESS && UnitT::MagnitudeType::VALUE == 1.0l) {
1781 return getValue() == other;
1782 }
1783
1784 template <arithmetic Arithmetic>
1785 [[nodiscard]] GREM_ALWAYS_INLINE constexpr auto operator<=>(Arithmetic other) const noexcept requires(UnitT::DIMENSION == DIMENSIONLESS && UnitT::MagnitudeType::VALUE == 1.0l)
1786 {
1787 return getValue() <=> other;
1788 }
1789
1790 [[nodiscard]] GREM_ALWAYS_INLINE constexpr bool operator==(Zero) const noexcept {
1791 return getValue() == Quantity<1, UnitT>{};
1792 }
1793
1794 [[nodiscard]] GREM_ALWAYS_INLINE constexpr auto operator<=>(Zero) const noexcept {
1795 return getValue() <=> Quantity<1, UnitT>{};
1796 }
1797
1798 template <typename Rep, typename Period>
1799 [[nodiscard]] GREM_ALWAYS_INLINE constexpr bool operator==(const DurationBase<Rep, Period>& other) const noexcept
1800 requires(UnitT::DIMENSION == TIME && !UnitT::MagnitudeType::IS_ABSOLUTE) {
1801 return getValue() == other;
1802 }
1803
1804 template <typename Rep, typename Period>
1805 [[nodiscard]] GREM_ALWAYS_INLINE constexpr auto operator<=>(const DurationBase<Rep, Period>& other) const noexcept
1806 requires(UnitT::DIMENSION == TIME && !UnitT::MagnitudeType::IS_ABSOLUTE) {
1807 return getValue() <=> other;
1808 }
1809
1810 template <unit OtherUnitT>
1811 [[nodiscard]] GREM_ALWAYS_INLINE constexpr Quantity<1, Unitless> in(OtherUnitT unit) const requires(OtherUnitT::DIMENSION == DIMENSION) {
1812 return getValue().in(unit);
1813 }
1814
1815 template <unit OtherUnitT>
1816 [[nodiscard]] GREM_ALWAYS_INLINE constexpr Quantity<1, OtherUnitT> as(OtherUnitT unit) const
1817 requires(OtherUnitT::DIMENSION == DIMENSION && (OtherUnitT::MagnitudeType::IS_ABSOLUTE == MagnitudeType::IS_ABSOLUTE || OtherUnitT::MagnitudeType::IS_ABSOLUTE)) {
1818 return getValue().as(unit);
1819 }
1820
1821 [[nodiscard]] GREM_ALWAYS_INLINE constexpr size_t size() const noexcept {
1822 return 1;
1823 }
1824
1825 [[nodiscard]] GREM_ALWAYS_INLINE size_t getMinIndex() const {
1826 return 0;
1827 }
1828
1829 [[nodiscard]] GREM_ALWAYS_INLINE size_t getMaxIndex() const {
1830 return 0;
1831 }
1832
1833protected:
1835
1836 [[nodiscard]] GREM_ALWAYS_INLINE constexpr Quantity<1, UnitT> getValue() const noexcept {
1837#if defined(GREM_USE_SSE_INTRINSICS) && !defined(GREM_PHYSICS_USE_DOUBLE_PRECISION)
1838 if constexpr (N == 3) {
1839 if constexpr (Index == 0) {
1840 return Quantity<1, UnitT>::reinterpret(_mm_cvtss_f32(quantity->_private_value));
1841 } else {
1842 return Quantity<1, UnitT>::reinterpret(_mm_cvtss_f32(_mm_shuffle_ps(quantity->_private_value, quantity->_private_value, _MM_SHUFFLE(Index, Index, Index, Index))));
1843 }
1844 } else {
1845 return Quantity<1, UnitT>::reinterpret(quantity->_private_value[Index]);
1846 }
1847#else
1848 return Quantity<1, UnitT>::reinterpret(quantity->_private_value[Index]);
1849#endif
1850 }
1851};
1852
1861template <size_t N, typename UnitT, size_t Index>
1862class ComponentProxy : public ConstComponentProxy<N, UnitT, Index> {
1863public:
1866
1867 GREM_ALWAYS_INLINE ComponentProxy operator=( // NOLINT(misc-unconventional-assign-operator, cppcoreguidelines-c-copy-assignment-signature)
1868 Quantity<1, UnitT> value) const noexcept {
1869 Quantity<N, UnitT>* const quantity = const_cast<Quantity<N, UnitT>*>(this->quantity);
1870#if defined(GREM_USE_SSE_INTRINSICS) && !defined(GREM_PHYSICS_USE_DOUBLE_PRECISION)
1871 if constexpr (N == 3) {
1872 alignas(16) float components[4];
1873 _mm_store_ps(components, quantity->_private_value);
1874 components[Index] = value._private_value;
1875 if constexpr (Index == 2) {
1876 components[3] = value._private_value;
1877 }
1878 quantity->_private_value = _mm_load_ps(components);
1879 } else {
1880 quantity->_private_value[Index] = value._private_value;
1881 }
1882#else
1883 quantity->_private_value[Index] = value._private_value;
1884#endif
1885 return *this;
1886 }
1887
1888 GREM_ALWAYS_INLINE ComponentProxy operator=( // NOLINT(misc-unconventional-assign-operator, cppcoreguidelines-c-copy-assignment-signature)
1889 Zero) const noexcept {
1890 Quantity<N, UnitT>* const quantity = const_cast<Quantity<N, UnitT>*>(this->quantity);
1891#if defined(GREM_USE_SSE_INTRINSICS) && !defined(GREM_PHYSICS_USE_DOUBLE_PRECISION)
1892 if constexpr (N == 3) {
1893 alignas(16) float components[4];
1894 _mm_store_ps(components, quantity->_private_value);
1895 components[Index] = 0.0f;
1896 if constexpr (Index == 2) {
1897 components[3] = 0.0f;
1898 }
1899 quantity->_private_value = _mm_load_ps(components);
1900 } else {
1901 quantity->_private_value[Index] = 0.0f;
1902 }
1903#else
1904 quantity->_private_value[Index] = Scalar{};
1905#endif
1906 return *this;
1907 }
1908
1909 template <unit OtherUnitT>
1911 static_assert(OtherUnitT::DIMENSION == UnitT::DIMENSION && OtherUnitT::MagnitudeType::VALUE == UnitT::MagnitudeType::VALUE && !OtherUnitT::MagnitudeType::IS_ABSOLUTE,
1912 "Quantity of this unit cannot be added.");
1913 Quantity<N, UnitT>* const quantity = const_cast<Quantity<N, UnitT>*>(this->quantity);
1914#if defined(GREM_USE_SSE_INTRINSICS) && !defined(GREM_PHYSICS_USE_DOUBLE_PRECISION)
1915 if constexpr (N == 3) {
1916 alignas(16) float components[4];
1917 _mm_store_ps(components, quantity->_private_value);
1918 components[Index] += value._private_value;
1919 if constexpr (Index == 2) {
1920 components[3] += value._private_value;
1921 }
1922 quantity->_private_value = _mm_load_ps(components);
1923 } else {
1924 quantity->_private_value[Index] += value._private_value;
1925 }
1926#else
1927 quantity->_private_value[Index] += value._private_value;
1928#endif
1929 return *this;
1930 }
1931
1932 template <unit OtherUnitT>
1934 static_assert(OtherUnitT::DIMENSION == UnitT::DIMENSION && OtherUnitT::MagnitudeType::VALUE == UnitT::MagnitudeType::VALUE && !OtherUnitT::MagnitudeType::IS_ABSOLUTE,
1935 "Quantity of this unit cannot be subtracted.");
1936 Quantity<N, UnitT>* const quantity = const_cast<Quantity<N, UnitT>*>(this->quantity);
1937#if defined(GREM_USE_SSE_INTRINSICS) && !defined(GREM_PHYSICS_USE_DOUBLE_PRECISION)
1938 if constexpr (N == 3) {
1939 alignas(16) float components[4];
1940 _mm_store_ps(components, quantity->_private_value);
1941 components[Index] -= value._private_value;
1942 if constexpr (Index == 2) {
1943 components[3] -= value._private_value;
1944 }
1945 quantity->_private_value = _mm_load_ps(components);
1946 } else {
1947 quantity->_private_value[Index] -= value._private_value;
1948 }
1949#else
1950 quantity->_private_value[Index] -= value._private_value;
1951#endif
1952 return *this;
1953 }
1954
1956 Quantity<N, UnitT>* const quantity = const_cast<Quantity<N, UnitT>*>(this->quantity);
1957#if defined(GREM_USE_SSE_INTRINSICS) && !defined(GREM_PHYSICS_USE_DOUBLE_PRECISION)
1958 if constexpr (N == 3) {
1959 alignas(16) float components[4];
1960 _mm_store_ps(components, quantity->_private_value);
1961 components[Index] *= value;
1962 if constexpr (Index == 2) {
1963 components[3] *= value;
1964 }
1965 quantity->_private_value = _mm_load_ps(components);
1966 } else {
1967 quantity->_private_value[Index] *= value;
1968 }
1969#else
1970 quantity->_private_value[Index] *= value;
1971#endif
1972 return *this;
1973 }
1974
1976 Quantity<N, UnitT>* const quantity = const_cast<Quantity<N, UnitT>*>(this->quantity);
1977#if defined(GREM_USE_SSE_INTRINSICS) && !defined(GREM_PHYSICS_USE_DOUBLE_PRECISION)
1978 if constexpr (N == 3) {
1979 alignas(16) float components[4];
1980 _mm_store_ps(components, quantity->_private_value);
1981 components[Index] /= value;
1982 if constexpr (Index == 2) {
1983 components[3] /= value;
1984 }
1985 quantity->_private_value = _mm_load_ps(components);
1986 } else {
1987 quantity->_private_value[Index] /= value;
1988 }
1989#else
1990 quantity->_private_value[Index] /= value;
1991#endif
1992 return *this;
1993 }
1994};
1995
1996template <typename UnitT>
1997struct Quantity<2, UnitT> {
1999 using Unit = UnitT;
2000 using DimensionType = typename Unit::DimensionType;
2001 using MagnitudeType = typename Unit::MagnitudeType;
2002 static constexpr size_t RANK = 2;
2003 static constexpr Unit UNIT{};
2004 static constexpr DimensionType DIMENSION{};
2005 static constexpr MagnitudeType MAGNITUDE{};
2006 static const Quantity MIN;
2007 static const Quantity MAX;
2011 static const Quantity INF;
2012 static const Quantity QUIET_NAN;
2013
2014 template <typename OtherUnitT>
2015 [[nodiscard]] GREM_ALWAYS_INLINE static constexpr Quantity reinterpret(Quantity<2, OtherUnitT> other) {
2016 return Quantity{other._private_value};
2017 }
2018
2019 [[nodiscard]] GREM_ALWAYS_INLINE static constexpr Quantity reinterpret(vec<2, float> value) {
2020 return Quantity{value};
2021 }
2022
2023 [[nodiscard]] GREM_ALWAYS_INLINE static constexpr Quantity reinterpret(vec<2, double> value) {
2024 return Quantity{value};
2025 }
2026
2027 vec<2, Scalar> _private_value{};
2028
2029 [[nodiscard]] constexpr vec<2, Scalar> _private_getUnderlyingValue() const {
2030 return _private_value;
2031 }
2032
2033 GREM_ALWAYS_INLINE constexpr Quantity() = default;
2034 GREM_ALWAYS_INLINE constexpr Quantity(const Quantity&) = default;
2035 GREM_ALWAYS_INLINE constexpr Quantity(Quantity&&) noexcept = default;
2036 GREM_ALWAYS_INLINE constexpr Quantity& operator=(const Quantity&) = default;
2037 GREM_ALWAYS_INLINE constexpr Quantity& operator=(Quantity&&) noexcept = default;
2038 GREM_ALWAYS_INLINE constexpr ~Quantity() = default;
2039
2041
2042 GREM_ALWAYS_INLINE constexpr explicit Quantity(Component value)
2043 : Quantity(value, value) {}
2044
2046 : _private_value{x._private_value, y._private_value} {}
2047
2050
2053
2055
2056 GREM_ALWAYS_INLINE constexpr Quantity(vec<2, float> v) requires(DIMENSION == DIMENSIONLESS && MagnitudeType::VALUE == 1.0l)
2057 : Quantity(v.x, v.y) {}
2058
2059 GREM_ALWAYS_INLINE constexpr Quantity(vec<2, double> v) requires(DIMENSION == DIMENSIONLESS && MagnitudeType::VALUE == 1.0l)
2060 : Quantity(v.x, v.y) {}
2061
2062 template <unit OtherUnitT>
2064 requires(!same_as<OtherUnitT, UnitT> && OtherUnitT::DIMENSION == DIMENSION &&
2065 (OtherUnitT::MagnitudeType::IS_ABSOLUTE == MagnitudeType::IS_ABSOLUTE || !OtherUnitT::MagnitudeType::IS_ABSOLUTE))
2066 : Quantity(Quantity::reinterpret(q * static_cast<Scalar>(OtherUnitT::MagnitudeType::VALUE / MagnitudeType::VALUE))) {}
2067
2069 _private_value = {};
2070 return *this;
2071 }
2072
2073 [[nodiscard]] GREM_ALWAYS_INLINE constexpr bool operator==(const Quantity& other) const noexcept {
2074 return _private_value == other._private_value;
2075 }
2076
2077 template <typename OtherUnitT>
2078 [[nodiscard]] GREM_ALWAYS_INLINE constexpr bool operator==(const Quantity<2, OtherUnitT>& other) const noexcept requires(UnitT{} == OtherUnitT{}) {
2079 return _private_value == other._private_value;
2080 }
2081
2082 [[nodiscard]] GREM_ALWAYS_INLINE constexpr bool operator==(Zero) const noexcept {
2083 return *this == Quantity{};
2084 }
2085
2086 template <size_t Index>
2088 (*this)[Swizzle] = value;
2089 }
2090
2091 template <size_t Index>
2093 (*this)[Swizzle] = 0;
2094 }
2095
2097 set(X, x);
2098 }
2099
2101 setX(Component{});
2102 }
2103
2105 set(Y, y);
2106 }
2107
2109 setY(Component{});
2110 }
2111
2112 template <size_t Index>
2113 [[nodiscard]] GREM_ALWAYS_INLINE Component get(ComponentSwizzle<Index> Swizzle) const noexcept {
2114 return (*this)[Swizzle];
2115 }
2116
2117 [[nodiscard]] GREM_ALWAYS_INLINE Component get(Zero) const noexcept {
2118 return 0;
2119 }
2120
2121 template <size_t IndexX, size_t IndexY>
2123 return {get(SwizzleX), get(SwizzleY)};
2124 }
2125
2126 template <size_t IndexX>
2128 return {get(SwizzleX), 0};
2129 }
2130
2131 template <size_t IndexY>
2133 return {0, get(SwizzleY)};
2134 }
2135
2136 [[nodiscard]] GREM_ALWAYS_INLINE Quantity<2, UnitT> get(Zero, Zero) const noexcept {
2137 return {};
2138 }
2139
2140 template <size_t IndexX, size_t IndexY, size_t IndexZ>
2142 ComponentSwizzle<IndexZ> SwizzleZ) const noexcept {
2143 return {get(SwizzleX), get(SwizzleY), get(SwizzleZ)};
2144 }
2145
2146 template <size_t IndexX, size_t IndexY>
2148 return {get(SwizzleX, SwizzleY), 0};
2149 }
2150
2151 template <size_t IndexX, size_t IndexZ>
2153 return {get(SwizzleX), 0, get(SwizzleZ)};
2154 }
2155
2156 template <size_t IndexY, size_t IndexZ>
2158 return {0, get(SwizzleY), get(SwizzleZ)};
2159 }
2160
2161 template <size_t IndexX>
2163 return {get(SwizzleX), 0, 0};
2164 }
2165
2166 template <size_t IndexY>
2168 return {0, get(SwizzleY), 0};
2169 }
2170
2171 template <size_t IndexZ>
2173 return {0, 0, get(SwizzleZ)};
2174 }
2175
2176 [[nodiscard]] GREM_ALWAYS_INLINE Quantity<3, UnitT> get(Zero, Zero, Zero) const noexcept {
2177 return {};
2178 }
2179
2180 [[nodiscard]] GREM_ALWAYS_INLINE Component getX() const noexcept {
2181 return get(X);
2182 }
2183
2184 [[nodiscard]] GREM_ALWAYS_INLINE Component getY() const noexcept {
2185 return get(Y);
2186 }
2187
2188 template <size_t Index>
2190 static_assert(Index < RANK, "Swizzle component index out of range.");
2191 return *this;
2192 }
2193
2194 template <size_t Index>
2196 static_assert(Index < RANK, "Swizzle component index out of range.");
2197 return *this;
2198 }
2199
2200 template <size_t Index>
2202 static_assert(Index < RANK, "Swizzle component index out of range.");
2203 return *this;
2204 }
2205
2206 template <size_t Index>
2208 static_assert(Index < RANK, "Swizzle component index out of range.");
2209 return *this;
2210 }
2211
2212 GREM_ALWAYS_INLINE constexpr operator vec<2, float>() const requires(DIMENSION == DIMENSIONLESS && MagnitudeType::VALUE == 1.0l) {
2213 return vec<2, float>{static_cast<float>(getX()), static_cast<float>(getY())};
2214 }
2215
2216 GREM_ALWAYS_INLINE constexpr operator vec<2, double>() const requires(DIMENSION == DIMENSIONLESS && MagnitudeType::VALUE == 1.0l) {
2217 return vec<2, double>{static_cast<double>(getX()), static_cast<double>(getY())};
2218 }
2219
2220 template <unit OtherUnitT>
2221 [[nodiscard]] GREM_ALWAYS_INLINE Quantity<2, Unitless> in(OtherUnitT) const requires(OtherUnitT::DIMENSION == DIMENSION) {
2222 if constexpr (OtherUnitT::MagnitudeType::VALUE == MagnitudeType::VALUE) {
2223 return Quantity<2, Unitless>{_private_value};
2224 } else {
2225 constexpr Scalar factor = static_cast<Scalar>(MagnitudeType::VALUE / OtherUnitT::MagnitudeType::VALUE);
2226 return _private_getUnderlyingValue() * factor;
2227 }
2228 }
2229
2230 template <unit OtherUnitT>
2231 [[nodiscard]] GREM_ALWAYS_INLINE constexpr Quantity<2, OtherUnitT> as(OtherUnitT) const
2232 requires(OtherUnitT::DIMENSION == DIMENSION && (OtherUnitT::MagnitudeType::IS_ABSOLUTE == MagnitudeType::IS_ABSOLUTE || OtherUnitT::MagnitudeType::IS_ABSOLUTE)) {
2233 return *this;
2234 }
2235
2236 [[nodiscard]] GREM_ALWAYS_INLINE constexpr size_t size() const noexcept {
2237 return 2;
2238 }
2239
2240 [[nodiscard]] GREM_ALWAYS_INLINE size_t getMinIndex() const {
2241 const Component x = getX();
2242 const Component y = getY();
2243 return static_cast<size_t>(y < x);
2244 }
2245
2246 [[nodiscard]] GREM_ALWAYS_INLINE size_t getMaxIndex() const {
2247 const Component x = getX();
2248 const Component y = getY();
2249 return static_cast<size_t>(y > x);
2250 }
2251
2252private:
2253 template <size_t OtherN, typename OtherUnitT>
2254 friend struct Quantity;
2255
2256 template <size_t OtherN, typename OtherUnitT, size_t Index>
2258
2259 template <size_t OtherN, typename OtherUnitT, size_t Index>
2260 friend class ComponentProxy;
2261
2262 GREM_ALWAYS_INLINE constexpr explicit Quantity(vec<2, float> value) requires(DIMENSION != DIMENSIONLESS || MagnitudeType::VALUE != 1.0l)
2263 : _private_value(value) {}
2264
2265 GREM_ALWAYS_INLINE constexpr explicit Quantity(vec<2, double> value) requires(DIMENSION != DIMENSIONLESS || MagnitudeType::VALUE != 1.0l)
2266 : _private_value(value) {}
2267};
2268
2269template <typename UnitT>
2271
2272template <typename UnitT>
2274
2275template <typename UnitT>
2277
2278template <typename UnitT>
2280
2281template <typename UnitT>
2283
2284template <typename UnitT>
2286
2287template <typename UnitT>
2289
2290template <typename UnitT>
2291struct
2292#ifndef GREM_PHYSICS_USE_DOUBLE_PRECISION
2293 alignas(16)
2294#endif
2297 using Unit = UnitT;
2298 using DimensionType = typename Unit::DimensionType;
2299 using MagnitudeType = typename Unit::MagnitudeType;
2300 static constexpr size_t RANK = 3;
2301 static constexpr Unit UNIT{};
2302 static constexpr DimensionType DIMENSION{};
2303 static constexpr MagnitudeType MAGNITUDE{};
2304 static const Quantity ZERO;
2305 static const Quantity MIN;
2306 static const Quantity MAX;
2310 static const Quantity INF;
2311 static const Quantity QUIET_NAN;
2312
2313 template <typename OtherUnitT>
2314 [[nodiscard]] GREM_ALWAYS_INLINE static constexpr Quantity reinterpret(Quantity<3, OtherUnitT> other) {
2315 return Quantity{other._private_value};
2316 }
2317
2318 [[nodiscard]] GREM_ALWAYS_INLINE static constexpr Quantity reinterpret(vec<3, float> value) {
2319 return Quantity{value};
2320 }
2321
2322 [[nodiscard]] GREM_ALWAYS_INLINE static constexpr Quantity reinterpret(vec<3, double> value) {
2323 return Quantity{value};
2324 }
2325
2326#if defined(GREM_USE_SSE_INTRINSICS) && !defined(GREM_PHYSICS_USE_DOUBLE_PRECISION)
2327 [[nodiscard]] GREM_ALWAYS_INLINE static constexpr Quantity reinterpret(__m128 value) {
2328 return Quantity{value};
2329 }
2330
2331 __m128 _private_value{};
2332#else
2333 vec<3, Scalar> _private_value{};
2334#endif
2335
2336 [[nodiscard]] constexpr vec<3, Scalar> _private_getUnderlyingValue() const {
2337#if defined(GREM_USE_SSE_INTRINSICS) && !defined(GREM_PHYSICS_USE_DOUBLE_PRECISION)
2338 alignas(16) float components[4]{};
2339 _mm_store_ps(components, _private_value);
2340 return {components[0], components[1], components[2]};
2341#else
2342 return _private_value;
2343#endif
2344 }
2345
2346 GREM_ALWAYS_INLINE constexpr Quantity() = default;
2347 GREM_ALWAYS_INLINE constexpr Quantity(const Quantity&) = default;
2348 GREM_ALWAYS_INLINE constexpr Quantity(Quantity&&) noexcept = default;
2349 GREM_ALWAYS_INLINE constexpr Quantity& operator=(const Quantity&) = default;
2350 GREM_ALWAYS_INLINE constexpr Quantity& operator=(Quantity&&) noexcept = default;
2351 GREM_ALWAYS_INLINE constexpr ~Quantity() = default;
2352
2354
2355 GREM_ALWAYS_INLINE constexpr explicit Quantity(Component value)
2356 : Quantity(value, value, value) {}
2357
2359#if defined(GREM_USE_SSE_INTRINSICS) && !defined(GREM_PHYSICS_USE_DOUBLE_PRECISION)
2360 : _private_value{x._private_value, y._private_value, z._private_value, z._private_value}
2361#else
2362 : _private_value{x._private_value, y._private_value, z._private_value}
2363#endif
2364 {
2365 }
2366
2369
2372
2375
2378
2381
2384
2387
2388 GREM_ALWAYS_INLINE constexpr Quantity(vec<3, float> v) requires(DIMENSION == DIMENSIONLESS && MagnitudeType::VALUE == 1.0l)
2389 : Quantity(v.x, v.y, v.z) {}
2390
2391 GREM_ALWAYS_INLINE constexpr Quantity(vec<3, double> v) requires(DIMENSION == DIMENSIONLESS && MagnitudeType::VALUE == 1.0l)
2392 : Quantity(v.x, v.y, v.z) {}
2393
2394 template <unit OtherUnitT>
2396 requires(!same_as<OtherUnitT, UnitT> && OtherUnitT::DIMENSION == DIMENSION &&
2397 (OtherUnitT::MagnitudeType::IS_ABSOLUTE == MagnitudeType::IS_ABSOLUTE || !OtherUnitT::MagnitudeType::IS_ABSOLUTE))
2398 : Quantity(Quantity::reinterpret(q * static_cast<Scalar>(OtherUnitT::MagnitudeType::VALUE / MagnitudeType::VALUE))) {}
2399
2401 : Quantity(xy.getX(), xy.getY(), z) {}
2402
2405
2407 : Quantity(x, yz.getX(), yz.getY()) {}
2408
2411
2413#if defined(GREM_USE_SSE_INTRINSICS) && !defined(GREM_PHYSICS_USE_DOUBLE_PRECISION)
2414 _private_value = __m128{};
2415#else
2416 _private_value = {};
2417#endif
2418 return *this;
2419 }
2420
2421 [[nodiscard]] GREM_ALWAYS_INLINE constexpr bool operator==(const Quantity& other) const noexcept {
2422#if defined(GREM_USE_SSE_INTRINSICS) && !defined(GREM_PHYSICS_USE_DOUBLE_PRECISION)
2423 return (_mm_movemask_ps(_mm_cmpeq_ps(_private_value, other._private_value)) & 0b111) == 0b111;
2424#else
2425 return _private_value == other._private_value;
2426#endif
2427 }
2428
2429 template <typename OtherUnitT>
2430 [[nodiscard]] GREM_ALWAYS_INLINE constexpr bool operator==(const Quantity<3, OtherUnitT>& other) const noexcept requires(UnitT{} == OtherUnitT{}) {
2431#if defined(GREM_USE_SSE_INTRINSICS) && !defined(GREM_PHYSICS_USE_DOUBLE_PRECISION)
2432 return (_mm_movemask_ps(_mm_cmpeq_ps(_private_value, other._private_value)) & 0b111) == 0b111;
2433#else
2434 return _private_value == other._private_value;
2435#endif
2436 }
2437
2438 [[nodiscard]] GREM_ALWAYS_INLINE constexpr bool operator==(Zero) const noexcept {
2439 return *this == Quantity{};
2440 }
2441
2442 template <size_t Index>
2444 (*this)[Swizzle] = value;
2445 }
2446
2447 template <size_t Index>
2449 set(Swizzle, Component{});
2450 }
2451
2453 set(X, x);
2454 }
2455
2457 setX(Component{});
2458 }
2459
2461 set(Y, y);
2462 }
2463
2465 setY(Component{});
2466 }
2467
2469 set(Z, z);
2470 }
2471
2473 setZ(Component{});
2474 }
2475
2476 template <size_t Index>
2477 [[nodiscard]] GREM_ALWAYS_INLINE Component get(ComponentSwizzle<Index> Swizzle) const noexcept {
2478 return (*this)[Swizzle];
2479 }
2480
2481 [[nodiscard]] GREM_ALWAYS_INLINE Component get(Zero) const noexcept {
2482 return 0;
2483 }
2484
2485 template <size_t IndexX, size_t IndexY>
2487 return {get(SwizzleX), get(SwizzleY)};
2488 }
2489
2490 template <size_t IndexX>
2492 return {get(SwizzleX), 0};
2493 }
2494
2495 template <size_t IndexY>
2497 return {0, get(SwizzleY)};
2498 }
2499
2500 [[nodiscard]] GREM_ALWAYS_INLINE Quantity<2, UnitT> get(Zero, Zero) const noexcept {
2501 return {};
2502 }
2503
2504 template <size_t IndexX, size_t IndexY, size_t IndexZ>
2505 [[nodiscard]] GREM_ALWAYS_INLINE Quantity<3, UnitT> get([[maybe_unused]] ComponentSwizzle<IndexX> SwizzleX, [[maybe_unused]] ComponentSwizzle<IndexY> SwizzleY,
2506 [[maybe_unused]] ComponentSwizzle<IndexZ> SwizzleZ) const noexcept {
2507#if defined(GREM_USE_SSE_INTRINSICS) && !defined(GREM_PHYSICS_USE_DOUBLE_PRECISION)
2508 return Quantity<3, UnitT>::reinterpret(_mm_shuffle_ps(_private_value, _private_value, _MM_SHUFFLE(IndexZ, IndexZ, IndexY, IndexX)));
2509#else
2510 return {get(SwizzleX), get(SwizzleY), get(SwizzleZ)};
2511#endif
2512 }
2513
2514 template <size_t IndexX, size_t IndexY>
2516 return {get(SwizzleX, SwizzleY), 0};
2517 }
2518
2519 template <size_t IndexX, size_t IndexZ>
2521 return {get(SwizzleX), 0, get(SwizzleZ)};
2522 }
2523
2524 template <size_t IndexY, size_t IndexZ>
2526 return {0, get(SwizzleY), get(SwizzleZ)};
2527 }
2528
2529 template <size_t IndexX>
2531 return {get(SwizzleX), 0, 0};
2532 }
2533
2534 template <size_t IndexY>
2536 return {0, get(SwizzleY), 0};
2537 }
2538
2539 template <size_t IndexZ>
2541 return {0, 0, get(SwizzleZ)};
2542 }
2543
2544 [[nodiscard]] GREM_ALWAYS_INLINE Quantity<3, UnitT> get(Zero, Zero, Zero) const noexcept {
2545 return {};
2546 }
2547
2548 [[nodiscard]] GREM_ALWAYS_INLINE Component getX() const noexcept {
2549 return get(X);
2550 }
2551
2552 [[nodiscard]] GREM_ALWAYS_INLINE Component getY() const noexcept {
2553 return get(Y);
2554 }
2555
2556 [[nodiscard]] GREM_ALWAYS_INLINE Component getZ() const noexcept {
2557 return get(Z);
2558 }
2559
2560 template <size_t Index>
2562 static_assert(Index < RANK, "Swizzle component index out of range.");
2563 return *this;
2564 }
2565
2566 template <size_t Index>
2568 static_assert(Index < RANK, "Swizzle component index out of range.");
2569 return *this;
2570 }
2571
2572 template <size_t Index>
2574 static_assert(Index < RANK, "Swizzle component index out of range.");
2575 return *this;
2576 }
2577
2578 template <size_t Index>
2580 static_assert(Index < RANK, "Swizzle component index out of range.");
2581 return *this;
2582 }
2583
2584 GREM_ALWAYS_INLINE constexpr operator vec<3, float>() const requires(DIMENSION == DIMENSIONLESS && MagnitudeType::VALUE == 1.0l) {
2585 return vec<3, float>{static_cast<float>(getX()), static_cast<float>(getY()), static_cast<float>(getZ())};
2586 }
2587
2588 GREM_ALWAYS_INLINE constexpr operator vec<3, double>() const requires(DIMENSION == DIMENSIONLESS && MagnitudeType::VALUE == 1.0l) {
2589 return vec<3, double>{static_cast<double>(getX()), static_cast<double>(getY()), static_cast<double>(getZ())};
2590 }
2591
2592 template <unit OtherUnitT>
2593 [[nodiscard]] GREM_ALWAYS_INLINE Quantity<3, Unitless> in(OtherUnitT) const requires(OtherUnitT::DIMENSION == DIMENSION) {
2594 if constexpr (OtherUnitT::MagnitudeType::VALUE == MagnitudeType::VALUE) {
2595 return Quantity<3, Unitless>{_private_value};
2596 } else {
2597 constexpr Scalar factor = static_cast<Scalar>(MagnitudeType::VALUE / OtherUnitT::MagnitudeType::VALUE);
2598 return _private_getUnderlyingValue() * factor;
2599 }
2600 }
2601
2602 template <unit OtherUnitT>
2603 [[nodiscard]] GREM_ALWAYS_INLINE constexpr Quantity<3, OtherUnitT> as(OtherUnitT) const
2604 requires(OtherUnitT::DIMENSION == DIMENSION && (OtherUnitT::MagnitudeType::IS_ABSOLUTE == MagnitudeType::IS_ABSOLUTE || OtherUnitT::MagnitudeType::IS_ABSOLUTE)) {
2605 return *this;
2606 }
2607
2608 [[nodiscard]] GREM_ALWAYS_INLINE constexpr size_t size() const noexcept {
2609 return 3;
2610 }
2611
2612 [[nodiscard]] GREM_ALWAYS_INLINE size_t getMinIndex() const {
2613 size_t result = 0;
2614 Component minValue = getX();
2615 const Component y = getY();
2616 if (y < minValue) {
2617 result = 1;
2618 minValue = y;
2619 }
2620 const Component z = getZ();
2621 if (z < minValue) {
2622 result = 2;
2623 }
2624 return result;
2625 }
2626
2627 [[nodiscard]] GREM_ALWAYS_INLINE size_t getMaxIndex() const {
2628 size_t result = 0;
2629 Component maxValue = getX();
2630 const Component y = getY();
2631 if (y > maxValue) {
2632 result = 1;
2633 maxValue = y;
2634 }
2635 const Component z = getZ();
2636 if (z > maxValue) {
2637 result = 2;
2638 }
2639 return result;
2640 }
2641
2642private:
2643 template <size_t OtherN, typename OtherUnitT>
2644 friend struct Quantity;
2645
2646 template <size_t OtherN, typename OtherUnitT, size_t Index>
2648
2649 template <size_t OtherN, typename OtherUnitT, size_t Index>
2650 friend class ComponentProxy;
2651
2652#if defined(GREM_USE_SSE_INTRINSICS) && !defined(GREM_PHYSICS_USE_DOUBLE_PRECISION)
2653 GREM_ALWAYS_INLINE constexpr explicit Quantity(__m128 value)
2654 : _private_value(value) {}
2655
2656 GREM_ALWAYS_INLINE constexpr explicit Quantity(vec<3, float> value) requires(DIMENSION != DIMENSIONLESS || MagnitudeType::VALUE != 1.0l)
2657 : _private_value{static_cast<Scalar>(value.x), static_cast<Scalar>(value.y), static_cast<Scalar>(value.z), static_cast<Scalar>(value.z)} {}
2658
2659 GREM_ALWAYS_INLINE constexpr explicit Quantity(vec<3, double> value) requires(DIMENSION != DIMENSIONLESS || MagnitudeType::VALUE != 1.0l)
2660 : _private_value{static_cast<Scalar>(value.x), static_cast<Scalar>(value.y), static_cast<Scalar>(value.z), static_cast<Scalar>(value.z)} {}
2661#else
2662 GREM_ALWAYS_INLINE constexpr explicit Quantity(vec<3, float> value) requires(DIMENSION != DIMENSIONLESS || MagnitudeType::VALUE != 1.0l)
2663 : _private_value(value) {}
2664
2665 GREM_ALWAYS_INLINE constexpr explicit Quantity(vec<3, double> value) requires(DIMENSION != DIMENSIONLESS || MagnitudeType::VALUE != 1.0l)
2666 : _private_value(value) {}
2667#endif
2668};
2669
2670template <typename UnitT>
2672
2673template <typename UnitT>
2675
2676template <typename UnitT>
2678
2679template <typename UnitT>
2681
2682template <typename UnitT>
2684
2685template <typename UnitT>
2687
2688template <typename UnitT>
2690
2691namespace detail {
2692
2693template <size_t N, typename T>
2694consteval void derivedFromQuantityTest(const Quantity<N, T>&);
2695
2696template <typename T>
2697concept derived_from_quantity = requires(const T t) { derivedFromQuantityTest(t); };
2698
2699template <size_t N, typename UnitT>
2700[[nodiscard]] GREM_ALWAYS_INLINE constexpr Quantity<N, UnitT> GREM_VECTORCALL toQuantity(Quantity<N, UnitT> value) noexcept {
2701 return value;
2702}
2703
2704template <size_t N, typename UnitT, size_t Index>
2705[[nodiscard]] GREM_ALWAYS_INLINE constexpr Quantity<1, UnitT> GREM_VECTORCALL toQuantity(ConstComponentProxy<N, UnitT, Index> value) noexcept {
2706 return value;
2707}
2708
2709template <size_t N, typename UnitT, size_t Index>
2710[[nodiscard]] GREM_ALWAYS_INLINE constexpr Quantity<1, UnitT> GREM_VECTORCALL toQuantity(ComponentProxy<N, UnitT, Index> value) noexcept {
2711 return value;
2712}
2713
2714[[nodiscard]] GREM_ALWAYS_INLINE constexpr Quantity<1, Unitless> GREM_VECTORCALL toQuantity(floating_point auto value) noexcept {
2715 return value;
2716}
2717
2718[[nodiscard]] GREM_ALWAYS_INLINE constexpr Quantity<2, Unitless> GREM_VECTORCALL toQuantity(vec<2, float> value) noexcept {
2719 return value;
2720}
2721
2722[[nodiscard]] GREM_ALWAYS_INLINE constexpr Quantity<2, Unitless> GREM_VECTORCALL toQuantity(vec<2, double> value) noexcept {
2723 return value;
2724}
2725
2726[[nodiscard]] GREM_ALWAYS_INLINE constexpr Quantity<3, Unitless> GREM_VECTORCALL toQuantity(vec<3, float> value) noexcept {
2727 return value;
2728}
2729
2730[[nodiscard]] GREM_ALWAYS_INLINE constexpr Quantity<3, Unitless> GREM_VECTORCALL toQuantity(vec<3, double> value) noexcept {
2731 return value;
2732}
2733
2734template <typename Rep, typename Period>
2735[[nodiscard]] GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL toQuantity(const DurationBase<Rep, Period>& value) noexcept {
2736 return Quantity<1, MultipleOf<Seconds, static_cast<long double>(Period::num) / static_cast<long double>(Period::den)>>{value};
2737}
2738
2739[[nodiscard]] GREM_ALWAYS_INLINE constexpr Quantity<1, Seconds> GREM_VECTORCALL toQuantity(Duration value) noexcept {
2740 return value;
2741}
2742
2743template <typename T>
2744concept quantity_convertible = requires(const T t) { toQuantity(t); };
2745
2746template <typename T>
2747inline constexpr size_t quantity_rank_v = decltype(toQuantity(std::declval<T>()))::RANK;
2748
2749template <typename T>
2750using unit_type_t = typename decltype(toQuantity(std::declval<T>()))::Unit;
2751
2752template <typename T>
2753struct is_quantity_or_component_proxy : std::bool_constant<derived_from_quantity<T>> {};
2754
2755template <size_t N, typename UnitT, size_t Index>
2756struct is_quantity_or_component_proxy<ConstComponentProxy<N, UnitT, Index>> : std::true_type {};
2757
2758template <size_t N, typename UnitT, size_t Index>
2759struct is_quantity_or_component_proxy<ComponentProxy<N, UnitT, Index>> : std::true_type {};
2760
2761template <typename T>
2762inline constexpr bool is_quantity_or_component_proxy_v = is_quantity_or_component_proxy<T>::value;
2763
2764template <typename T>
2765concept quantity_unary_operand = is_quantity_or_component_proxy_v<std::remove_cvref_t<T>>;
2766
2767template <typename T>
2768concept quantity_binary_operand_a = quantity_convertible<T>;
2769
2770template <typename T, typename A>
2771concept quantity_binary_operand_b = quantity_unary_operand<T> || (quantity_unary_operand<A> && quantity_convertible<T>);
2772
2773template <typename T>
2774concept quantity_ternary_operand_a = quantity_convertible<T>;
2775
2776template <typename T, typename A>
2777concept quantity_ternary_operand_b = quantity_convertible<T>;
2778
2779template <typename T, typename A, typename B>
2780concept quantity_ternary_operand_c = quantity_unary_operand<T> || ((quantity_unary_operand<A> || quantity_unary_operand<B>) && quantity_convertible<T>);
2781
2782} // namespace detail
2783
2791template <size_t N>
2792using Mask = std::conditional_t<N == 1, bool, vec<N, bool>>;
2796
2804template <size_t N>
2805using AngularMask = std::conditional_t<N == 3, Mask<N>, Mask<1>>;
2808
2809using grem::clamp;
2810using grem::max;
2811using grem::min;
2812using grem::select;
2813
2814template <size_t N, typename UnitT, unit OtherUnitT>
2815[[nodiscard]] GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL operator*(Quantity<N, UnitT> value, OtherUnitT) {
2816 return Quantity<N, Product<UnitT, OtherUnitT>>::reinterpret(value);
2817}
2818
2819template <unit OtherUnitT>
2820[[nodiscard]] GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL operator*(detail::quantity_convertible auto value, OtherUnitT unit) {
2821 return detail::toQuantity(value) * unit;
2822}
2823
2824template <unit OtherUnitT, size_t N, typename UnitT>
2825[[nodiscard]] GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL operator*(OtherUnitT, Quantity<N, UnitT> value) {
2826 return Quantity<N, Product<OtherUnitT, UnitT>>::reinterpret(value);
2827}
2828
2829template <unit OtherUnitT>
2830[[nodiscard]] GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL operator*(OtherUnitT unit, detail::quantity_convertible auto value) {
2831 return unit * detail::toQuantity(value);
2832}
2833
2834template <size_t N, typename UnitT, unit OtherUnitT>
2835[[nodiscard]] GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL operator/(Quantity<N, UnitT> value, OtherUnitT) {
2836 return Quantity<N, Quotient<UnitT, OtherUnitT>>::reinterpret(value);
2837}
2838
2839template <unit OtherUnitT>
2840[[nodiscard]] GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL operator/(detail::quantity_convertible auto value, OtherUnitT unit) {
2841 return detail::toQuantity(value) / unit;
2842}
2843
2844template <unit OtherUnitT, size_t N, typename UnitT>
2845[[nodiscard]] GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL operator/(OtherUnitT, Quantity<N, UnitT> value) {
2846 return Quantity<N, Quotient<OtherUnitT, UnitT>>::reinterpret(Scalar{1} / value);
2847}
2848
2849template <unit OtherUnitT>
2850[[nodiscard]] GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL operator/(OtherUnitT unit, detail::quantity_convertible auto value) {
2851 return unit / detail::toQuantity(value);
2852}
2853
2854template <detail::quantity_unary_operand A>
2855[[nodiscard]] GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL operator+(A a) {
2856 constexpr size_t N = detail::quantity_rank_v<A>;
2857 using UnitT = detail::unit_type_t<A>;
2858 return Quantity<N, Relative<UnitT>>::reinterpret(detail::toQuantity(a)._private_value);
2859}
2860
2861template <detail::quantity_unary_operand A>
2862[[nodiscard]] GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL operator-(A a) {
2863 constexpr size_t N = detail::quantity_rank_v<A>;
2864 using UnitT = detail::unit_type_t<A>;
2865 static_assert(!UnitT::MagnitudeType::IS_ABSOLUTE, "Quantity of this unit cannot be negated because it represents an absolute position.");
2866#if defined(GREM_USE_SSE_INTRINSICS) && !defined(GREM_PHYSICS_USE_DOUBLE_PRECISION)
2867 if constexpr (N == 3) {
2868 return Quantity<N, UnitT>::reinterpret(_mm_sub_ps(_mm_setzero_ps(), detail::toQuantity(a)._private_value));
2869 } else {
2870 return Quantity<N, UnitT>::reinterpret(-detail::toQuantity(a)._private_value);
2871 }
2872#else
2873 return Quantity<N, UnitT>::reinterpret(-detail::toQuantity(a)._private_value);
2874#endif
2875}
2876
2877template <detail::quantity_binary_operand_a A, detail::quantity_binary_operand_b<A> B>
2878[[nodiscard]] GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL operator+(A a, B b) {
2879 constexpr size_t N1 = detail::quantity_rank_v<A>;
2880 constexpr size_t N2 = detail::quantity_rank_v<B>;
2881 using UnitT1 = detail::unit_type_t<A>;
2882 using UnitT2 = detail::unit_type_t<B>;
2883 static_assert(detail::can_add<UnitT1, UnitT2>, "Quantities of these units cannot be added.");
2884#if defined(GREM_USE_SSE_INTRINSICS) && !defined(GREM_PHYSICS_USE_DOUBLE_PRECISION)
2885 if constexpr (N1 == 3 && N2 == 3) {
2886 return Quantity<3, Sum<UnitT1, UnitT2>>::reinterpret(_mm_add_ps(detail::toQuantity(a)._private_value, detail::toQuantity(b)._private_value));
2887 } else {
2888 return Quantity<grem::max(N1, N2), Sum<UnitT1, UnitT2>>::reinterpret(
2889 detail::toQuantity(a)._private_getUnderlyingValue() + detail::toQuantity(b)._private_getUnderlyingValue());
2890 }
2891#else
2892 return Quantity<grem::max(N1, N2), Sum<UnitT1, UnitT2>>::reinterpret(detail::toQuantity(a)._private_value + detail::toQuantity(b)._private_value);
2893#endif
2894}
2895
2896template <size_t N, typename UnitT>
2897GREM_ALWAYS_INLINE constexpr Quantity<N, UnitT>& GREM_VECTORCALL operator+=(Quantity<N, UnitT>& a, detail::quantity_convertible auto b) {
2898 return a = a + Quantity<N, Relative<UnitT>>{detail::toQuantity(b)};
2899}
2900
2901template <detail::quantity_binary_operand_a A, detail::quantity_binary_operand_b<A> B>
2902[[nodiscard]] GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL operator-(A a, B b) {
2903 constexpr size_t N1 = detail::quantity_rank_v<A>;
2904 constexpr size_t N2 = detail::quantity_rank_v<B>;
2905 using UnitT1 = detail::unit_type_t<A>;
2906 using UnitT2 = detail::unit_type_t<B>;
2907 static_assert(detail::can_subtract<UnitT1, UnitT2>, "Quantities of these units cannot be subtracted.");
2908#if defined(GREM_USE_SSE_INTRINSICS) && !defined(GREM_PHYSICS_USE_DOUBLE_PRECISION)
2909 if constexpr (N1 == 3 && N2 == 3) {
2910 return Quantity<3, Difference<UnitT1, UnitT2>>::reinterpret(_mm_sub_ps(detail::toQuantity(a)._private_value, detail::toQuantity(b)._private_value));
2911 } else {
2912 return Quantity<grem::max(N1, N2), Difference<UnitT1, UnitT2>>::reinterpret(
2913 detail::toQuantity(a)._private_getUnderlyingValue() - detail::toQuantity(b)._private_getUnderlyingValue());
2914 }
2915#else
2916 return Quantity<grem::max(N1, N2), Difference<UnitT1, UnitT2>>::reinterpret(detail::toQuantity(a)._private_value - detail::toQuantity(b)._private_value);
2917#endif
2918}
2919
2920template <size_t N, typename UnitT>
2921GREM_ALWAYS_INLINE constexpr Quantity<N, UnitT>& GREM_VECTORCALL operator-=(Quantity<N, UnitT>& a, detail::quantity_convertible auto b) {
2922 return a = a - Quantity<N, Relative<UnitT>>{detail::toQuantity(b)};
2923}
2924
2925template <detail::quantity_binary_operand_a A, detail::quantity_binary_operand_b<A> B>
2926[[nodiscard]] GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL operator*(A a, B b) {
2927 constexpr size_t N1 = detail::quantity_rank_v<A>;
2928 constexpr size_t N2 = detail::quantity_rank_v<B>;
2929 using UnitT1 = detail::unit_type_t<A>;
2930 using UnitT2 = detail::unit_type_t<B>;
2931 static_assert(detail::can_multiply<UnitT1, UnitT2>, "Quantities of these units cannot be multiplied.");
2932#if defined(GREM_USE_SSE_INTRINSICS) && !defined(GREM_PHYSICS_USE_DOUBLE_PRECISION)
2933 if constexpr (N1 == 3 && N2 == 3) {
2934 return Quantity<3, Product<UnitT1, UnitT2>>::reinterpret(_mm_mul_ps(detail::toQuantity(a)._private_value, detail::toQuantity(b)._private_value));
2935 } else if constexpr (N1 == 1 && N2 == 3) {
2936 return Quantity<3, Product<UnitT1, UnitT2>>::reinterpret(_mm_mul_ps(_mm_set1_ps(detail::toQuantity(a)._private_value), detail::toQuantity(b)._private_value));
2937 } else if constexpr (N1 == 3 && N2 == 1) {
2938 return Quantity<3, Product<UnitT1, UnitT2>>::reinterpret(_mm_mul_ps(detail::toQuantity(a)._private_value, _mm_set1_ps(detail::toQuantity(b)._private_value)));
2939 } else {
2940 return Quantity<grem::max(N1, N2), Product<UnitT1, UnitT2>>::reinterpret(
2941 detail::toQuantity(a)._private_getUnderlyingValue() * detail::toQuantity(b)._private_getUnderlyingValue());
2942 }
2943#else
2944 return Quantity<grem::max(N1, N2), Product<UnitT1, UnitT2>>::reinterpret(detail::toQuantity(a)._private_value * detail::toQuantity(b)._private_value);
2945#endif
2946}
2947
2948template <size_t N, typename UnitT>
2949GREM_ALWAYS_INLINE constexpr Quantity<N, UnitT>& GREM_VECTORCALL operator*=(Quantity<N, UnitT>& a, detail::quantity_convertible auto b) {
2950 return a = a * detail::toQuantity(b);
2951}
2952
2953template <detail::quantity_binary_operand_a A, detail::quantity_binary_operand_b<A> B>
2954[[nodiscard]] GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL operator/(A a, B b) {
2955 constexpr size_t N1 = detail::quantity_rank_v<A>;
2956 constexpr size_t N2 = detail::quantity_rank_v<B>;
2957 using UnitT1 = detail::unit_type_t<A>;
2958 using UnitT2 = detail::unit_type_t<B>;
2959 static_assert(detail::can_divide<UnitT1, UnitT2>, "Quantities of these units cannot be divided.");
2960#if defined(GREM_USE_SSE_INTRINSICS) && !defined(GREM_PHYSICS_USE_DOUBLE_PRECISION)
2961 if constexpr (N1 == 3 && N2 == 3) {
2962 return Quantity<3, Quotient<UnitT1, UnitT2>>::reinterpret(_mm_div_ps(detail::toQuantity(a)._private_value, detail::toQuantity(b)._private_value));
2963 } else if constexpr (N1 == 1 && N2 == 3) {
2964 return Quantity<3, Quotient<UnitT1, UnitT2>>::reinterpret(_mm_div_ps(_mm_set1_ps(detail::toQuantity(a)._private_value), detail::toQuantity(b)._private_value));
2965 } else if constexpr (N1 == 3 && N2 == 1) {
2966 return Quantity<3, Quotient<UnitT1, UnitT2>>::reinterpret(_mm_div_ps(detail::toQuantity(a)._private_value, _mm_set1_ps(detail::toQuantity(b)._private_value)));
2967 } else {
2968 return Quantity<grem::max(N1, N2), Quotient<UnitT1, UnitT2>>::reinterpret(
2969 detail::toQuantity(a)._private_getUnderlyingValue() / detail::toQuantity(b)._private_getUnderlyingValue());
2970 }
2971#else
2972 return Quantity<grem::max(N1, N2), Quotient<UnitT1, UnitT2>>::reinterpret(detail::toQuantity(a)._private_value / detail::toQuantity(b)._private_value);
2973#endif
2974}
2975
2976template <size_t N, typename UnitT>
2977GREM_ALWAYS_INLINE constexpr Quantity<N, UnitT>& GREM_VECTORCALL operator/=(Quantity<N, UnitT>& a, detail::quantity_convertible auto b) {
2978 return a = a / detail::toQuantity(b);
2979}
2980
2981template <size_t N1, typename UnitT1, size_t N2, typename UnitT2>
2983 static_assert(UnitT1{} == UnitT2{}, "Quantities of different units cannot be selected between.");
2984#if defined(GREM_USE_SSE_INTRINSICS) && !defined(GREM_PHYSICS_USE_DOUBLE_PRECISION)
2985 if constexpr (N1 == 3 && N2 == 3) {
2986 return Quantity<3, UnitT1>::reinterpret(_mm_min_ps(detail::toQuantity(a)._private_value, detail::toQuantity(b)._private_value));
2987 } else if constexpr (N1 == 1 && N2 == 3) {
2988 return Quantity<3, UnitT1>::reinterpret(_mm_min_ps(_mm_set1_ps(detail::toQuantity(a)._private_value), detail::toQuantity(b)._private_value));
2989 } else if constexpr (N1 == 3 && N2 == 1) {
2990 return Quantity<3, UnitT1>::reinterpret(_mm_min_ps(detail::toQuantity(a)._private_value, _mm_set1_ps(detail::toQuantity(b)._private_value)));
2991 } else {
2992 return Quantity<grem::max(N1, N2), UnitT1>::reinterpret(
2993 grem::min(detail::toQuantity(a)._private_getUnderlyingValue(), detail::toQuantity(b)._private_getUnderlyingValue()));
2994 }
2995#else
2996 return Quantity<grem::max(N1, N2), UnitT1>::reinterpret(grem::min(detail::toQuantity(a)._private_value, detail::toQuantity(b)._private_value));
2997#endif
2998}
2999
3000template <size_t N1, typename UnitT1, size_t N2, typename UnitT2>
3002 static_assert(UnitT1{} == UnitT2{}, "Quantities of different units cannot be selected between.");
3003#if defined(GREM_USE_SSE_INTRINSICS) && !defined(GREM_PHYSICS_USE_DOUBLE_PRECISION)
3004 if constexpr (N1 == 3 && N2 == 3) {
3005 return Quantity<3, UnitT1>::reinterpret(_mm_max_ps(detail::toQuantity(a)._private_value, detail::toQuantity(b)._private_value));
3006 } else if constexpr (N1 == 1 && N2 == 3) {
3007 return Quantity<3, UnitT1>::reinterpret(_mm_max_ps(_mm_set1_ps(detail::toQuantity(a)._private_value), detail::toQuantity(b)._private_value));
3008 } else if constexpr (N1 == 3 && N2 == 1) {
3009 return Quantity<3, UnitT1>::reinterpret(_mm_max_ps(detail::toQuantity(a)._private_value, _mm_set1_ps(detail::toQuantity(b)._private_value)));
3010 } else {
3011 return Quantity<grem::max(N1, N2), UnitT1>::reinterpret(
3012 grem::max(detail::toQuantity(a)._private_getUnderlyingValue(), detail::toQuantity(b)._private_getUnderlyingValue()));
3013 }
3014#else
3015 return Quantity<grem::max(N1, N2), UnitT1>::reinterpret(grem::max(detail::toQuantity(a)._private_value, detail::toQuantity(b)._private_value));
3016#endif
3017}
3018
3019template <size_t N1, typename UnitT1, size_t N2, typename UnitT2, size_t N3, typename UnitT3>
3021 return min(max(a, b), c);
3022}
3023
3024template <detail::quantity_unary_operand A>
3025[[nodiscard]] GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL sum(A a) {
3026 constexpr size_t N = detail::quantity_rank_v<A>;
3027 using UnitT = detail::unit_type_t<A>;
3028 static_assert(!detail::unit_type_t<A>::MagnitudeType::IS_ABSOLUTE, "Quantity of this unit cannot be added to itself because it represents an absolute position.");
3029 if constexpr (N == 1) {
3030 return detail::toQuantity(a);
3031 } else {
3032#if defined(GREM_USE_SSE_INTRINSICS) && !defined(GREM_PHYSICS_USE_DOUBLE_PRECISION)
3033 if constexpr (N == 3) {
3034 constexpr float32_t ZEROS = bit_cast<float32_t>(uint32_t{0});
3035 constexpr float32_t ONES = bit_cast<float32_t>(uint32_t{0xFFFFFFFF});
3036
3037 const auto q = detail::toQuantity(a);
3038 const __m128 y_x_z_z = _mm_shuffle_ps(q._private_value, q._private_value, _MM_SHUFFLE(2, 2, 0, 1));
3039 const __m128 y_x_0_0 = _mm_and_ps(y_x_z_z, _mm_set_ps(ZEROS, ZEROS, ONES, ONES));
3040 const __m128 xy_xy_z_z = _mm_add_ps(q._private_value, y_x_0_0);
3041 const __m128 z_z_0_0 = _mm_movehl_ps(y_x_0_0, xy_xy_z_z);
3042 const __m128 xyz_xy_z_z = _mm_add_ss(xy_xy_z_z, z_z_0_0);
3043 return Quantity<1, UnitT>::reinterpret(_mm_cvtss_f32(xyz_xy_z_z));
3044 } else {
3045 return Quantity<1, UnitT>::reinterpret(grem::sum(detail::toQuantity(a)._private_value));
3046 }
3047#else
3048 return Quantity<1, UnitT>::reinterpret(grem::sum(detail::toQuantity(a)._private_value));
3049#endif
3050 }
3051}
3052
3053template <detail::quantity_unary_operand A>
3054[[nodiscard]] GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL product(A a) {
3055 constexpr size_t N = detail::quantity_rank_v<A>;
3056 using UnitT = detail::unit_type_t<A>;
3057 static_assert(!UnitT::MagnitudeType::IS_ABSOLUTE, "Quantity of this unit cannot be multiplied by itself because it represents an absolute position.");
3058 if constexpr (N == 1) {
3059 return detail::toQuantity(a);
3060 } else if constexpr (N == 2) {
3061 return Quantity<1, Square<UnitT>>::reinterpret(grem::product(detail::toQuantity(a)._private_getUnderlyingValue()));
3062 } else if constexpr (N == 3) {
3063#if defined(GREM_USE_SSE_INTRINSICS) && !defined(GREM_PHYSICS_USE_DOUBLE_PRECISION)
3064 if constexpr (N == 3) {
3065 const auto q = detail::toQuantity(a);
3066 const __m128 y_x_z_z = _mm_shuffle_ps(q._private_value, q._private_value, _MM_SHUFFLE(2, 2, 0, 1));
3067 const __m128 y_x_1_1 = _mm_movelh_ps(y_x_z_z, _mm_set1_ps(1.0f));
3068 const __m128 xy_xy_z_z = _mm_mul_ps(q._private_value, y_x_1_1);
3069 const __m128 z_z_1_1 = _mm_movehl_ps(y_x_1_1, xy_xy_z_z);
3070 const __m128 xyz_xy_z_z = _mm_mul_ss(xy_xy_z_z, z_z_1_1);
3071 return Quantity<1, Cubic<UnitT>>::reinterpret(_mm_cvtss_f32(xyz_xy_z_z));
3072 } else {
3073 return Quantity<1, Cubic<UnitT>>::reinterpret(grem::product(detail::toQuantity(a)._private_value));
3074 }
3075#else
3076 return Quantity<1, Cubic<UnitT>>::reinterpret(grem::product(detail::toQuantity(a)._private_value));
3077#endif
3078 }
3079}
3080
3081template <detail::quantity_unary_operand A>
3082[[nodiscard]] GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL minComponent(A a) {
3083 constexpr size_t N = detail::quantity_rank_v<A>;
3084 using UnitT = detail::unit_type_t<A>;
3085 if constexpr (N == 1) {
3086 return detail::toQuantity(a);
3087 } else {
3088#if defined(GREM_USE_SSE_INTRINSICS) && !defined(GREM_PHYSICS_USE_DOUBLE_PRECISION)
3089 if constexpr (N == 3) {
3090 const auto q = detail::toQuantity(a);
3091 const auto minOfXY = min(q, q.get(Y, Z, Z));
3092 return min(minOfXY, q.get(Z, Z, Z)).getX();
3093 } else {
3094 return Quantity<1, UnitT>::reinterpret(grem::minComponent(detail::toQuantity(a)._private_value));
3095 }
3096#else
3097 return Quantity<1, UnitT>::reinterpret(grem::minComponent(detail::toQuantity(a)._private_value));
3098#endif
3099 }
3100}
3101
3102template <detail::quantity_unary_operand A>
3103[[nodiscard]] GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL maxComponent(A a) {
3104 constexpr size_t N = detail::quantity_rank_v<A>;
3105 using UnitT = detail::unit_type_t<A>;
3106 if constexpr (N == 1) {
3107 return detail::toQuantity(a);
3108 } else {
3109#if defined(GREM_USE_SSE_INTRINSICS) && !defined(GREM_PHYSICS_USE_DOUBLE_PRECISION)
3110 if constexpr (N == 3) {
3111 const auto q = detail::toQuantity(a);
3112 const auto maxOfXY = max(q, q.get(Y, Z, Z));
3113 return max(maxOfXY, q.get(Z, Z, Z)).getX();
3114 } else {
3115 return Quantity<1, UnitT>::reinterpret(grem::maxComponent(detail::toQuantity(a)._private_value));
3116 }
3117#else
3118 return Quantity<1, UnitT>::reinterpret(grem::maxComponent(detail::toQuantity(a)._private_value));
3119#endif
3120 }
3121}
3122
3123template <detail::quantity_unary_operand A>
3125 return grem::isfinite(detail::toQuantity(a)._private_getUnderlyingValue());
3126}
3127
3128template <detail::quantity_unary_operand A>
3130 return grem::isinf(detail::toQuantity(a)._private_getUnderlyingValue());
3131}
3132
3133template <detail::quantity_unary_operand A>
3135#if defined(GREM_USE_SSE_INTRINSICS) && !defined(GREM_PHYSICS_USE_DOUBLE_PRECISION)
3136 constexpr size_t N = detail::quantity_rank_v<A>;
3137 if constexpr (N == 3) {
3138 const auto q = detail::toQuantity(a);
3139 const int mask = _mm_movemask_ps(_mm_cmpunord_ps(q._private_value, q._private_value));
3140 return bvec3{static_cast<bool>(mask & 0b001), static_cast<bool>(mask & 0b010), static_cast<bool>(mask & 0b100)};
3141 } else {
3142 return grem::isnan(detail::toQuantity(a)._private_value);
3143 }
3144#else
3145 return grem::isnan(detail::toQuantity(a)._private_value);
3146#endif
3147}
3148
3149template <detail::quantity_unary_operand A>
3151#if defined(GREM_USE_SSE_INTRINSICS) && !defined(GREM_PHYSICS_USE_DOUBLE_PRECISION)
3152 constexpr size_t N = detail::quantity_rank_v<A>;
3153 if constexpr (N == 3) {
3154 const int mask = _mm_movemask_ps(detail::toQuantity(a)._private_value);
3155 return bvec3{static_cast<bool>(mask & 0b001), static_cast<bool>(mask & 0b010), static_cast<bool>(mask & 0b100)};
3156 } else {
3157 return grem::signbit(detail::toQuantity(a)._private_value);
3158 }
3159#else
3160 return grem::signbit(detail::toQuantity(a)._private_value);
3161#endif
3162}
3163
3164template <detail::quantity_unary_operand A>
3165[[nodiscard]] GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL sign(A a) {
3166 constexpr size_t N = detail::quantity_rank_v<A>;
3167#if defined(GREM_USE_SSE_INTRINSICS) && !defined(GREM_PHYSICS_USE_DOUBLE_PRECISION)
3168 if constexpr (N == 3) {
3169 return Quantity<3, Unitless>::reinterpret(_mm_or_ps(_mm_and_ps(detail::toQuantity(a)._private_value, _mm_set1_ps(-1.0f)), _mm_set1_ps(1.0f)));
3170 } else {
3171 return Quantity<N, Unitless>{grem::sign(detail::toQuantity(a)._private_value)};
3172 }
3173#else
3174 return Quantity<N, Unitless>{grem::sign(detail::toQuantity(a)._private_value)};
3175#endif
3176}
3177
3178template <detail::quantity_unary_operand A>
3179[[nodiscard]] GREM_ALWAYS_INLINE auto GREM_VECTORCALL exp(A a) {
3180 constexpr size_t N = detail::quantity_rank_v<A>;
3181 static_assert(detail::unit_type_t<A>{} == UNITLESS, "Quantities that are not unitless cannot be used as an exponent.");
3182 return Quantity<N, Unitless>::reinterpret(grem::exp(detail::toQuantity(a)._private_getUnderlyingValue()));
3183}
3184
3185template <detail::quantity_unary_operand A>
3186[[nodiscard]] GREM_ALWAYS_INLINE auto GREM_VECTORCALL exp2(A a) {
3187 constexpr size_t N = detail::quantity_rank_v<A>;
3188 static_assert(detail::unit_type_t<A>{} == UNITLESS, "Quantities that are not unitless cannot be used as an exponent.");
3189 return Quantity<N, Unitless>::reinterpret(grem::exp2(detail::toQuantity(a)._private_getUnderlyingValue()));
3190}
3191
3192template <detail::quantity_binary_operand_a A, detail::quantity_binary_operand_b<A> B>
3193[[nodiscard]] GREM_ALWAYS_INLINE auto GREM_VECTORCALL pow(A a, B b) {
3194 constexpr size_t N = detail::quantity_rank_v<A>;
3195 static_assert(detail::unit_type_t<A>{} == UNITLESS, "Quantities that are not unitless cannot be used as a base.");
3196 static_assert(detail::unit_type_t<B>{} == UNITLESS, "Quantities that are not unitless cannot be used as an exponent.");
3197 return Quantity<N, Unitless>::reinterpret(grem::pow(detail::toQuantity(a)._private_getUnderlyingValue(), detail::toQuantity(b)._private_getUnderlyingValue()));
3198}
3199
3200template <detail::quantity_binary_operand_a A, detail::quantity_binary_operand_b<A> B>
3201[[nodiscard]] GREM_ALWAYS_INLINE auto GREM_VECTORCALL fmod(A a, B b) {
3202 constexpr size_t N = detail::quantity_rank_v<A>;
3203 using UnitT = detail::unit_type_t<A>;
3204 static_assert(detail::unit_type_t<B>{} == UnitT{}, "Quantities of different units cannot wrap each other.");
3205 return Quantity<N, UnitT>::reinterpret(grem::fmod(detail::toQuantity(a)._private_getUnderlyingValue(), detail::toQuantity(b)._private_getUnderlyingValue()));
3206}
3207
3208template <detail::quantity_binary_operand_a A, detail::quantity_binary_operand_b<A> B>
3209[[nodiscard]] GREM_ALWAYS_INLINE auto GREM_VECTORCALL wrap(A a, B b) {
3210 constexpr size_t N = detail::quantity_rank_v<A>;
3211 using UnitT = detail::unit_type_t<A>;
3212 static_assert(detail::unit_type_t<B>{} == UnitT{}, "Quantities of different units cannot wrap each other.");
3213 return Quantity<N, UnitT>::reinterpret(grem::wrap(detail::toQuantity(a)._private_getUnderlyingValue(), detail::toQuantity(b)._private_getUnderlyingValue()));
3214}
3215
3216template <detail::quantity_unary_operand A>
3217[[nodiscard]] GREM_ALWAYS_INLINE auto GREM_VECTORCALL abs(A a) {
3218 constexpr size_t N = detail::quantity_rank_v<A>;
3219 using UnitT = detail::unit_type_t<A>;
3220 static_assert(!UnitT::MagnitudeType::IS_ABSOLUTE, "Quantity of this unit cannot have its absolute value taken because it represents an absolute position.");
3221#if defined(GREM_USE_SSE_INTRINSICS) && !defined(GREM_PHYSICS_USE_DOUBLE_PRECISION)
3222 if constexpr (N == 3) {
3223 const auto q = detail::toQuantity(a);
3224 return max(-q, q);
3225 } else {
3226 return Quantity<N, UnitT>::reinterpret(grem::abs(detail::toQuantity(a)._private_value));
3227 }
3228#else
3229 return Quantity<N, UnitT>::reinterpret(grem::abs(detail::toQuantity(a)._private_value));
3230#endif
3231}
3232
3233template <detail::quantity_binary_operand_a A, detail::quantity_binary_operand_b<A> B>
3234[[nodiscard]] GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL dot(A a, B b) {
3235 return sum(a * b);
3236}
3237
3238template <detail::quantity_binary_operand_a A, detail::quantity_binary_operand_b<A> B>
3239[[nodiscard]] GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL cross(A a, B b) {
3240 constexpr size_t N1 = detail::quantity_rank_v<A>;
3241 constexpr size_t N2 = detail::quantity_rank_v<B>;
3242 using UnitT1 = detail::unit_type_t<A>;
3243 using UnitT2 = detail::unit_type_t<B>;
3244 static_assert(detail::can_multiply<UnitT1, UnitT2>, "Quantities of these units cannot be multiplied.");
3245 if constexpr (N1 == 1 && N2 == 1) {
3247 } else if constexpr (N1 == 2 && N2 == 1) {
3248 const vec<2, Scalar> v = detail::toQuantity(a)._private_getUnderlyingValue();
3249 return Quantity<2, Product<UnitT1, UnitT2>>::reinterpret(vec<2, Scalar>{v.y, -v.x} * detail::toQuantity(b)._private_getUnderlyingValue());
3250 } else if constexpr (N1 == 1 && N2 == 2) {
3251 const vec<2, Scalar> v = detail::toQuantity(b)._private_getUnderlyingValue();
3252 return Quantity<2, Product<UnitT1, UnitT2>>::reinterpret(detail::toQuantity(a)._private_getUnderlyingValue() * vec<2, Scalar>{-v.y, v.x});
3253 } else if constexpr (N1 == 2 && N2 == 2) {
3254 return Quantity<1, Product<UnitT1, UnitT2>>::reinterpret(
3255 grem::cross(detail::toQuantity(a)._private_getUnderlyingValue(), detail::toQuantity(b)._private_getUnderlyingValue()));
3256 } else if constexpr (N1 == 3 && N2 == 3) {
3257#if defined(GREM_USE_SSE_INTRINSICS) && !defined(GREM_PHYSICS_USE_DOUBLE_PRECISION)
3258 const auto qA = detail::toQuantity(a);
3259 const auto qB = detail::toQuantity(b);
3260 return (qB.get(Y, Z, X) * qA - qA.get(Y, Z, X) * qB).get(Y, Z, X);
3261#else
3262 return Quantity<3, Product<UnitT1, UnitT2>>::reinterpret(grem::cross(detail::toQuantity(a)._private_value, detail::toQuantity(b)._private_value));
3263#endif
3264 } else {
3265 return Quantity<grem::max(N1, N2), Product<UnitT1, UnitT2>>::reinterpret(
3266 grem::cross(detail::toQuantity(a)._private_getUnderlyingValue(), detail::toQuantity(b)._private_getUnderlyingValue()));
3267 }
3268}
3269
3270template <detail::quantity_unary_operand A>
3271[[nodiscard]] GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL sqrt(A a) {
3272 constexpr size_t N = detail::quantity_rank_v<A>;
3273 using UnitT = detail::unit_type_t<A>;
3274 static_assert(!UnitT::MagnitudeType::IS_ABSOLUTE, "Quantity of this unit cannot have its square root taken because it represents an absolute position.");
3275#if defined(GREM_USE_SSE_INTRINSICS) && !defined(GREM_PHYSICS_USE_DOUBLE_PRECISION)
3276 if constexpr (N == 3) {
3277 return Quantity<3, Sqrt<UnitT>>::reinterpret(_mm_sqrt_ps(detail::toQuantity(a)._private_value));
3278 } else {
3279 return Quantity<N, Sqrt<UnitT>>::reinterpret(grem::sqrt(detail::toQuantity(a)._private_value));
3280 }
3281#else
3282 return Quantity<N, Sqrt<UnitT>>::reinterpret(grem::sqrt(detail::toQuantity(a)._private_value));
3283#endif
3284}
3285
3286template <detail::quantity_unary_operand A>
3287[[nodiscard]] GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL inversesqrt(A a) {
3288 constexpr size_t N = detail::quantity_rank_v<A>;
3289 using UnitT = detail::unit_type_t<A>;
3290 static_assert(!UnitT::MagnitudeType::IS_ABSOLUTE, "Quantity of this unit cannot have its reciprocal square root taken because it represents an absolute position.");
3291 return Quantity<N, Reciprocal<Sqrt<UnitT>>>::reinterpret(grem::inversesqrt(detail::toQuantity(a)._private_getUnderlyingValue()));
3292}
3293
3294template <detail::quantity_unary_operand A>
3295[[nodiscard]] GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL length2(A a) {
3296 using UnitT = detail::unit_type_t<A>;
3297 static_assert(!UnitT::MagnitudeType::IS_ABSOLUTE, "Quantity of this unit cannot have its square length taken because it represents an absolute position.");
3298 return dot(a, a);
3299}
3300
3301template <detail::quantity_unary_operand A>
3302[[nodiscard]] GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL length(A a) {
3303 using UnitT = detail::unit_type_t<A>;
3304 static_assert(!UnitT::MagnitudeType::IS_ABSOLUTE, "Quantity of this unit cannot have its length taken because it represents an absolute position.");
3305 return sqrt(length2(a));
3306}
3307
3308template <detail::quantity_binary_operand_a A, detail::quantity_binary_operand_b<A> B>
3309[[nodiscard]] GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL distance(A a, B b) {
3310 using UnitT = detail::unit_type_t<A>;
3311 static_assert(detail::unit_type_t<B>{} == UnitT{}, "Quantities of these units cannot have their distance measured.");
3312 return length(a - b);
3313}
3314
3315template <detail::quantity_binary_operand_a A, detail::quantity_binary_operand_b<A> B>
3316[[nodiscard]] GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL distance2(A a, B b) {
3317 using UnitT = detail::unit_type_t<A>;
3318 static_assert(detail::unit_type_t<B>{} == UnitT{}, "Quantities of these units cannot have their squared distance measured.");
3319 return length2(a - b);
3320}
3321
3322template <detail::quantity_unary_operand A>
3323[[nodiscard]] GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL getAngle(A a) {
3324 using UnitT = detail::unit_type_t<A>;
3325 static_assert(!UnitT::MagnitudeType::IS_ABSOLUTE, "Quantity of this unit cannot have its angle taken because it represents an absolute position.");
3326 return Quantity<1, Radians>::reinterpret(grem::getAngle(detail::toQuantity(a)._private_getUnderlyingValue()));
3327}
3328
3329template <detail::quantity_unary_operand A>
3330[[nodiscard]] GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL tryGetAngle(A a) {
3331 using UnitT = detail::unit_type_t<A>;
3332 static_assert(!UnitT::MagnitudeType::IS_ABSOLUTE, "Quantity of this unit cannot have its angle taken because it represents an absolute position.");
3333 if (const auto result = grem::tryGetAngle(detail::toQuantity(a)._private_getUnderlyingValue())) {
3335 }
3337}
3338
3339template <detail::quantity_unary_operand A>
3340[[nodiscard]] GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL cos(A a) {
3341 using UnitT = detail::unit_type_t<A>;
3342 static_assert(UnitT::DIMENSION == ANGLE, "Quantity of this unit cannot have its cosine taken because it is not an angle.");
3343 return Quantity<1, Unitless>::reinterpret(grem::cos(detail::toQuantity(a).in(RADIANS)._private_getUnderlyingValue()));
3344}
3345
3346template <detail::quantity_unary_operand A>
3347[[nodiscard]] GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL sin(A a) {
3348 using UnitT = detail::unit_type_t<A>;
3349 static_assert(UnitT::DIMENSION == ANGLE, "Quantity of this unit cannot have its cosine taken because it is not an angle.");
3350 return Quantity<1, Unitless>::reinterpret(grem::sin(detail::toQuantity(a).in(RADIANS)._private_getUnderlyingValue()));
3351}
3352
3353template <detail::quantity_unary_operand A>
3354[[nodiscard]] GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL tan(A a) {
3355 using UnitT = detail::unit_type_t<A>;
3356 static_assert(UnitT::DIMENSION == ANGLE, "Quantity of this unit cannot have its cosine taken because it is not an angle.");
3357 return Quantity<1, Unitless>::reinterpret(grem::tan(detail::toQuantity(a).in(RADIANS)._private_getUnderlyingValue()));
3358}
3359
3360template <detail::quantity_unary_operand A>
3361[[nodiscard]] GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL acos(A a) {
3362 return Quantity<1, Radians>::reinterpret(grem::acos(detail::toQuantity(a)._private_getUnderlyingValue()));
3363}
3364
3365template <detail::quantity_unary_operand A>
3366[[nodiscard]] GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL asin(A a) {
3367 return Quantity<1, Radians>::reinterpret(grem::asin(detail::toQuantity(a)._private_getUnderlyingValue()));
3368}
3369
3370template <detail::quantity_unary_operand A>
3371[[nodiscard]] GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL atan(A a) {
3372 return Quantity<1, Radians>::reinterpret(grem::atan(detail::toQuantity(a)._private_getUnderlyingValue()));
3373}
3374
3375template <detail::quantity_binary_operand_a A, detail::quantity_binary_operand_b<A> B>
3376[[nodiscard]] GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL atan2(A a, B b) {
3377 using UnitT = detail::unit_type_t<A>;
3378 static_assert(detail::unit_type_t<B>{} == UnitT{}, "Quantities of different units cannot be passed to atan2.");
3379 return Quantity<1, Radians>::reinterpret(grem::atan2(detail::toQuantity(a)._private_getUnderlyingValue(), detail::toQuantity(b)._private_getUnderlyingValue()));
3380}
3381
3382template <detail::quantity_binary_operand_a A, detail::quantity_binary_operand_b<A> B>
3383[[nodiscard]] GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL tryDivide(A a, B b) {
3384 using R = decltype(a / b);
3385 using UnitT1 = detail::unit_type_t<A>;
3386 using UnitT2 = detail::unit_type_t<B>;
3387 static_assert(detail::can_divide<UnitT1, UnitT2>, "Quantities of these units cannot be divided.");
3388 if (const auto quotient = grem::tryDivide(detail::toQuantity(a)._private_getUnderlyingValue(), detail::toQuantity(b)._private_getUnderlyingValue())) {
3389 return Optional<R>{R::reinterpret(*quotient)};
3390 }
3391 return Optional<R>{};
3392}
3393
3394template <detail::quantity_binary_operand_a A, detail::quantity_binary_operand_b<A> B>
3395[[nodiscard]] GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL reflect(A a, B normal) {
3396 constexpr size_t N = detail::quantity_rank_v<A>;
3397 using UnitT = detail::unit_type_t<A>;
3398 static_assert(!UnitT::MagnitudeType::IS_ABSOLUTE, "Quantity of this unit cannot be reflected because it represents an absolute position.");
3399 static_assert(detail::unit_type_t<B>{} == UNITLESS, "Quantity of this unit cannot be reflected against.");
3400 return Quantity<N, UnitT>::reinterpret(grem::reflect(detail::toQuantity(a)._private_getUnderlyingValue(), detail::toQuantity(normal)._private_getUnderlyingValue()));
3401}
3402
3403template <detail::quantity_ternary_operand_a A, detail::quantity_ternary_operand_b<A> B, detail::quantity_ternary_operand_c<A, B> C>
3404[[nodiscard]] GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL lerp(A a, B b, C alpha) {
3405 constexpr size_t N = detail::quantity_rank_v<A>;
3406 using UnitT = detail::unit_type_t<A>;
3407 static_assert(detail::quantity_rank_v<B> == N, "Quantities of different ranks cannot be interpolated.");
3408 static_assert(detail::unit_type_t<B>{} == UnitT{}, "Quantities of different units cannot be interpolated.");
3409 static_assert(detail::unit_type_t<C>{} == UNITLESS, "Alpha quantity must be unitless.");
3410 return Quantity<N, UnitT>::reinterpret((+a) * (C{Scalar{1}} - alpha) + (+b) * alpha);
3411}
3412
3413template <detail::quantity_ternary_operand_a A, detail::quantity_ternary_operand_b<A> B, detail::quantity_ternary_operand_c<A, B> C>
3414[[nodiscard]] GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL unlerp(A value, B minValue, C maxValue) {
3415 static_assert(detail::quantity_rank_v<A> == 1 && detail::quantity_rank_v<B> == 1 && detail::quantity_rank_v<C> == 1, "Non-scalar quantities cannot be deinterpolated.");
3416 using UnitT = detail::unit_type_t<A>;
3417 static_assert(detail::unit_type_t<B>{} == UnitT{}, "Quantities of different units cannot be deinterpolated.");
3418 static_assert(detail::unit_type_t<C>{} == UnitT{}, "Quantities of different units cannot be deinterpolated.");
3419 return (value - minValue) / (maxValue - minValue);
3420}
3421
3422template <detail::quantity_ternary_operand_a A, detail::quantity_ternary_operand_b<A> B, detail::quantity_ternary_operand_c<A, B> C>
3423[[nodiscard]] GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL mix(A a, B b, C alpha) {
3424 return lerp(a, b, alpha);
3425}
3426
3427template <detail::quantity_binary_operand_a A, detail::quantity_binary_operand_b<A> B>
3428[[nodiscard]] GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL step(A edge, B value) {
3429 constexpr size_t N = detail::quantity_rank_v<A>;
3430 using UnitT = detail::unit_type_t<A>;
3431 static_assert(detail::quantity_rank_v<B> == N, "Quantities of different ranks cannot be passed to step.");
3432 static_assert(detail::unit_type_t<B>{} == UnitT{}, "Quantities of different units cannot be passed to step.");
3433 return Quantity<N, Unitless>::reinterpret(grem::step(detail::toQuantity(edge)._private_getUnderlyingValue(), detail::toQuantity(value)._private_getUnderlyingValue()));
3434}
3435
3436template <detail::quantity_binary_operand_a A, detail::quantity_binary_operand_b<A> B>
3437[[nodiscard]] GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL select(auto condition, A ifTrue, B ifFalse) {
3438 constexpr size_t N = detail::quantity_rank_v<A>;
3439 using UnitT = detail::unit_type_t<A>;
3440 static_assert(detail::quantity_rank_v<B> == N, "Quantities of different ranks cannot be selected between.");
3441 static_assert(detail::unit_type_t<B>{} == UnitT{}, "Quantities of different units cannot be selected between.");
3442 if constexpr (N == 1) {
3444 grem::select(vec<1, bool>{condition}, vec<1, Scalar>{detail::toQuantity(ifTrue)._private_value}, vec<1, Scalar>{detail::toQuantity(ifFalse)._private_value}).x);
3445 } else {
3446#if defined(GREM_USE_SSE_INTRINSICS) && !defined(GREM_PHYSICS_USE_DOUBLE_PRECISION)
3447 if constexpr (N == 3) {
3448 const bvec3 conditions{condition};
3449 const __m128 mask = _mm_castsi128_ps(_mm_sub_epi32(
3450 _mm_set_epi32(static_cast<int>(conditions.z), static_cast<int>(conditions.z), static_cast<int>(conditions.y), static_cast<int>(conditions.x)), _mm_set1_epi32(1)));
3452 _mm_or_ps(_mm_and_ps(mask, detail::toQuantity(ifFalse)._private_value), _mm_andnot_ps(mask, detail::toQuantity(ifTrue)._private_value)));
3453 } else {
3454 return Quantity<N, UnitT>::reinterpret(grem::select(condition, detail::toQuantity(ifTrue)._private_value, detail::toQuantity(ifFalse)._private_value));
3455 }
3456#else
3457 return Quantity<N, UnitT>::reinterpret(grem::select(condition, detail::toQuantity(ifTrue)._private_value, detail::toQuantity(ifFalse)._private_value));
3458#endif
3459 }
3460}
3461
3462template <detail::quantity_ternary_operand_a A, detail::quantity_ternary_operand_b<A> B, detail::quantity_ternary_operand_c<A, B> C>
3463[[nodiscard]] GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL moveTowards(A value, B targetValue, C amount) {
3464 constexpr size_t N = detail::quantity_rank_v<A>;
3465 using UnitT = detail::unit_type_t<A>;
3466 static_assert(detail::quantity_rank_v<B> == N, "Cannot move towards a quantity of a different rank.");
3467 static_assert(detail::unit_type_t<B>{} == UnitT{}, "Cannot move towards a quantity of a different unit.");
3468 static_assert(detail::quantity_rank_v<C> == 1, "Cannot move by a non-scalar quantity.");
3469 using AmountUnitT = detail::unit_type_t<C>;
3470 static_assert(!AmountUnitT::MagnitudeType::IS_ABSOLUTE, "Cannot move by an absolute unit.");
3471 static_assert(AmountUnitT{} == Relative<UnitT>{}, "Cannot move by a quantity of a different unit.");
3472 return Quantity<N, UnitT>::reinterpret(grem::moveTowards(detail::toQuantity(value)._private_getUnderlyingValue(), detail::toQuantity(targetValue)._private_getUnderlyingValue(),
3473 detail::toQuantity(amount)._private_getUnderlyingValue()));
3474}
3475
3476template <detail::quantity_binary_operand_a A, detail::quantity_binary_operand_b<A> B, typename Frequency, typename Duration>
3477[[nodiscard]] GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL expDecay(A value, B targetValue, Frequency decayRate, Duration deltaTime) {
3478 constexpr size_t N = detail::quantity_rank_v<A>;
3479 using UnitT = detail::unit_type_t<A>;
3480 static_assert(detail::quantity_rank_v<B> == N, "Cannot decay towards a quantity of a different rank.");
3481 static_assert(detail::unit_type_t<B>{} == UnitT{}, "Cannot decay towards a quantity of a different unit.");
3482 static_assert(Product<detail::unit_type_t<Frequency>, detail::unit_type_t<Duration>>{} == UNITLESS, "Cannot decay by a non-unitless exponent.");
3483 return Quantity<N, UnitT>::reinterpret(grem::expDecay(detail::toQuantity(value)._private_getUnderlyingValue(), detail::toQuantity(targetValue)._private_getUnderlyingValue(),
3484 detail::toQuantity(decayRate)._private_getUnderlyingValue(), detail::toQuantity(deltaTime)._private_getUnderlyingValue()));
3485}
3486
3487template <detail::quantity_unary_operand A, typename Frequency, typename Duration>
3488[[nodiscard]] GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL expDecay(A value, Frequency decayRate, Duration deltaTime) {
3489 constexpr size_t N = detail::quantity_rank_v<A>;
3490 using UnitT = detail::unit_type_t<A>;
3491 static_assert(Product<detail::unit_type_t<Frequency>, detail::unit_type_t<Duration>>{} == UNITLESS, "Cannot decay by a non-unitless exponent.");
3492 return Quantity<N, UnitT>::reinterpret(grem::expDecay(detail::toQuantity(value)._private_getUnderlyingValue(), detail::toQuantity(decayRate)._private_getUnderlyingValue(),
3493 detail::toQuantity(deltaTime)._private_getUnderlyingValue()));
3494}
3495
3496template <detail::quantity_binary_operand_a A, detail::quantity_binary_operand_b<A> B>
3497[[nodiscard]] GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL midpoint(A a, B b) {
3498 constexpr size_t N = detail::quantity_rank_v<A>;
3499 using UnitT = detail::unit_type_t<A>;
3500 static_assert(detail::quantity_rank_v<B> == N, "Cannot take the midpoint of two quantities of different ranks.");
3501 static_assert(detail::unit_type_t<B>{} == UnitT{}, "Cannot take the midpoint of two quantities of different units.");
3502 return Quantity<N, UnitT>::reinterpret(((+a) + (+b)) * Scalar{0.5});
3503}
3504
3505template <detail::quantity_unary_operand A>
3506[[nodiscard]] GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL round(A a) {
3507 constexpr size_t N = detail::quantity_rank_v<A>;
3508 using UnitT = detail::unit_type_t<A>;
3509 return Quantity<N, UnitT>::reinterpret(grem::round(detail::toQuantity(a)._private_getUnderlyingValue()));
3510}
3511
3512template <detail::quantity_unary_operand A>
3513[[nodiscard]] GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL floor(A a) {
3514 constexpr size_t N = detail::quantity_rank_v<A>;
3515 using UnitT = detail::unit_type_t<A>;
3516 return Quantity<N, UnitT>::reinterpret(grem::floor(detail::toQuantity(a)._private_getUnderlyingValue()));
3517}
3518
3519template <detail::quantity_unary_operand A>
3520[[nodiscard]] GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL ceil(A a) {
3521 constexpr size_t N = detail::quantity_rank_v<A>;
3522 using UnitT = detail::unit_type_t<A>;
3523 return Quantity<N, UnitT>::reinterpret(grem::ceil(detail::toQuantity(a)._private_getUnderlyingValue()));
3524}
3525
3526template <detail::quantity_binary_operand_a A, detail::quantity_binary_operand_b<A> B>
3527[[nodiscard]] GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL equal(A a, B b) {
3528 using UnitT = detail::unit_type_t<A>;
3529 static_assert(detail::unit_type_t<B>{} == UnitT{}, "Quantities of different units cannot be compared for equality.");
3530#if defined(GREM_USE_SSE_INTRINSICS) && !defined(GREM_PHYSICS_USE_DOUBLE_PRECISION)
3531 constexpr size_t N1 = detail::quantity_rank_v<A>;
3532 constexpr size_t N2 = detail::quantity_rank_v<B>;
3533 if constexpr (N1 == 3 && N2 == 3) {
3534 const int mask = _mm_movemask_ps(_mm_cmpeq_ps(detail::toQuantity(a)._private_value, detail::toQuantity(b)._private_value));
3535 return bvec3{static_cast<bool>(mask & 0b001), static_cast<bool>(mask & 0b010), static_cast<bool>(mask & 0b100)};
3536 } else if constexpr (N1 == 1 && N2 == 3) {
3537 const int mask = _mm_movemask_ps(_mm_cmpeq_ps(_mm_set1_ps(detail::toQuantity(a)._private_value), detail::toQuantity(b)._private_value));
3538 return bvec3{static_cast<bool>(mask & 0b001), static_cast<bool>(mask & 0b010), static_cast<bool>(mask & 0b100)};
3539 } else if constexpr (N1 == 3 && N2 == 1) {
3540 const int mask = _mm_movemask_ps(_mm_cmpeq_ps(detail::toQuantity(a)._private_value, _mm_set1_ps(detail::toQuantity(b)._private_value)));
3541 return bvec3{static_cast<bool>(mask & 0b001), static_cast<bool>(mask & 0b010), static_cast<bool>(mask & 0b100)};
3542 } else {
3543 return grem::equal(detail::toQuantity(a)._private_getUnderlyingValue(), detail::toQuantity(b)._private_getUnderlyingValue());
3544 }
3545#else
3546 return grem::equal(detail::toQuantity(a)._private_value, detail::toQuantity(b)._private_value);
3547#endif
3548}
3549
3550template <detail::quantity_unary_operand A>
3551[[nodiscard]] GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL equal(A a, Zero) {
3552 return equal(a, A{});
3553}
3554
3555template <detail::quantity_unary_operand B>
3556[[nodiscard]] GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL equal(Zero, B b) {
3557 return equal(B{}, b);
3558}
3559
3560template <detail::quantity_binary_operand_a A, detail::quantity_binary_operand_b<A> B>
3561[[nodiscard]] GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL notEqual(A a, B b) {
3562 using UnitT = detail::unit_type_t<A>;
3563 static_assert(detail::unit_type_t<B>{} == UnitT{}, "Quantities of different units cannot be compared for inequality.");
3564#if defined(GREM_USE_SSE_INTRINSICS) && !defined(GREM_PHYSICS_USE_DOUBLE_PRECISION)
3565 constexpr size_t N1 = detail::quantity_rank_v<A>;
3566 constexpr size_t N2 = detail::quantity_rank_v<B>;
3567 if constexpr (N1 == 3 && N2 == 3) {
3568 const int mask = _mm_movemask_ps(_mm_cmpne_ps(detail::toQuantity(a)._private_value, detail::toQuantity(b)._private_value));
3569 return bvec3{static_cast<bool>(mask & 0b001), static_cast<bool>(mask & 0b010), static_cast<bool>(mask & 0b100)};
3570 } else if constexpr (N1 == 1 && N2 == 3) {
3571 const int mask = _mm_movemask_ps(_mm_cmpne_ps(_mm_set1_ps(detail::toQuantity(a)._private_value), detail::toQuantity(b)._private_value));
3572 return bvec3{static_cast<bool>(mask & 0b001), static_cast<bool>(mask & 0b010), static_cast<bool>(mask & 0b100)};
3573 } else if constexpr (N1 == 3 && N2 == 1) {
3574 const int mask = _mm_movemask_ps(_mm_cmpne_ps(detail::toQuantity(a)._private_value, _mm_set1_ps(detail::toQuantity(b)._private_value)));
3575 return bvec3{static_cast<bool>(mask & 0b001), static_cast<bool>(mask & 0b010), static_cast<bool>(mask & 0b100)};
3576 } else {
3577 return grem::notEqual(detail::toQuantity(a)._private_getUnderlyingValue(), detail::toQuantity(b)._private_getUnderlyingValue());
3578 }
3579#else
3580 return grem::notEqual(detail::toQuantity(a)._private_value, detail::toQuantity(b)._private_value);
3581#endif
3582}
3583
3584template <detail::quantity_unary_operand A>
3585[[nodiscard]] GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL notEqual(A a, Zero) {
3586 return notEqual(a, A{});
3587}
3588
3589template <detail::quantity_unary_operand B>
3590[[nodiscard]] GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL notEqual(Zero, B b) {
3591 return notEqual(B{}, b);
3592}
3593
3594template <detail::quantity_binary_operand_a A, detail::quantity_binary_operand_b<A> B>
3595[[nodiscard]] GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL lessThan(A a, B b) {
3596 using UnitT = detail::unit_type_t<A>;
3597 static_assert(detail::unit_type_t<B>{} == UnitT{}, "Quantities of different units cannot be compared.");
3598#if defined(GREM_USE_SSE_INTRINSICS) && !defined(GREM_PHYSICS_USE_DOUBLE_PRECISION)
3599 constexpr size_t N1 = detail::quantity_rank_v<A>;
3600 constexpr size_t N2 = detail::quantity_rank_v<B>;
3601 if constexpr (N1 == 3 && N2 == 3) {
3602 const int mask = _mm_movemask_ps(_mm_cmplt_ps(detail::toQuantity(a)._private_value, detail::toQuantity(b)._private_value));
3603 return bvec3{static_cast<bool>(mask & 0b001), static_cast<bool>(mask & 0b010), static_cast<bool>(mask & 0b100)};
3604 } else if constexpr (N1 == 1 && N2 == 3) {
3605 const int mask = _mm_movemask_ps(_mm_cmplt_ps(_mm_set1_ps(detail::toQuantity(a)._private_value), detail::toQuantity(b)._private_value));
3606 return bvec3{static_cast<bool>(mask & 0b001), static_cast<bool>(mask & 0b010), static_cast<bool>(mask & 0b100)};
3607 } else if constexpr (N1 == 3 && N2 == 1) {
3608 const int mask = _mm_movemask_ps(_mm_cmplt_ps(detail::toQuantity(a)._private_value, _mm_set1_ps(detail::toQuantity(b)._private_value)));
3609 return bvec3{static_cast<bool>(mask & 0b001), static_cast<bool>(mask & 0b010), static_cast<bool>(mask & 0b100)};
3610 } else {
3611 return grem::lessThan(detail::toQuantity(a)._private_getUnderlyingValue(), detail::toQuantity(b)._private_getUnderlyingValue());
3612 }
3613#else
3614 return grem::lessThan(detail::toQuantity(a)._private_value, detail::toQuantity(b)._private_value);
3615#endif
3616}
3617
3618template <detail::quantity_unary_operand A>
3619[[nodiscard]] GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL lessThan(A a, Zero) {
3620 return lessThan(a, A{});
3621}
3622
3623template <detail::quantity_unary_operand B>
3624[[nodiscard]] GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL lessThan(Zero, B b) {
3625 return lessThan(B{}, b);
3626}
3627
3628template <detail::quantity_binary_operand_a A, detail::quantity_binary_operand_b<A> B>
3629[[nodiscard]] GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL lessThanEqual(A a, B b) {
3630 using UnitT = detail::unit_type_t<A>;
3631 static_assert(detail::unit_type_t<B>{} == UnitT{}, "Quantities of different units cannot be compared.");
3632#if defined(GREM_USE_SSE_INTRINSICS) && !defined(GREM_PHYSICS_USE_DOUBLE_PRECISION)
3633 constexpr size_t N1 = detail::quantity_rank_v<A>;
3634 constexpr size_t N2 = detail::quantity_rank_v<B>;
3635 if constexpr (N1 == 3 && N2 == 3) {
3636 const int mask = _mm_movemask_ps(_mm_cmple_ps(detail::toQuantity(a)._private_value, detail::toQuantity(b)._private_value));
3637 return bvec3{static_cast<bool>(mask & 0b001), static_cast<bool>(mask & 0b010), static_cast<bool>(mask & 0b100)};
3638 } else if constexpr (N1 == 1 && N2 == 3) {
3639 const int mask = _mm_movemask_ps(_mm_cmple_ps(_mm_set1_ps(detail::toQuantity(a)._private_value), detail::toQuantity(b)._private_value));
3640 return bvec3{static_cast<bool>(mask & 0b001), static_cast<bool>(mask & 0b010), static_cast<bool>(mask & 0b100)};
3641 } else if constexpr (N1 == 3 && N2 == 1) {
3642 const int mask = _mm_movemask_ps(_mm_cmple_ps(detail::toQuantity(a)._private_value, _mm_set1_ps(detail::toQuantity(b)._private_value)));
3643 return bvec3{static_cast<bool>(mask & 0b001), static_cast<bool>(mask & 0b010), static_cast<bool>(mask & 0b100)};
3644 } else {
3645 return grem::lessThanEqual(detail::toQuantity(a)._private_getUnderlyingValue(), detail::toQuantity(b)._private_getUnderlyingValue());
3646 }
3647#else
3648 return grem::lessThanEqual(detail::toQuantity(a)._private_value, detail::toQuantity(b)._private_value);
3649#endif
3650}
3651
3652template <detail::quantity_unary_operand A>
3653[[nodiscard]] GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL lessThanEqual(A a, Zero) {
3654 return lessThanEqual(a, A{});
3655}
3656
3657template <detail::quantity_unary_operand B>
3658[[nodiscard]] GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL lessThanEqual(Zero, B b) {
3659 return lessThanEqual(B{}, b);
3660}
3661
3662template <detail::quantity_binary_operand_a A, detail::quantity_binary_operand_b<A> B>
3663[[nodiscard]] GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL greaterThan(A a, B b) {
3664 using UnitT = detail::unit_type_t<A>;
3665 static_assert(detail::unit_type_t<B>{} == UnitT{}, "Quantities of different units cannot be compared.");
3666#if defined(GREM_USE_SSE_INTRINSICS) && !defined(GREM_PHYSICS_USE_DOUBLE_PRECISION)
3667 constexpr size_t N1 = detail::quantity_rank_v<A>;
3668 constexpr size_t N2 = detail::quantity_rank_v<B>;
3669 if constexpr (N1 == 3 && N2 == 3) {
3670 const int mask = _mm_movemask_ps(_mm_cmpgt_ps(detail::toQuantity(a)._private_value, detail::toQuantity(b)._private_value));
3671 return bvec3{static_cast<bool>(mask & 0b001), static_cast<bool>(mask & 0b010), static_cast<bool>(mask & 0b100)};
3672 } else if constexpr (N1 == 1 && N2 == 3) {
3673 const int mask = _mm_movemask_ps(_mm_cmpgt_ps(_mm_set1_ps(detail::toQuantity(a)._private_value), detail::toQuantity(b)._private_value));
3674 return bvec3{static_cast<bool>(mask & 0b001), static_cast<bool>(mask & 0b010), static_cast<bool>(mask & 0b100)};
3675 } else if constexpr (N1 == 3 && N2 == 1) {
3676 const int mask = _mm_movemask_ps(_mm_cmpgt_ps(detail::toQuantity(a)._private_value, _mm_set1_ps(detail::toQuantity(b)._private_value)));
3677 return bvec3{static_cast<bool>(mask & 0b001), static_cast<bool>(mask & 0b010), static_cast<bool>(mask & 0b100)};
3678 } else {
3679 return grem::greaterThan(detail::toQuantity(a)._private_getUnderlyingValue(), detail::toQuantity(b)._private_getUnderlyingValue());
3680 }
3681#else
3682 return grem::greaterThan(detail::toQuantity(a)._private_value, detail::toQuantity(b)._private_value);
3683#endif
3684}
3685
3686template <detail::quantity_unary_operand A>
3687[[nodiscard]] GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL greaterThan(A a, Zero) {
3688 return greaterThan(a, A{});
3689}
3690
3691template <detail::quantity_unary_operand B>
3692[[nodiscard]] GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL greaterThan(Zero, B b) {
3693 return greaterThan(B{}, b);
3694}
3695
3696template <detail::quantity_binary_operand_a A, detail::quantity_binary_operand_b<A> B>
3697[[nodiscard]] GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL greaterThanEqual(A a, B b) {
3698 using UnitT = detail::unit_type_t<A>;
3699 static_assert(detail::unit_type_t<B>{} == UnitT{}, "Quantities of different units cannot be compared.");
3700#if defined(GREM_USE_SSE_INTRINSICS) && !defined(GREM_PHYSICS_USE_DOUBLE_PRECISION)
3701 constexpr size_t N1 = detail::quantity_rank_v<A>;
3702 constexpr size_t N2 = detail::quantity_rank_v<B>;
3703 if constexpr (N1 == 3 && N2 == 3) {
3704 const int mask = _mm_movemask_ps(_mm_cmpge_ps(detail::toQuantity(a)._private_value, detail::toQuantity(b)._private_value));
3705 return bvec3{static_cast<bool>(mask & 0b001), static_cast<bool>(mask & 0b010), static_cast<bool>(mask & 0b100)};
3706 } else if constexpr (N1 == 1 && N2 == 3) {
3707 const int mask = _mm_movemask_ps(_mm_cmpge_ps(_mm_set1_ps(detail::toQuantity(a)._private_value), detail::toQuantity(b)._private_value));
3708 return bvec3{static_cast<bool>(mask & 0b001), static_cast<bool>(mask & 0b010), static_cast<bool>(mask & 0b100)};
3709 } else if constexpr (N1 == 3 && N2 == 1) {
3710 const int mask = _mm_movemask_ps(_mm_cmpge_ps(detail::toQuantity(a)._private_value, _mm_set1_ps(detail::toQuantity(b)._private_value)));
3711 return bvec3{static_cast<bool>(mask & 0b001), static_cast<bool>(mask & 0b010), static_cast<bool>(mask & 0b100)};
3712 } else {
3713 return grem::greaterThanEqual(detail::toQuantity(a)._private_getUnderlyingValue(), detail::toQuantity(b)._private_getUnderlyingValue());
3714 }
3715#else
3716 return grem::greaterThanEqual(detail::toQuantity(a)._private_value, detail::toQuantity(b)._private_value);
3717#endif
3718}
3719
3720template <detail::quantity_unary_operand A>
3721[[nodiscard]] GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL greaterThanEqual(A a, Zero) {
3722 return greaterThanEqual(a, A{});
3723}
3724
3725template <detail::quantity_unary_operand B>
3726[[nodiscard]] GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL greaterThanEqual(Zero, B b) {
3727 return greaterThanEqual(B{}, b);
3728}
3729
3730template <detail::quantity_binary_operand_a A, detail::quantity_binary_operand_b<A> B>
3731[[nodiscard]] GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL clampLength(A value, B maxLength) {
3732 constexpr size_t N = detail::quantity_rank_v<A>;
3733 using UnitT = detail::unit_type_t<A>;
3734 static_assert(detail::unit_type_t<B>{} == UnitT{}, "Quantities of different units cannot be clamped.");
3735 static_assert(!UnitT::MagnitudeType::IS_ABSOLUTE, "Quantity of this unit cannot have its length clamped because it represents an absolute position.");
3736 return Quantity<N, UnitT>::reinterpret(grem::clampLength(detail::toQuantity(value)._private_getUnderlyingValue(), detail::toQuantity(maxLength)._private_getUnderlyingValue()));
3737}
3738
3739template <size_t N, typename UnitT>
3742 using Unit = UnitT;
3743 using DimensionType = typename Unit::DimensionType;
3744 using MagnitudeType = typename Unit::MagnitudeType;
3745 static constexpr size_t RANK = N;
3746 static constexpr Unit UNIT{};
3747 static constexpr DimensionType DIMENSION{};
3748 static constexpr MagnitudeType MAGNITUDE{};
3749
3750 template <typename OtherUnitT>
3752 return TensorQuantity{other._private_value};
3753 }
3754
3755 [[nodiscard]] GREM_ALWAYS_INLINE static constexpr TensorQuantity reinterpret(const mat<N, N, float>& value) {
3756 return TensorQuantity{value};
3757 }
3758
3759 [[nodiscard]] GREM_ALWAYS_INLINE static constexpr TensorQuantity reinterpret(const mat<N, N, double>& value) {
3760 return TensorQuantity{value};
3761 }
3762
3763 mat<N, N, Scalar> _private_value{Scalar{1}};
3764
3765 constexpr TensorQuantity() noexcept = default;
3766
3767 constexpr TensorQuantity(const mat<N, N, float>& value) noexcept requires(DIMENSION == DIMENSIONLESS && MagnitudeType::VALUE == 1.0l)
3768 : _private_value(value) {}
3769
3770 constexpr TensorQuantity(const mat<N, N, double>& value) noexcept requires(DIMENSION == DIMENSIONLESS && MagnitudeType::VALUE == 1.0l)
3771 : _private_value(value) {}
3772
3773 constexpr TensorQuantity(Quantity<1, UnitT> value) noexcept
3774 : _private_value{value._private_value} {}
3775
3776 constexpr TensorQuantity(Component x, Component y) noexcept requires(N == 2)
3777 : _private_value{x._private_getUnderlyingValue(), y._private_getUnderlyingValue()} {}
3778
3779 constexpr TensorQuantity(Component x, Component y, Component z) noexcept requires(N == 3)
3780 : _private_value{x._private_getUnderlyingValue(), y._private_getUnderlyingValue(), z._private_getUnderlyingValue()} {}
3781
3782 [[nodiscard]] GREM_ALWAYS_INLINE constexpr operator mat<N, N, float>() const requires(DIMENSION == DIMENSIONLESS && MagnitudeType::VALUE == 1.0l) {
3783 return mat<N, N, float>{_private_value};
3784 }
3785
3786 [[nodiscard]] GREM_ALWAYS_INLINE constexpr operator mat<N, N, double>() const requires(DIMENSION == DIMENSIONLESS && MagnitudeType::VALUE == 1.0l) {
3787 return mat<N, N, double>{_private_value};
3788 }
3789
3791 if constexpr (N == 2) {
3792 return {length(Component::reinterpret(_private_value[0])), length(Component::reinterpret(_private_value[1]))};
3793 } else if constexpr (N == 3) {
3794 return {length(Component::reinterpret(_private_value[0])), length(Component::reinterpret(_private_value[1])), length(Component::reinterpret(_private_value[2]))};
3795 }
3796 }
3797
3799 if constexpr (N == 2) {
3800 return {length2(Component::reinterpret(_private_value[0])), length2(Component::reinterpret(_private_value[1]))};
3801 } else if constexpr (N == 3) {
3802 return {length2(Component::reinterpret(_private_value[0])), length2(Component::reinterpret(_private_value[1])), length2(Component::reinterpret(_private_value[2]))};
3803 }
3804 }
3805
3806 [[nodiscard]] GREM_ALWAYS_INLINE constexpr bool operator==(const TensorQuantity& other) const noexcept {
3807 return _private_value == other._private_value;
3808 }
3809
3810 template <typename OtherUnitT>
3811 [[nodiscard]] GREM_ALWAYS_INLINE constexpr bool operator==(const TensorQuantity<N, OtherUnitT>& other) const noexcept requires(UnitT{} == OtherUnitT{}) {
3812 return _private_value == other._private_value;
3813 }
3814
3815 [[nodiscard]] GREM_ALWAYS_INLINE constexpr bool operator==(Zero) const noexcept {
3816 return *this == TensorQuantity{mat<N, N, Scalar>{Scalar{0}}};
3817 }
3818
3819 template <size_t Index>
3821 static_assert(Index < RANK, "Swizzle component index out of range.");
3822 return Component::reinterpret(_private_value[Index]);
3823 }
3824
3825 template <size_t Index>
3827 static_assert(Index < RANK, "Swizzle component index out of range.");
3828 return Component::reinterpret(_private_value[Index]);
3829 }
3830
3831 template <size_t Index>
3833 static_assert(Index < RANK, "Swizzle component index out of range.");
3834 return Component::reinterpret(_private_value[Index]);
3835 }
3836
3837 template <size_t Index>
3839 static_assert(Index < RANK, "Swizzle component index out of range.");
3840 return Component::reinterpret(_private_value[Index]);
3841 }
3842
3843 [[nodiscard]] GREM_ALWAYS_INLINE constexpr size_t size() const noexcept {
3844 return N;
3845 }
3846
3847private:
3848 constexpr explicit TensorQuantity(const mat<N, N, float>& value) noexcept requires(DIMENSION != DIMENSIONLESS || MagnitudeType::VALUE != 1.0l)
3849 : _private_value(value) {}
3850
3851 constexpr explicit TensorQuantity(const mat<N, N, double>& value) noexcept requires(DIMENSION != DIMENSIONLESS || MagnitudeType::VALUE != 1.0l)
3852 : _private_value(value) {}
3853};
3854
3855template <size_t N, typename UnitT>
3856requires(N == 2 || N == 3) //
3857using AngularTensorQuantity = std::conditional_t<N == 3, TensorQuantity<3, UnitT>, Quantity<1, UnitT>>;
3858
3859template <size_t N, typename UnitT>
3860[[nodiscard]] GREM_ALWAYS_INLINE constexpr auto inverse(Quantity<N, UnitT> a) {
3861 return Quantity<N, Reciprocal<UnitT>>::reinterpret(Scalar{1} / a._private_getUnderlyingValue());
3862}
3863
3864template <size_t N, typename UnitT>
3865[[nodiscard]] GREM_ALWAYS_INLINE constexpr auto inverse(const TensorQuantity<N, UnitT>& a) {
3866 return TensorQuantity<N, Reciprocal<UnitT>>::reinterpret(grem::inverse(a._private_value));
3867}
3868
3869template <size_t N, typename UnitT>
3870[[nodiscard]] GREM_ALWAYS_INLINE constexpr auto transpose(const TensorQuantity<N, UnitT>& a) {
3871 return TensorQuantity<N, Reciprocal<UnitT>>::reinterpret(grem::transpose(a._private_value));
3872}
3873
3874template <size_t N, typename UnitT>
3875[[nodiscard]] GREM_ALWAYS_INLINE constexpr auto inverseTranspose(const TensorQuantity<N, UnitT>& a) {
3877}
3878
3879template <size_t N, typename UnitT1, typename UnitT2>
3881 static_assert(detail::can_add<UnitT1, UnitT2>, "Quantities of these units cannot be added.");
3882 return TensorQuantity<N, Sum<UnitT1, UnitT2>>::reinterpret(a._private_value + b._private_value);
3883}
3884
3885template <size_t N, typename UnitT1, typename UnitT2>
3887 static_assert(detail::can_subtract<UnitT1, UnitT2>, "Quantities of these units cannot be subtracted.");
3888 return TensorQuantity<N, Difference<UnitT1, UnitT2>>::reinterpret(a._private_value - b._private_value);
3889}
3890
3891template <size_t N, typename UnitT1, typename UnitT2>
3893 static_assert(detail::can_multiply<UnitT1, UnitT2>, "Quantities of these units cannot be multiplied.");
3894 return TensorQuantity<N, Product<UnitT1, UnitT2>>::reinterpret(a._private_value * b._private_value);
3895}
3896
3897template <size_t N1, typename UnitT1, detail::quantity_convertible B>
3899 constexpr size_t N2 = detail::quantity_rank_v<B>;
3900 using UnitT2 = detail::unit_type_t<B>;
3901 static_assert(detail::can_multiply<UnitT1, UnitT2>, "Quantities of these units cannot be multiplied.");
3902 return Quantity<grem::max(N1, N2), Product<UnitT1, UnitT2>>::reinterpret(a._private_value * detail::toQuantity(b)._private_getUnderlyingValue());
3903}
3904
3905template <size_t N2, typename UnitT2, detail::quantity_convertible A>
3907 constexpr size_t N1 = detail::quantity_rank_v<A>;
3908 using UnitT1 = detail::unit_type_t<A>;
3909 static_assert(detail::can_multiply<UnitT1, UnitT2>, "Quantities of these units cannot be multiplied.");
3910 return TensorQuantity<grem::max(N1, N2), Product<UnitT1, UnitT2>>::reinterpret(detail::toQuantity(a)._private_getUnderlyingValue() * b._private_value);
3911}
3912
3913template <size_t N, typename UnitT1, typename UnitT2>
3915 static_assert(detail::can_multiply<UnitT1, UnitT2>, "Quantities of these units cannot be multiplied.");
3916 if constexpr (N == 2) {
3918 dot(a[X], b[X]),
3919 dot(a[Y], b[Y]),
3920 };
3921 } else if constexpr (N == 3) {
3923 dot(a[X], b[X]),
3924 dot(a[Y], b[Y]),
3925 dot(a[Z], b[Z]),
3926 };
3927 }
3928}
3929
3930template <detail::quantity_convertible A, size_t N2, typename UnitT2>
3931[[nodiscard]] GREM_ALWAYS_INLINE auto cross(A a, const TensorQuantity<N2, UnitT2>& b) {
3932 constexpr size_t N1 = detail::quantity_rank_v<A>;
3933 using UnitT1 = detail::unit_type_t<A>;
3934 static_assert(detail::can_multiply<UnitT1, UnitT2>, "Quantities of these units cannot be multiplied.");
3935 if constexpr (N1 == 2 && N2 == 2) {
3939 };
3940 } else if constexpr (N1 == 3 && N2 == 3) {
3942 cross(a, b[X]),
3943 cross(a, b[Y]),
3944 cross(a, b[Z]),
3945 };
3946 }
3947}
3948
3949template <size_t N, typename UnitT>
3950[[nodiscard]] decltype(auto) getNormalComponent(Quantity<N, UnitT>& v) {
3951 if constexpr (N == 2) {
3952 return v[Y];
3953 } else if constexpr (N == 3) {
3954 return v[Z];
3955 }
3956}
3957
3958template <size_t N, typename UnitT>
3959[[nodiscard]] decltype(auto) getNormalComponent(const Quantity<N, UnitT>& v) {
3960 if constexpr (N == 2) {
3961 return v[Y];
3962 } else if constexpr (N == 3) {
3963 return v[Z];
3964 }
3965}
3966
3967template <size_t N, typename UnitT>
3968[[nodiscard]] auto getTangentialComponent(const Quantity<N, UnitT>& v) {
3969 if constexpr (N == 2) {
3970 return v.getX();
3971 } else if constexpr (N == 3) {
3972 return v.get(X, Y);
3973 }
3974}
3975
3983template <size_t N>
3989
3997template <size_t N>
4001
4009template <size_t N>
4013
4020
4024inline constexpr Angle PI{numbers::pi_v<Scalar>};
4025
4032
4040template <size_t N>
4042
4049
4056
4063
4070
4077
4084
4092template <size_t N>
4096
4104template <size_t N>
4105struct Direction : Scale<N> {
4106 static_assert(N == 2 || N == 3);
4107
4108 using typename Scale<N>::Component;
4109 using typename Scale<N>::Unit;
4110 using typename Scale<N>::DimensionType;
4111 using typename Scale<N>::MagnitudeType;
4112 using Scale<N>::RANK;
4113 using Scale<N>::UNIT;
4114 using Scale<N>::DIMENSION;
4115 using Scale<N>::MAGNITUDE;
4116
4117 [[nodiscard]] GREM_ALWAYS_INLINE static constexpr Direction reinterpret(auto other) {
4118 return Direction{Scale<N>::reinterpret(other)};
4119 }
4120
4121 GREM_ALWAYS_INLINE constexpr Direction() noexcept
4122 : Scale<N>([]() -> Scale<N> {
4123 if constexpr (N == 3) {
4124 return {Scalar{0}, Scalar{0}, Scalar{-1}};
4125 } else {
4126 return {Scalar{1}, Scalar{0}};
4127 }
4128 }()) {}
4129
4130 [[nodiscard]] GREM_ALWAYS_INLINE constexpr bool operator==(const Direction& other) const noexcept {
4131 return static_cast<const Scale<N>&>(*this) == static_cast<const Scale<N>&>(other);
4132 }
4133
4134 template <typename OtherUnitT>
4135 [[nodiscard]] GREM_ALWAYS_INLINE constexpr bool operator==(const Quantity<2, OtherUnitT>& other) const noexcept requires(UNIT == OtherUnitT{}) {
4136 return static_cast<const Scale<N>&>(*this) == other;
4137 }
4138
4139 [[nodiscard]] GREM_ALWAYS_INLINE constexpr bool operator==(Zero other) const noexcept {
4140 return static_cast<const Scale<N>&>(*this) == other;
4141 }
4142
4143 [[nodiscard]] GREM_ALWAYS_INLINE constexpr Direction GREM_VECTORCALL operator-() const {
4144 return Direction{-static_cast<const Scale<N>&>(*this)};
4145 }
4146
4147private:
4148 GREM_ALWAYS_INLINE constexpr explicit Direction(Scale<N> scale)
4149 : Scale<N>(scale) {}
4150};
4153
4154template <detail::quantity_unary_operand A>
4155[[nodiscard]] GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL flipSignIf(A a, bool b) {
4156 constexpr size_t N = detail::quantity_rank_v<A>;
4157 using UnitT = detail::unit_type_t<A>;
4158#if defined(GREM_USE_SSE_INTRINSICS) && !defined(GREM_PHYSICS_USE_DOUBLE_PRECISION)
4159 if constexpr (N == 3) {
4160 return Quantity<N, UnitT>::reinterpret(_mm_xor_ps(_mm_set1_ps(bit_cast<float32_t>(static_cast<uint32_t>(b) << 31)), detail::toQuantity(a)._private_value));
4161 } else {
4162 return Quantity<N, UnitT>::reinterpret(grem::flipSignIf(detail::toQuantity(a)._private_value, b));
4163 }
4164#else
4165 return Quantity<N, UnitT>::reinterpret(grem::flipSignIf(detail::toQuantity(a)._private_value, b));
4166#endif
4167}
4168
4169template <size_t N>
4170[[nodiscard]] GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL flipSignIf(Direction<N> a, bool b) {
4171 return Direction<N>::reinterpret(flipSignIf(static_cast<const Scale<N>&>(a), b));
4172}
4173
4174template <detail::quantity_binary_operand_a A, detail::quantity_binary_operand_b<A> B>
4175[[nodiscard]] GREM_ALWAYS_INLINE auto GREM_VECTORCALL copysign(A a, B b) {
4176 constexpr size_t N = detail::quantity_rank_v<A>;
4177 using UnitT = detail::unit_type_t<A>;
4178 return Quantity<N, UnitT>::reinterpret(grem::copysign(detail::toQuantity(a)._private_getUnderlyingValue(), detail::toQuantity(b)._private_getUnderlyingValue()));
4179}
4180
4181template <size_t N, detail::quantity_binary_operand_b<Direction<N>> B>
4182[[nodiscard]] GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL copysign(Direction<N> a, B b) {
4183 return Direction<N>::reinterpret(copysign(static_cast<const Scale<N>&>(a), b));
4184}
4185
4186template <detail::quantity_unary_operand A>
4187[[nodiscard]] GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL normalize(A a) {
4188 constexpr size_t N = detail::quantity_rank_v<A>;
4189 using UnitT = detail::unit_type_t<A>;
4190 static_assert(!UnitT::MagnitudeType::IS_ABSOLUTE, "Quantity of this unit cannot be normalized because it represents an absolute position.");
4193}
4194
4195template <size_t N>
4197 return a;
4198}
4199
4200template <detail::quantity_unary_operand A>
4201[[nodiscard]] GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL tryNormalize(A a) {
4202 constexpr size_t N = detail::quantity_rank_v<A>;
4203 using UnitT = detail::unit_type_t<A>;
4204 static_assert(!UnitT::MagnitudeType::IS_ABSOLUTE, "Quantity of this unit cannot be normalized because it represents an absolute position.");
4206 const Scale1D lengthSquared = length2(scale);
4207 if (lengthSquared > length2(Scale1D::MACHINE_EPSILON)) {
4208 return Optional<Direction<N>>{Direction<N>::reinterpret(scale / sqrt(lengthSquared))};
4209 }
4210 return Optional<Direction<N>>{};
4211}
4212
4213template <size_t N>
4215 return Optional<Direction<N>>{a};
4216}
4217
4218template <detail::quantity_unary_operand A>
4219[[nodiscard]] GREM_ALWAYS_INLINE constexpr auto rotate90DegreesCounterclockwise(A a) {
4220 constexpr size_t N = detail::quantity_rank_v<A>;
4221 using UnitT = detail::unit_type_t<A>;
4222 static_assert(N == 2, "Quantity cannot be rotated around an implicit axis because it is not 2D.");
4223 static_assert(!UnitT::MagnitudeType::IS_ABSOLUTE, "Quantity of this unit cannot be rotated because it represents an absolute position.");
4224 return Quantity<2, UnitT>{-a.getY(), a.getX()};
4225}
4226
4228 return Direction2D::reinterpret(Scale2D{-a._private_value.y, a._private_value.x});
4229}
4230
4231template <detail::quantity_unary_operand A>
4232[[nodiscard]] GREM_ALWAYS_INLINE constexpr auto rotate90DegreesClockwise(A a) {
4233 constexpr size_t N = detail::quantity_rank_v<A>;
4234 using UnitT = detail::unit_type_t<A>;
4235 static_assert(N == 2, "Quantity cannot be rotated around an implicit axis because it is not 2D.");
4236 static_assert(!UnitT::MagnitudeType::IS_ABSOLUTE, "Quantity of this unit cannot be rotated because it represents an absolute position.");
4237 return Quantity<2, UnitT>{a.getY(), -a.getX()};
4238}
4239
4241 return Direction2D::reinterpret(Scale2D{a._private_value.y, -a._private_value.x});
4242}
4243
4244template <detail::quantity_unary_operand A>
4245[[nodiscard]] GREM_ALWAYS_INLINE constexpr auto flipX(A a) {
4246 constexpr size_t N = detail::quantity_rank_v<A>;
4247 using UnitT = detail::unit_type_t<A>;
4248 static_assert(!UnitT::MagnitudeType::IS_ABSOLUTE, "Quantity of this unit cannot be flipped because it represents an absolute position.");
4249 return Quantity<N, UnitT>::reinterpret(grem::flipX(a._private_getUnderlyingValue()));
4250}
4251
4252template <size_t N>
4253[[nodiscard]] GREM_ALWAYS_INLINE constexpr auto flipX(Direction<N> a) {
4254 return Direction<N>::reinterpret(grem::flipX(a._private_getUnderlyingValue()));
4255}
4256
4257template <detail::quantity_unary_operand A>
4258[[nodiscard]] GREM_ALWAYS_INLINE constexpr auto flipY(A a) {
4259 constexpr size_t N = detail::quantity_rank_v<A>;
4260 using UnitT = detail::unit_type_t<A>;
4261 static_assert(N >= 2, "Quantity cannot be flipped on the Y axis because it has fewer than 2 dimensions.");
4262 static_assert(!UnitT::MagnitudeType::IS_ABSOLUTE, "Quantity of this unit cannot be flipped because it represents an absolute position.");
4263 return Quantity<N, UnitT>::reinterpret(grem::flipY(a._private_getUnderlyingValue()));
4264}
4265
4266template <size_t N>
4267[[nodiscard]] GREM_ALWAYS_INLINE constexpr auto flipY(Direction<N> a) requires(N >= 2) {
4268 return Direction<N>::reinterpret(grem::flipY(a._private_getUnderlyingValue()));
4269}
4270
4271template <detail::quantity_unary_operand A>
4272[[nodiscard]] GREM_ALWAYS_INLINE constexpr auto flipZ(A a) {
4273 constexpr size_t N = detail::quantity_rank_v<A>;
4274 using UnitT = detail::unit_type_t<A>;
4275 static_assert(N >= 2, "Quantity cannot be flipped on the Z axis because it has fewer than 3 dimensions.");
4276 static_assert(!UnitT::MagnitudeType::IS_ABSOLUTE, "Quantity of this unit cannot be flipped because it represents an absolute position.");
4277 return Quantity<N, UnitT>::reinterpret(grem::flipZ(a._private_getUnderlyingValue()));
4278}
4279
4280template <size_t N>
4281[[nodiscard]] GREM_ALWAYS_INLINE constexpr auto flipZ(Direction<N> a) requires(N >= 3) {
4282 return Direction<N>::reinterpret(grem::flipZ(a._private_getUnderlyingValue()));
4283}
4284
4285template <size_t N, typename UnitT>
4290
4291template <detail::quantity_unary_operand A>
4292[[nodiscard]] GREM_ALWAYS_INLINE constexpr auto decomposeMagnitudeDirection(A a) {
4293 constexpr size_t N = detail::quantity_rank_v<A>;
4294 const auto magnitude = length(a);
4296}
4297
4298template <detail::quantity_unary_operand A>
4299[[nodiscard]] GREM_ALWAYS_INLINE constexpr auto tryDecomposeMagnitudeDirection(A a) {
4300 constexpr size_t N = detail::quantity_rank_v<A>;
4301 using R = decltype(decomposeMagnitudeDirection(a));
4302 const auto magnitude = length(a);
4303 if (magnitude > decltype(magnitude)::MACHINE_EPSILON) {
4305 }
4306 return Optional<R>{};
4307}
4308
4309template <typename UnitT>
4314
4315template <detail::quantity_unary_operand A>
4316[[nodiscard]] GREM_ALWAYS_INLINE constexpr auto decomposeMagnitudeAngle(A a) {
4318}
4319
4320template <detail::quantity_unary_operand A>
4321[[nodiscard]] GREM_ALWAYS_INLINE constexpr auto tryDecomposeMagnitudeAngle(A a) {
4322 using R = decltype(decomposeMagnitudeAngle(a));
4323 const auto magnitude = length(a);
4324 if (magnitude > decltype(magnitude)::MACHINE_EPSILON) {
4326 }
4327 return Optional<R>{};
4328}
4329
4337template <size_t N>
4338struct OrthonormalBasis : Basis<N> {
4339 static_assert(N == 2 || N == 3);
4340
4342 using typename Basis<N>::Unit;
4343 using typename Basis<N>::DimensionType;
4344 using typename Basis<N>::MagnitudeType;
4345 using Basis<N>::RANK;
4346 using Basis<N>::UNIT;
4347 using Basis<N>::DIMENSION;
4348 using Basis<N>::MAGNITUDE;
4349
4350 [[nodiscard]] GREM_ALWAYS_INLINE static constexpr OrthonormalBasis reinterpret(const auto& value) {
4351 return OrthonormalBasis{Basis<N>::reinterpret(value)};
4352 }
4353
4354 [[nodiscard]] GREM_ALWAYS_INLINE constexpr bool operator==(const OrthonormalBasis& other) const noexcept {
4355 return static_cast<const Basis<N>&>(*this) == static_cast<const Basis<N>&>(other);
4356 }
4357
4358 template <typename OtherUnitT>
4359 [[nodiscard]] GREM_ALWAYS_INLINE constexpr bool operator==(const TensorQuantity<N, OtherUnitT>& other) const noexcept requires(UNIT == OtherUnitT{}) {
4360 return static_cast<const Basis<N>&>(*this) == other;
4361 }
4362
4363 [[nodiscard]] GREM_ALWAYS_INLINE constexpr bool operator==(Zero other) const noexcept {
4364 return static_cast<const Basis<N>&>(*this) == other;
4365 }
4366
4367 template <size_t Index>
4369 static_assert(Index < RANK, "Swizzle component index out of range.");
4370 return Component::reinterpret(this->_private_value[Index]);
4371 }
4372
4373 template <size_t Index>
4375 static_assert(Index < RANK, "Swizzle component index out of range.");
4376 return Component::reinterpret(this->_private_value[Index]);
4377 }
4378
4379 template <size_t Index>
4381 static_assert(Index < RANK, "Swizzle component index out of range.");
4382 return Component::reinterpret(this->_private_value[Index]);
4383 }
4384
4385 template <size_t Index>
4387 static_assert(Index < RANK, "Swizzle component index out of range.");
4388 return Component::reinterpret(this->_private_value[Index]);
4389 }
4390
4391 [[nodiscard]] GREM_ALWAYS_INLINE constexpr OrthonormalBasis GREM_VECTORCALL operator-() const {
4392 return OrthonormalBasis{-static_cast<const Basis<N>&>(*this)};
4393 }
4394
4395 [[nodiscard]] GREM_ALWAYS_INLINE OrthonormalBasis GREM_VECTORCALL operator*(const OrthonormalBasis& other) const {
4396 return OrthonormalBasis::reinterpret(static_cast<const Basis<N>&>(*this) * static_cast<const Basis<N>&>(other));
4397 }
4398
4400 return Direction<N>::reinterpret(static_cast<const Basis<N>&>(*this) * static_cast<const Scale<N>&>(direction));
4401 }
4402
4403private:
4404 GREM_ALWAYS_INLINE constexpr explicit OrthonormalBasis(const Basis<N>& basis)
4405 : Basis<N>(basis) {}
4406};
4409
4410template <size_t N>
4411[[nodiscard]] GREM_ALWAYS_INLINE constexpr auto transpose(const OrthonormalBasis<N>& a) {
4412 return OrthonormalBasis<N>::reinterpret(grem::transpose(a._private_value));
4413}
4414
4415template <size_t N>
4416[[nodiscard]] GREM_ALWAYS_INLINE constexpr auto inverse(const OrthonormalBasis<N>& a) {
4417 return transpose(a);
4418}
4419
4420template <size_t N>
4421[[nodiscard]] GREM_ALWAYS_INLINE constexpr auto inverseTranspose(const OrthonormalBasis<N>& a) {
4422 return a;
4423}
4424
4430template <size_t N>
4432
4438template <>
4439struct Orientation<2> {
4443 static constexpr size_t RANK = 1;
4444 static constexpr Unit UNIT{};
4445 static constexpr DimensionType DIMENSION{};
4446 static constexpr MagnitudeType MAGNITUDE{};
4447
4448 Scalar _private_value{};
4449
4450 GREM_ALWAYS_INLINE constexpr Orientation() noexcept = default;
4451
4452 GREM_ALWAYS_INLINE constexpr Orientation(float angle) noexcept
4453 : _private_value(static_cast<Scalar>(angle)) {}
4454
4455 GREM_ALWAYS_INLINE constexpr Orientation(double angle) noexcept
4456 : _private_value(static_cast<Scalar>(angle)) {}
4457
4458 template <typename OtherUnitT>
4459 GREM_ALWAYS_INLINE constexpr Orientation(Quantity<1, OtherUnitT> angle) noexcept requires(OtherUnitT::DIMENSION == DIMENSION)
4460 : _private_value(angle.in(UNIT)) {}
4461
4462 [[nodiscard]] GREM_ALWAYS_INLINE constexpr operator float() const {
4463 return static_cast<float>(_private_value);
4464 }
4465
4466 [[nodiscard]] GREM_ALWAYS_INLINE constexpr operator double() const {
4467 return static_cast<double>(_private_value);
4468 }
4469
4470 template <typename OtherUnitT>
4471 [[nodiscard]] GREM_ALWAYS_INLINE constexpr operator Quantity<1, OtherUnitT>() const requires(OtherUnitT::DIMENSION == DIMENSION) {
4472 return Quantity<1, OtherUnitT>{_private_value * RADIANS};
4473 }
4474
4475 template <unit OtherUnitT>
4476 [[nodiscard]] GREM_ALWAYS_INLINE constexpr Quantity<1, Unitless> in(OtherUnitT) const requires(OtherUnitT::DIMENSION == DIMENSION) {
4477 if constexpr (OtherUnitT::MagnitudeType::VALUE == MagnitudeType::VALUE) {
4478 return Quantity<1, Unitless>{_private_value};
4479 } else {
4480 constexpr Scalar factor = static_cast<Scalar>(MagnitudeType::VALUE / OtherUnitT::MagnitudeType::VALUE);
4481 return _private_value * factor;
4482 }
4483 }
4484
4485 [[nodiscard]] GREM_ALWAYS_INLINE constexpr bool operator==(const Orientation&) const noexcept = default;
4486
4487 template <typename UnitT>
4489 return (mat<2, 2, Scalar>{grem::rotate(_private_value)} * b._private_getUnderlyingValue()) * UnitT{};
4490 }
4491
4493 return Direction2D::reinterpret(mat<2, 2, Scalar>{grem::rotate(_private_value)} * b._private_value);
4494 }
4495
4496 template <typename UnitT>
4500
4501 [[nodiscard]] GREM_ALWAYS_INLINE constexpr size_t size() const noexcept {
4502 return 1;
4503 }
4504};
4505
4511template <>
4512struct Orientation<3> {
4517 static constexpr size_t RANK = 4;
4518 static constexpr Unit UNIT{};
4519 static constexpr DimensionType DIMENSION{};
4520 static constexpr MagnitudeType MAGNITUDE{};
4521
4522 [[nodiscard]] GREM_ALWAYS_INLINE static Orientation rotation(Scale3D from, Scale3D to) {
4524 }
4525
4526 [[nodiscard]] GREM_ALWAYS_INLINE static Orientation lookAt(Scale3D direction, Scale3D up) {
4528 }
4529
4531 return Orientation{grem::angleAxis(Scalar{angle.in(RADIANS)}, vec<3, Scalar>{axis})};
4532 }
4533
4535 return Orientation{grem::pitch(Scalar{angle})};
4536 }
4537
4538 [[nodiscard]] GREM_ALWAYS_INLINE static Orientation yaw(AbsoluteAngle angle) {
4539 return Orientation{grem::yaw(Scalar{angle})};
4540 }
4541
4542 [[nodiscard]] GREM_ALWAYS_INLINE static Orientation roll(AbsoluteAngle angle) {
4543 return Orientation{grem::roll(Scalar{angle})};
4544 }
4545
4546 [[nodiscard]] GREM_ALWAYS_INLINE static Orientation fromAngles(AbsoluteAngle pitchAngle, AbsoluteAngle yawAngle, AbsoluteAngle rollAngle) {
4547 return Orientation{grem::convertAnglesToQuaternion(Scalar{pitchAngle}, Scalar{yawAngle}, Scalar{rollAngle})};
4548 }
4549
4553
4557
4558 qua<Scalar> _private_value{Scalar{0}, Scalar{0}, Scalar{0}, Scalar{1}};
4559
4560 GREM_ALWAYS_INLINE constexpr Orientation() noexcept = default;
4561
4562 GREM_ALWAYS_INLINE constexpr Orientation(qua<float> quaternion) noexcept
4563 : _private_value(quaternion) {}
4564
4565 GREM_ALWAYS_INLINE constexpr Orientation(qua<double> quaternion) noexcept
4566 : _private_value(quaternion) {}
4567
4568 [[nodiscard]] GREM_ALWAYS_INLINE constexpr operator qua<float>() const {
4569 return qua<float>{_private_value};
4570 }
4571
4572 [[nodiscard]] GREM_ALWAYS_INLINE constexpr operator qua<double>() const {
4573 return qua<double>{_private_value};
4574 }
4575
4576 [[nodiscard]] GREM_ALWAYS_INLINE constexpr bool operator==(const Orientation&) const noexcept = default;
4577
4578 template <typename UnitT>
4580 return (_private_value * b._private_getUnderlyingValue()) * UnitT{};
4581 }
4582
4584 return Direction3D::reinterpret(_private_value * b._private_getUnderlyingValue());
4585 }
4586
4587 [[nodiscard]] GREM_ALWAYS_INLINE constexpr size_t size() const noexcept {
4588 return 4;
4589 }
4590};
4591
4594
4596 return grem::isfinite(a._private_value);
4597}
4598
4600 return grem::isfinite(vec<4, Scalar>{a._private_value.x, a._private_value.y, a._private_value.z, a._private_value.w});
4601}
4602
4604 return grem::isinf(a._private_value);
4605}
4606
4608 return grem::isinf(vec<4, Scalar>{a._private_value.x, a._private_value.y, a._private_value.z, a._private_value.w});
4609}
4610
4612 return grem::isnan(a._private_value);
4613}
4614
4616 return grem::isnan(vec<4, Scalar>{a._private_value.x, a._private_value.y, a._private_value.z, a._private_value.w});
4617}
4618
4620 return Orientation2D{-a._private_value};
4621}
4622
4626
4628 return Orientation2D{Scalar{a} + b.in(RADIANS)};
4629}
4630
4634
4638
4642
4643template <size_t N>
4647
4649 const Scalar x = Angle{a}.in(RADIANS);
4650 const Scalar y = Angle{b}.in(RADIANS);
4651 constexpr Scalar HALF_TURN = numbers::pi_v<Scalar>;
4652 constexpr Scalar FULL_TURN = Scalar{2} * HALF_TURN;
4653 return (grem::wrap(x - y + HALF_TURN, FULL_TURN) - HALF_TURN) * RADIANS;
4654}
4655
4657 const qua<Scalar> delta = qua<Scalar>{a} * qua<Scalar>{inverse(b)};
4658 const vec<3, Scalar> difference = Scalar{2} * vec<3, Scalar>{delta.x, delta.y, delta.z};
4659 return grem::flipSignIf(difference, grem::signbit(delta.w)) * RADIANS;
4660}
4661
4663 return Orientation2D{Scalar{a} - b.in(RADIANS)};
4664}
4665
4669
4670template <size_t N>
4674
4678
4682
4686
4690
4694
4698
4700 return slerp(a, b, alpha);
4701}
4702
4704 return slerp(a, b, alpha);
4705}
4706
4707template <size_t N, typename UnitT>
4709 if constexpr (N == 2) {
4711 vec<2, Scalar>{s.getX()._private_value, Scalar{0}},
4712 vec<2, Scalar>{Scalar{0}, s.getY()._private_value},
4713 });
4714 } else if constexpr (N == 3) {
4716 vec<3, Scalar>{s.getX()._private_value, Scalar{0}, Scalar{0}},
4717 vec<3, Scalar>{Scalar{0}, s.getY()._private_value, Scalar{0}},
4718 vec<3, Scalar>{Scalar{0}, Scalar{0}, s.getZ()._private_value},
4719 });
4720 }
4721}
4722
4726
4730
4734
4735template <size_t N>
4737 if constexpr (N == 2) {
4739 } else if constexpr (N == 3) {
4741 }
4742}
4743
4747
4751
4755
4756template <size_t N, typename UnitT>
4758 if constexpr (N == 3) {
4759 const qua<Scalar> rotation{r};
4760 const vec<3, Scalar> scale{s._private_getUnderlyingValue()};
4762 (Scalar{1} - Scalar{2} * (rotation.y * rotation.y + rotation.z * rotation.z)) * scale.x,
4763 (rotation.x * rotation.y + rotation.z * rotation.w) * scale.x * Scalar{2},
4764 (rotation.x * rotation.z - rotation.y * rotation.w) * scale.x * Scalar{2},
4765 (rotation.x * rotation.y - rotation.z * rotation.w) * scale.y * Scalar{2},
4766 (Scalar{1} - Scalar{2} * (rotation.x * rotation.x + rotation.z * rotation.z)) * scale.y,
4767 (rotation.y * rotation.z + rotation.x * rotation.w) * scale.y * Scalar{2},
4768 (rotation.x * rotation.z + rotation.y * rotation.w) * scale.z * Scalar{2},
4769 (rotation.y * rotation.z - rotation.x * rotation.w) * scale.z * Scalar{2},
4770 (Scalar{1} - Scalar{2} * (rotation.x * rotation.x + rotation.y * rotation.y)) * scale.z,
4771 });
4772 } else {
4773 return rotate(r) * scale(s);
4774 }
4775}
4776
4778 return orientation;
4779}
4780
4782 return grem::getAngle(qua<Scalar>{orientation});
4783}
4784
4787}
4788
4790 return grem::getPitch(qua<Scalar>{orientation});
4791}
4792
4794 return grem::getYaw(qua<Scalar>{orientation});
4795}
4796
4798 return orientation;
4799}
4800
4802 return grem::getRoll(qua<Scalar>{orientation});
4803}
4804
4806 return {getPitch(orientation), getYaw(orientation), getRoll(orientation)};
4807}
4808
4812
4816
4820
4824
4826 return PitchYaw::reinterpret(grem::convertForwardDirectionToAngles(vec<3, Scalar>{forward}));
4827}
4828
4838 return wrap((b - a) + PI, Scalar{2} * PI) - PI;
4839}
4840
4851template <typename UnitT>
4852[[nodiscard]] inline Angle getAngleDifferenceAroundAxis(Direction3D axis, Quantity<3, UnitT> a, Quantity<3, UnitT> b) requires(!UnitT::MagnitudeType::IS_ABSOLUTE) {
4853 return atan2(dot(cross(a, b), axis), dot(a, b));
4854}
4855
4861template <size_t N>
4863template <>
4867});
4868template <>
4870 vec<3, Scalar>{Scalar{1}, Scalar{0}, Scalar{0}},
4871 vec<3, Scalar>{Scalar{0}, Scalar{1}, Scalar{0}},
4872 vec<3, Scalar>{Scalar{0}, Scalar{0}, Scalar{1}},
4873});
4876
4882template <size_t N>
4883inline constexpr Direction<N> X_AXIS;
4884template <>
4886template <>
4888inline constexpr Direction2D X_AXIS_2D = X_AXIS<2>;
4889inline constexpr Direction3D X_AXIS_3D = X_AXIS<3>;
4890
4896template <size_t N>
4897inline constexpr Direction<N> Y_AXIS;
4898template <>
4900template <>
4902inline constexpr Direction2D Y_AXIS_2D = Y_AXIS<2>;
4903inline constexpr Direction3D Y_AXIS_3D = Y_AXIS<3>;
4904
4910template <size_t N>
4911inline constexpr Direction<N> Z_AXIS;
4912template <>
4914inline constexpr Direction3D Z_AXIS_3D = Z_AXIS<3>;
4915
4923template <size_t N>
4928
4936template <size_t N>
4940
4948template <size_t N>
4953
4963
4970
4977
4983template <size_t N>
4985public:
4986 GREM_ALWAYS_INLINE constexpr LocalTransformation() noexcept = default;
4987
4989 : offset(0)
4990 , basis(basis) {}
4991
4993 : offset(offset)
4994 , basis(basis) {}
4995
4997 : offset(0)
4998 , basis(basis) {}
4999
5000 [[nodiscard]] GREM_ALWAYS_INLINE constexpr operator mat<3, 3, float>() const requires(N == 2) {
5001 mat<3, 3, float> result{mat<2, 2, float>{basis._private_value}};
5002 result[2] = vec<3, float>{vec<2, float>{offset._private_getUnderlyingValue()}, 1.0f};
5003 return result;
5004 }
5005
5006 [[nodiscard]] GREM_ALWAYS_INLINE constexpr operator mat<3, 3, double>() const requires(N == 2) {
5007 mat<3, 3, double> result{mat<2, 2, double>{basis._private_value}};
5008 result[2] = vec<3, double>{vec<2, double>{offset._private_getUnderlyingValue()}, 1.0};
5009 return result;
5010 }
5011
5012 [[nodiscard]] GREM_ALWAYS_INLINE constexpr operator mat<4, 4, float>() const requires(N == 3) {
5013 mat<4, 4, float> result{mat<3, 3, float>{basis._private_value}};
5014 result[3] = vec<4, float>{vec<3, float>{offset._private_getUnderlyingValue()}, 1.0f};
5015 return result;
5016 }
5017
5018 [[nodiscard]] GREM_ALWAYS_INLINE constexpr operator mat<4, 4, double>() const requires(N == 3) {
5019 mat<4, 4, double> result{mat<3, 3, double>{basis._private_value}};
5020 result[3] = vec<4, double>{vec<3, double>{offset._private_getUnderlyingValue()}, 1.0};
5021 return result;
5022 }
5023
5024 [[nodiscard]] GREM_ALWAYS_INLINE constexpr bool operator==(const LocalTransformation&) const noexcept = default;
5025
5027 return offset + basis * b;
5028 }
5029
5031 return offset;
5032 }
5033
5035 return basis;
5036 }
5037
5039 return length(basis * localOffset);
5040 }
5041
5043 return length2(basis * localOffset);
5044 }
5045
5046 template <typename UnitT>
5047 [[nodiscard]] GREM_ALWAYS_INLINE Quantity<N, UnitT> GREM_VECTORCALL getRelative(Quantity<N, UnitT> localQuantity) const requires(!UnitT::MagnitudeType::IS_ABSOLUTE) {
5048 return basis * localQuantity;
5049 }
5050
5052 return normalize(basis * direction);
5053 }
5054
5055private:
5056 Length<N> offset{};
5057 Basis<N> basis{};
5058};
5061
5062template <size_t N>
5064 return LocalTransformation<N>{localOffset, rotateScale(localOrientation, localScale)};
5065}
5066
5068 return LocalTransformation3D{localOffset, rotateScale(Orientation3D{localOrientation}, localScale)};
5069}
5070
5072 return LocalTransformation3D{localOffset, rotateScale(Orientation3D{localOrientation}, localScale)};
5073}
5074
5075template <size_t N>
5077 return LocalTransformation<N>{localOffset, rotate(localOrientation)};
5078}
5079
5081 return LocalTransformation3D{localOffset, rotate(Orientation3D{localOrientation})};
5082}
5083
5085 return LocalTransformation3D{localOffset, rotate(Orientation3D{localOrientation})};
5086}
5087
5088template <size_t N>
5090 return LocalTransformation<N>{localOffset, physics::scale(localScale)};
5091}
5092
5093template <size_t N>
5097
5103template <size_t N>
5105public:
5106 GREM_ALWAYS_INLINE constexpr Transformation() noexcept = default;
5107
5108 GREM_ALWAYS_INLINE constexpr Transformation(Position<N> origin, Basis<N> basis)
5109 : origin(origin)
5110 , basis(basis) {}
5111
5113 : origin(0)
5114 , basis(basis) {}
5115
5116 GREM_ALWAYS_INLINE constexpr explicit Transformation(Position<N> origin, const LocalTransformation<N>& localTransformation)
5117 : origin(origin + localTransformation.getOffset())
5118 , basis(localTransformation.getBasis()) {}
5119
5120 GREM_ALWAYS_INLINE constexpr explicit Transformation(Zero, const LocalTransformation<N>& localTransformation)
5121 : origin(localTransformation.getOffset())
5122 , basis(localTransformation.getBasis()) {}
5123
5124 [[nodiscard]] GREM_ALWAYS_INLINE constexpr operator mat<3, 3, float>() const requires(N == 2) {
5125 mat<3, 3, float> result{mat<2, 2, float>{basis._private_value}};
5126 result[2] = vec<3, float>{vec<2, float>{origin._private_getUnderlyingValue()}, 1.0f};
5127 return result;
5128 }
5129
5130 [[nodiscard]] GREM_ALWAYS_INLINE constexpr operator mat<3, 3, double>() const requires(N == 2) {
5131 mat<3, 3, double> result{mat<2, 2, double>{basis._private_value}};
5132 result[2] = vec<3, double>{vec<2, double>{origin._private_getUnderlyingValue()}, 1.0};
5133 return result;
5134 }
5135
5136 [[nodiscard]] GREM_ALWAYS_INLINE constexpr operator mat<4, 4, float>() const requires(N == 3) {
5137 mat<4, 4, float> result{mat<3, 3, float>{basis._private_value}};
5138 result[3] = vec<4, float>{vec<3, float>{origin._private_getUnderlyingValue()}, 1.0f};
5139 return result;
5140 }
5141
5142 [[nodiscard]] GREM_ALWAYS_INLINE constexpr operator mat<4, 4, double>() const requires(N == 3) {
5143 mat<4, 4, double> result{mat<3, 3, double>{basis._private_value}};
5144 result[3] = vec<4, double>{vec<3, double>{origin._private_getUnderlyingValue()}, 1.0};
5145 return result;
5146 }
5147
5148 [[nodiscard]] GREM_ALWAYS_INLINE constexpr bool operator==(const Transformation&) const noexcept = default;
5149
5151 return origin + basis * b;
5152 }
5153
5155 return origin;
5156 }
5157
5159 return basis;
5160 }
5161
5163 return length(basis * localOffset);
5164 }
5165
5167 return length2(basis * localOffset);
5168 }
5169
5170 template <typename UnitT>
5171 [[nodiscard]] GREM_ALWAYS_INLINE Quantity<N, UnitT> GREM_VECTORCALL getRelative(Quantity<N, UnitT> localQuantity) const requires(!UnitT::MagnitudeType::IS_ABSOLUTE) {
5172 return basis * localQuantity;
5173 }
5174
5176 return normalize(basis * direction);
5177 }
5178
5179private:
5180 Position<N> origin{};
5181 Basis<N> basis{};
5182};
5185
5186template <size_t N>
5190
5194
5198
5199template <size_t N>
5201 return Transformation<N>{position, rotate(orientation)};
5202}
5203
5205 return Transformation3D{position, rotate(Orientation3D{orientation})};
5206}
5207
5209 return Transformation3D{position, rotate(Orientation3D{orientation})};
5210}
5211
5212template <size_t N>
5216
5217template <size_t N>
5221
5222template <size_t N>
5223class InverseTransformation; // Forward declaration.
5224
5230template <size_t N>
5232public:
5233 GREM_ALWAYS_INLINE constexpr InverseLocalTransformation() noexcept = default;
5234
5235 [[nodiscard]] GREM_ALWAYS_INLINE constexpr bool operator==(const InverseLocalTransformation&) const noexcept = default;
5236
5237 [[nodiscard]] GREM_ALWAYS_INLINE Length<N> GREM_VECTORCALL operator()(Length<N> b) const {
5238 return inverseBasis * (b - offset);
5239 }
5240
5242 return offset;
5243 }
5244
5246 return inverseBasis;
5247 }
5248
5250 return length(inverseBasis * localOffset);
5251 }
5252
5254 return length2(inverseBasis * localOffset);
5255 }
5256
5257 template <typename UnitT>
5258 [[nodiscard]] GREM_ALWAYS_INLINE Quantity<N, UnitT> GREM_VECTORCALL getRelative(Quantity<N, UnitT> localQuantity) const requires(!UnitT::MagnitudeType::IS_ABSOLUTE) {
5259 return inverseBasis * localQuantity;
5260 }
5261
5263 return normalize(inverseBasis * direction);
5264 }
5265
5267 return LocalTransformation<N>{inverseBasis * (b.getOffset() - offset), inverseBasis * b.getBasis()};
5268 }
5269
5270 template <size_t OtherN>
5272 Scale<OtherN> localScale);
5273
5276
5277 template <size_t OtherN>
5279
5282
5283 template <size_t OtherN>
5285
5286 template <size_t OtherN>
5288
5289 template <size_t OtherN>
5291
5292 template <size_t OtherN>
5294
5295private:
5296 GREM_ALWAYS_INLINE constexpr InverseLocalTransformation(Length<N> offset, Basis<N> inverseBasis)
5297 : offset(offset)
5298 , inverseBasis(inverseBasis) {}
5299
5300 Length<N> offset{};
5301 Basis<N> inverseBasis{};
5302};
5305
5306template <size_t N>
5308 Scale<N> localScale) {
5309 return InverseLocalTransformation<N>{localOffset, scale(Scalar{1} / localScale) * rotate(inverse(localOrientation))};
5310}
5311
5313 return inverseTranslateRotateScale(localOffset, Orientation3D{localOrientation}, localScale);
5314}
5315
5317 return inverseTranslateRotateScale(localOffset, Orientation3D{localOrientation}, localScale);
5318}
5319
5320template <size_t N>
5322 return InverseLocalTransformation<N>{localOffset, rotate(inverse(localOrientation))};
5323}
5324
5326 return inverseTranslateRotate(localOffset, Orientation3D{localOrientation});
5327}
5328
5330 return inverseTranslateRotate(localOffset, Orientation3D{localOrientation});
5331}
5332
5333template <size_t N>
5335 return InverseLocalTransformation<N>{localOffset, scale(Scalar{1} / localScale)};
5336}
5337
5338template <size_t N>
5342
5343template <size_t N>
5347
5348template <size_t N>
5352
5358template <size_t N>
5360public:
5361 GREM_ALWAYS_INLINE constexpr InverseTransformation() noexcept = default;
5362
5363 [[nodiscard]] GREM_ALWAYS_INLINE constexpr bool operator==(const InverseTransformation&) const noexcept = default;
5364
5365 [[nodiscard]] GREM_ALWAYS_INLINE Length<N> GREM_VECTORCALL operator()(Position<N> b) const {
5366 return inverseBasis * (b - origin);
5367 }
5368
5370 return origin;
5371 }
5372
5374 return inverseBasis;
5375 }
5376
5378 return length(inverseBasis * localOffset);
5379 }
5380
5382 return length2(inverseBasis * localOffset);
5383 }
5384
5385 template <typename UnitT>
5386 [[nodiscard]] GREM_ALWAYS_INLINE Quantity<N, UnitT> GREM_VECTORCALL getRelative(Quantity<N, UnitT> localQuantity) const requires(!UnitT::MagnitudeType::IS_ABSOLUTE) {
5387 return inverseBasis * localQuantity;
5388 }
5389
5391 return normalize(inverseBasis * direction);
5392 }
5393
5395 return LocalTransformation<N>{inverseBasis * (b.getOrigin() - origin), inverseBasis * b.getBasis()};
5396 }
5397
5398 template <size_t OtherN>
5401
5404
5405 template <size_t OtherN>
5407
5410
5411 template <size_t OtherN>
5413
5414 template <size_t OtherN>
5416
5417 template <size_t OtherN>
5419
5420 template <size_t OtherN>
5422
5423 template <size_t OtherN>
5425
5426private:
5427 GREM_ALWAYS_INLINE constexpr InverseTransformation(Position<N> origin, Basis<N> inverseBasis)
5428 : origin(origin)
5429 , inverseBasis(inverseBasis) {}
5430
5431 Position<N> origin{};
5432 Basis<N> inverseBasis{};
5433};
5436
5437template <size_t N>
5441
5445
5449
5450template <size_t N>
5454
5458
5462
5463template <size_t N>
5467
5468template <size_t N>
5472
5473template <size_t N>
5477
5478template <size_t N>
5482
5486
5490
5494
5498
5505
5512
5519
5526
5533
5540
5547
5554
5562template <size_t N>
5567
5577
5585template <size_t N>
5589
5597template <size_t N>
5602
5609
5617template <size_t N>
5622
5632
5640template <size_t N>
5644
5651
5659template <size_t N>
5665
5672
5680template <size_t N>
5684
5692template <size_t N>
5697
5705template <size_t N>
5709
5717template <size_t N>
5721
5729template <size_t N>
5733
5741template <size_t N>
5746
5756
5764template <size_t N>
5768
5776template <size_t N>
5781
5791
5799template <size_t N>
5803
5811template <size_t N>
5815
5823template <size_t N>
5827
5835template <size_t N>
5839
5847template <size_t N>
5851
5859template <size_t N>
5863
5872template <size_t N>
5874
5875template <>
5877 constexpr operator Orientation2D() const noexcept {
5878 return {};
5879 }
5880};
5881
5882template <>
5884
5887
5895template <size_t N>
5901
5909template <size_t N>
5913
5921template <size_t N>
5925
5933template <size_t N>
5937
5945template <size_t N>
5949
5956
5964template <size_t N>
5968
5975
5982
5989
5996
6004template <size_t N>
6008
6016template <size_t N>
6020
6028template <size_t N>
6032
6040template <size_t N>
6046
6054template <size_t N>
6058
6066template <size_t N>
6070
6077
6084
6091
6098
6105
6112
6119
6126
6133
6134namespace literals {
6135
6136using namespace time_literals;
6137
6138[[nodiscard]] consteval Coefficient operator""_x(long double value) {
6139 return Coefficient{static_cast<Scalar>(value)};
6140}
6141
6142[[nodiscard]] consteval Coefficient operator""_x(unsigned long long value) {
6143 return Coefficient{static_cast<Scalar>(value)};
6144}
6145
6146[[nodiscard]] consteval Coefficient operator""_percent(long double value) {
6147 return Coefficient{static_cast<Scalar>(value * 0.01l)};
6148}
6149
6150[[nodiscard]] consteval Coefficient operator""_percent(unsigned long long value) {
6151 return Coefficient{static_cast<Scalar>(static_cast<long double>(value) * 0.01l)};
6152}
6153
6154[[nodiscard]] consteval Angle operator""_radians(long double value) {
6155 return static_cast<Scalar>(value) * RADIANS;
6156}
6157
6158[[nodiscard]] consteval Angle operator""_radians(unsigned long long value) {
6159 return static_cast<Scalar>(value) * RADIANS;
6160}
6161
6162[[nodiscard]] consteval Angle operator""_radian(long double value) {
6163 if (value != 1.0l) {
6164 throw physics::Error{"Syntax error: Expected \"1.0_radian\". For values other than 1, use the plural form \"_radians\" instead."};
6165 }
6166 return operator""_radians(value);
6167}
6168
6169[[nodiscard]] consteval Angle operator""_radian(unsigned long long value) {
6170 if (value != 1ull) {
6171 throw physics::Error{"Syntax error: Expected \"1_radian\". For values other than 1, use the plural form \"_radians\" instead."};
6172 }
6173 return operator""_radians(value);
6174}
6175
6176[[nodiscard]] consteval Angle operator""_degrees(long double value) {
6177 return static_cast<Scalar>(value * 0.01745329251994329576923690768489l) * RADIANS;
6178}
6179
6180[[nodiscard]] consteval Angle operator""_degrees(unsigned long long value) {
6181 return static_cast<Scalar>(static_cast<long double>(value) * 0.01745329251994329576923690768489l) * RADIANS;
6182}
6183
6184[[nodiscard]] consteval Angle operator""_degree(long double value) {
6185 if (value != 1.0l) {
6186 throw physics::Error{"Syntax error: Expected \"1.0_degree\". For values other than 1, use the plural form \"_degrees\" instead."};
6187 }
6188 return operator""_degrees(value);
6189}
6190
6191[[nodiscard]] consteval Angle operator""_degree(unsigned long long value) {
6192 if (value != 1ull) {
6193 throw physics::Error{"Syntax error: Expected \"1_degree\". For values other than 1, use the plural form \"_degrees\" instead."};
6194 }
6195 return operator""_degrees(value);
6196}
6197
6198[[nodiscard]] consteval Angle operator""_turns(long double value) {
6199 return static_cast<Scalar>(value * 6.28318530718l) * RADIANS;
6200}
6201
6202[[nodiscard]] consteval Angle operator""_turns(unsigned long long value) {
6203 return static_cast<Scalar>(static_cast<long double>(value) * 6.28318530718l) * RADIANS;
6204}
6205
6206[[nodiscard]] consteval Angle operator""_turn(long double value) {
6207 if (value != 1.0l) {
6208 throw physics::Error{"Syntax error: Expected \"1.0_turn\". For values other than 1, use the plural form \"_turns\" instead."};
6209 }
6210 return operator""_turns(value);
6211}
6212
6213[[nodiscard]] consteval Angle operator""_turn(unsigned long long value) {
6214 if (value != 1ull) {
6215 throw physics::Error{"Syntax error: Expected \"1_turn\". For values other than 1, use the plural form \"_turns\" instead."};
6216 }
6217 return operator""_turns(value);
6218}
6219
6220[[nodiscard]] consteval Mass operator""_kilograms(long double value) {
6221 return static_cast<Scalar>(value) * KILOGRAMS;
6222}
6223
6224[[nodiscard]] consteval Mass operator""_kilograms(unsigned long long value) {
6225 return static_cast<Scalar>(value) * KILOGRAMS;
6226}
6227
6228[[nodiscard]] consteval Mass operator""_kilogram(long double value) {
6229 if (value != 1.0l) {
6230 throw physics::Error{"Syntax error: Expected \"1.0_kilogram\". For values other than 1, use the plural form \"_kilograms\" instead."};
6231 }
6232 return operator""_kilograms(value);
6233}
6234
6235[[nodiscard]] consteval Mass operator""_kilogram(unsigned long long value) {
6236 if (value != 1ull) {
6237 throw physics::Error{"Syntax error: Expected \"1_kilogram\". For values other than 1, use the plural form \"_kilograms\" instead."};
6238 }
6239 return operator""_kilograms(value);
6240}
6241
6242[[nodiscard]] consteval Mass operator""_grams(long double value) {
6243 return static_cast<Scalar>(value * 0.001l) * KILOGRAMS;
6244}
6245
6246[[nodiscard]] consteval Mass operator""_grams(unsigned long long value) {
6247 return static_cast<Scalar>(static_cast<long double>(value) * 0.001l) * KILOGRAMS;
6248}
6249
6250[[nodiscard]] consteval Mass operator""_gram(long double value) {
6251 if (value != 1.0l) {
6252 throw physics::Error{"Syntax error: Expected \"1.0_gram\". For values other than 1, use the plural form \"_grams\" instead."};
6253 }
6254 return operator""_grams(value);
6255}
6256
6257[[nodiscard]] consteval Mass operator""_gram(unsigned long long value) {
6258 if (value != 1ull) {
6259 throw physics::Error{"Syntax error: Expected \"1_gram\". For values other than 1, use the plural form \"_grams\" instead."};
6260 }
6261 return operator""_grams(value);
6262}
6263
6264[[nodiscard]] consteval Distance operator""_meters(long double value) {
6265 return static_cast<Scalar>(value) * METERS;
6266}
6267
6268[[nodiscard]] consteval Distance operator""_meters(unsigned long long value) {
6269 return static_cast<Scalar>(value) * METERS;
6270}
6271
6272[[nodiscard]] consteval Distance operator""_meter(long double value) {
6273 if (value != 1.0l) {
6274 throw physics::Error{"Syntax error: Expected \"1.0_meter\". For values other than 1, use the plural form \"_meters\" instead."};
6275 }
6276 return operator""_meters(value);
6277}
6278
6279[[nodiscard]] consteval Distance operator""_meter(unsigned long long value) {
6280 if (value != 1ull) {
6281 throw physics::Error{"Syntax error: Expected \"1_meter\". For values other than 1, use the plural form \"_meters\" instead."};
6282 }
6283 return operator""_meters(value);
6284}
6285
6286[[nodiscard]] consteval Distance operator""_kilometers(long double value) {
6287 return static_cast<Scalar>(value * 1000.0l) * METERS;
6288}
6289
6290[[nodiscard]] consteval Distance operator""_kilometers(unsigned long long value) {
6291 return static_cast<Scalar>(value * 1000ull) * METERS;
6292}
6293
6294[[nodiscard]] consteval Distance operator""_kilometer(long double value) {
6295 if (value != 1.0l) {
6296 throw physics::Error{"Syntax error: Expected \"1.0_kilometer\". For values other than 1, use the plural form \"_kilometers\" instead."};
6297 }
6298 return operator""_kilometers(value);
6299}
6300
6301[[nodiscard]] consteval Distance operator""_kilometer(unsigned long long value) {
6302 if (value != 1ull) {
6303 throw physics::Error{"Syntax error: Expected \"1_kilometer\". For values other than 1, use the plural form \"_kilometers\" instead."};
6304 }
6305 return operator""_kilometers(value);
6306}
6307
6308[[nodiscard]] consteval Distance operator""_decimeters(long double value) {
6309 return static_cast<Scalar>(value * 0.1l) * METERS;
6310}
6311
6312[[nodiscard]] consteval Distance operator""_decimeters(unsigned long long value) {
6313 return static_cast<Scalar>(static_cast<long double>(value) * 0.1l) * METERS;
6314}
6315
6316[[nodiscard]] consteval Distance operator""_decimeter(long double value) {
6317 if (value != 1.0l) {
6318 throw physics::Error{"Syntax error: Expected \"1.0_decimeter\". For values other than 1, use the plural form \"_decimeters\" instead."};
6319 }
6320 return operator""_decimeters(value);
6321}
6322
6323[[nodiscard]] consteval Distance operator""_decimeter(unsigned long long value) {
6324 if (value != 1ull) {
6325 throw physics::Error{"Syntax error: Expected \"1_decimeter\". For values other than 1, use the plural form \"_decimeters\" instead."};
6326 }
6327 return operator""_decimeters(value);
6328}
6329
6330[[nodiscard]] consteval Distance operator""_centimeters(long double value) {
6331 return static_cast<Scalar>(value * 0.01l) * METERS;
6332}
6333
6334[[nodiscard]] consteval Distance operator""_centimeters(unsigned long long value) {
6335 return static_cast<Scalar>(static_cast<long double>(value) * 0.01l) * METERS;
6336}
6337
6338[[nodiscard]] consteval Distance operator""_centimeter(long double value) {
6339 if (value != 1.0l) {
6340 throw physics::Error{"Syntax error: Expected \"1.0_centimeter\". For values other than 1, use the plural form \"_centimeters\" instead."};
6341 }
6342 return operator""_centimeters(value);
6343}
6344
6345[[nodiscard]] consteval Distance operator""_centimeter(unsigned long long value) {
6346 if (value != 1ull) {
6347 throw physics::Error{"Syntax error: Expected \"1_centimeter\". For values other than 1, use the plural form \"_centimeters\" instead."};
6348 }
6349 return operator""_centimeters(value);
6350}
6351
6352[[nodiscard]] consteval Distance operator""_millimeters(long double value) {
6353 return static_cast<Scalar>(value * 0.001l) * METERS;
6354}
6355
6356[[nodiscard]] consteval Distance operator""_millimeters(unsigned long long value) {
6357 return static_cast<Scalar>(static_cast<long double>(value) * 0.001l) * METERS;
6358}
6359
6360[[nodiscard]] consteval Distance operator""_millimeter(long double value) {
6361 if (value != 1.0l) {
6362 throw physics::Error{"Syntax error: Expected \"1.0_millimeter\". For values other than 1, use the plural form \"_millimeters\" instead."};
6363 }
6364 return operator""_millimeters(value);
6365}
6366
6367[[nodiscard]] consteval Distance operator""_millimeter(unsigned long long value) {
6368 if (value != 1ull) {
6369 throw physics::Error{"Syntax error: Expected \"1_millimeter\". For values other than 1, use the plural form \"_millimeters\" instead."};
6370 }
6371 return operator""_millimeters(value);
6372}
6373
6374[[nodiscard]] consteval Area operator""_square_meters(long double value) {
6375 return static_cast<Scalar>(value) * SQUARE_METERS;
6376}
6377
6378[[nodiscard]] consteval Area operator""_square_meters(unsigned long long value) {
6379 return static_cast<Scalar>(value) * SQUARE_METERS;
6380}
6381
6382[[nodiscard]] consteval Area operator""_square_meter(long double value) {
6383 if (value != 1.0l) {
6384 throw physics::Error{"Syntax error: Expected \"1.0_square_meter\". For values other than 1, use the plural form \"_square_meters\" instead."};
6385 }
6386 return operator""_square_meters(value);
6387}
6388
6389[[nodiscard]] consteval Area operator""_square_meter(unsigned long long value) {
6390 if (value != 1ull) {
6391 throw physics::Error{"Syntax error: Expected \"1_square_meter\". For values other than 1, use the plural form \"_square_meters\" instead."};
6392 }
6393 return operator""_square_meters(value);
6394}
6395
6396[[nodiscard]] consteval Area operator""_square_kilometers(long double value) {
6397 return static_cast<Scalar>(value * 1000000.0l) * SQUARE_METERS;
6398}
6399
6400[[nodiscard]] consteval Area operator""_square_kilometers(unsigned long long value) {
6401 return static_cast<Scalar>(value * 1000000ull) * SQUARE_METERS;
6402}
6403
6404[[nodiscard]] consteval Area operator""_square_kilometer(long double value) {
6405 if (value != 1.0l) {
6406 throw physics::Error{"Syntax error: Expected \"1.0_square_kilometer\". For values other than 1, use the plural form \"_square_kilometers\" instead."};
6407 }
6408 return operator""_square_kilometers(value);
6409}
6410
6411[[nodiscard]] consteval Area operator""_square_kilometer(unsigned long long value) {
6412 if (value != 1ull) {
6413 throw physics::Error{"Syntax error: Expected \"1_square_kilometer\". For values other than 1, use the plural form \"_square_kilometers\" instead."};
6414 }
6415 return operator""_square_kilometers(value);
6416}
6417
6418[[nodiscard]] consteval Area operator""_square_decimeters(long double value) {
6419 return static_cast<Scalar>(value * 0.01l) * SQUARE_METERS;
6420}
6421
6422[[nodiscard]] consteval Area operator""_square_decimeters(unsigned long long value) {
6423 return static_cast<Scalar>(static_cast<long double>(value) * 0.01l) * SQUARE_METERS;
6424}
6425
6426[[nodiscard]] consteval Area operator""_square_decimeter(long double value) {
6427 if (value != 1.0l) {
6428 throw physics::Error{"Syntax error: Expected \"1.0_square_decimeter\". For values other than 1, use the plural form \"_square_decimeters\" instead."};
6429 }
6430 return operator""_square_decimeters(value);
6431}
6432
6433[[nodiscard]] consteval Area operator""_square_decimeter(unsigned long long value) {
6434 if (value != 1ull) {
6435 throw physics::Error{"Syntax error: Expected \"1_square_decimeter\". For values other than 1, use the plural form \"_square_decimeters\" instead."};
6436 }
6437 return operator""_square_decimeters(value);
6438}
6439
6440[[nodiscard]] consteval Area operator""_square_centimeters(long double value) {
6441 return static_cast<Scalar>(value * 0.0001l) * SQUARE_METERS;
6442}
6443
6444[[nodiscard]] consteval Area operator""_square_centimeters(unsigned long long value) {
6445 return static_cast<Scalar>(static_cast<long double>(value) * 0.0001l) * SQUARE_METERS;
6446}
6447
6448[[nodiscard]] consteval Area operator""_square_centimeter(long double value) {
6449 if (value != 1.0l) {
6450 throw physics::Error{"Syntax error: Expected \"1.0_square_centimeter\". For values other than 1, use the plural form \"_square_centimeters\" instead."};
6451 }
6452 return operator""_square_centimeters(value);
6453}
6454
6455[[nodiscard]] consteval Area operator""_square_centimeter(unsigned long long value) {
6456 if (value != 1ull) {
6457 throw physics::Error{"Syntax error: Expected \"1_square_centimeter\". For values other than 1, use the plural form \"_square_centimeters\" instead."};
6458 }
6459 return operator""_square_centimeters(value);
6460}
6461
6462[[nodiscard]] consteval Area operator""_square_millimeters(long double value) {
6463 return static_cast<Scalar>(value * 0.000001l) * SQUARE_METERS;
6464}
6465
6466[[nodiscard]] consteval Area operator""_square_millimeters(unsigned long long value) {
6467 return static_cast<Scalar>(static_cast<long double>(value) * 0.000001l) * SQUARE_METERS;
6468}
6469
6470[[nodiscard]] consteval Area operator""_square_millimeter(long double value) {
6471 if (value != 1.0l) {
6472 throw physics::Error{"Syntax error: Expected \"1.0_square_millimeter\". For values other than 1, use the plural form \"_square_millimeters\" instead."};
6473 }
6474 return operator""_square_millimeters(value);
6475}
6476
6477[[nodiscard]] consteval Area operator""_square_millimeter(unsigned long long value) {
6478 if (value != 1ull) {
6479 throw physics::Error{"Syntax error: Expected \"1_square_millimeter\". For values other than 1, use the plural form \"_square_millimeters\" instead."};
6480 }
6481 return operator""_square_millimeters(value);
6482}
6483
6484[[nodiscard]] consteval Volume operator""_cubic_meters(long double value) {
6485 return static_cast<Scalar>(value) * CUBIC_METERS;
6486}
6487
6488[[nodiscard]] consteval Volume operator""_cubic_meters(unsigned long long value) {
6489 return static_cast<Scalar>(value) * CUBIC_METERS;
6490}
6491
6492[[nodiscard]] consteval Volume operator""_cubic_meter(long double value) {
6493 if (value != 1.0l) {
6494 throw physics::Error{"Syntax error: Expected \"1.0_cubic_meter\". For values other than 1, use the plural form \"_cubic_meters\" instead."};
6495 }
6496 return operator""_cubic_meters(value);
6497}
6498
6499[[nodiscard]] consteval Volume operator""_cubic_meter(unsigned long long value) {
6500 if (value != 1ull) {
6501 throw physics::Error{"Syntax error: Expected \"1_cubic_meter\". For values other than 1, use the plural form \"_cubic_meters\" instead."};
6502 }
6503 return operator""_cubic_meters(value);
6504}
6505
6506[[nodiscard]] consteval Volume operator""_liters(long double value) {
6507 return static_cast<Scalar>(value * 0.001l) * CUBIC_METERS;
6508}
6509
6510[[nodiscard]] consteval Volume operator""_liters(unsigned long long value) {
6511 return static_cast<Scalar>(static_cast<long double>(value) * 0.001l) * CUBIC_METERS;
6512}
6513
6514[[nodiscard]] consteval Volume operator""_liter(long double value) {
6515 if (value != 1.0l) {
6516 throw physics::Error{"Syntax error: Expected \"1.0_liter\". For values other than 1, use the plural form \"_liters\" instead."};
6517 }
6518 return operator""_liters(value);
6519}
6520
6521[[nodiscard]] consteval Volume operator""_liter(unsigned long long value) {
6522 if (value != 1ull) {
6523 throw physics::Error{"Syntax error: Expected \"1_liter\". For values other than 1, use the plural form \"_liters\" instead."};
6524 }
6525 return operator""_liters(value);
6526}
6527
6528[[nodiscard]] consteval Volume operator""_deciliters(long double value) {
6529 return static_cast<Scalar>(value * 0.0001l) * CUBIC_METERS;
6530}
6531
6532[[nodiscard]] consteval Volume operator""_deciliters(unsigned long long value) {
6533 return static_cast<Scalar>(static_cast<long double>(value) * 0.0001l) * CUBIC_METERS;
6534}
6535
6536[[nodiscard]] consteval Volume operator""_deciliter(long double value) {
6537 if (value != 1.0l) {
6538 throw physics::Error{"Syntax error: Expected \"1.0_deciliter\". For values other than 1, use the plural form \"_deciliters\" instead."};
6539 }
6540 return operator""_deciliters(value);
6541}
6542
6543[[nodiscard]] consteval Volume operator""_deciliter(unsigned long long value) {
6544 if (value != 1ull) {
6545 throw physics::Error{"Syntax error: Expected \"1_deciliter\". For values other than 1, use the plural form \"_deciliters\" instead."};
6546 }
6547 return operator""_deciliters(value);
6548}
6549
6550[[nodiscard]] consteval Volume operator""_centiliters(long double value) {
6551 return static_cast<Scalar>(value * 0.00001l) * CUBIC_METERS;
6552}
6553
6554[[nodiscard]] consteval Volume operator""_centiliters(unsigned long long value) {
6555 return static_cast<Scalar>(static_cast<long double>(value) * 0.00001l) * CUBIC_METERS;
6556}
6557
6558[[nodiscard]] consteval Volume operator""_centiliter(long double value) {
6559 if (value != 1.0l) {
6560 throw physics::Error{"Syntax error: Expected \"1.0_centiliter\". For values other than 1, use the plural form \"_centiliters\" instead."};
6561 }
6562 return operator""_centiliters(value);
6563}
6564
6565[[nodiscard]] consteval Volume operator""_centiliter(unsigned long long value) {
6566 if (value != 1ull) {
6567 throw physics::Error{"Syntax error: Expected \"1_centiliter\". For values other than 1, use the plural form \"_centiliters\" instead."};
6568 }
6569 return operator""_centiliters(value);
6570}
6571
6572[[nodiscard]] consteval Volume operator""_milliliters(long double value) {
6573 return static_cast<Scalar>(value * 0.000001l) * CUBIC_METERS;
6574}
6575
6576[[nodiscard]] consteval Volume operator""_milliliters(unsigned long long value) {
6577 return static_cast<Scalar>(static_cast<long double>(value) * 0.000001l) * CUBIC_METERS;
6578}
6579
6580[[nodiscard]] consteval Volume operator""_milliliter(long double value) {
6581 if (value != 1.0l) {
6582 throw physics::Error{"Syntax error: Expected \"1.0_milliliter\". For values other than 1, use the plural form \"_milliliters\" instead."};
6583 }
6584 return operator""_milliliters(value);
6585}
6586
6587[[nodiscard]] consteval Volume operator""_milliliter(unsigned long long value) {
6588 if (value != 1ull) {
6589 throw physics::Error{"Syntax error: Expected \"1_milliliter\". For values other than 1, use the plural form \"_milliliters\" instead."};
6590 }
6591 return operator""_milliliters(value);
6592}
6593
6594[[nodiscard]] consteval Density operator""_kilograms_per_cubic_meter(long double value) {
6595 return static_cast<Scalar>(value) * KILOGRAMS_PER_CUBIC_METER;
6596}
6597
6598[[nodiscard]] consteval Density operator""_kilograms_per_cubic_meter(unsigned long long value) {
6599 return static_cast<Scalar>(value) * KILOGRAMS_PER_CUBIC_METER;
6600}
6601
6602[[nodiscard]] consteval Density operator""_kilogram_per_cubic_meter(long double value) {
6603 if (value != 1.0l) {
6604 throw physics::Error{"Syntax error: Expected \"1.0_kilogram_per_cubic_meter\". For values other than 1, use the plural form \"_kilograms_per_cubic_meter\" instead."};
6605 }
6606 return operator""_kilograms_per_cubic_meter(value);
6607}
6608
6609[[nodiscard]] consteval Density operator""_kilogram_per_cubic_meter(unsigned long long value) {
6610 if (value != 1ull) {
6611 throw physics::Error{"Syntax error: Expected \"1_kilogram_per_cubic_meter\". For values other than 1, use the plural form \"_kilograms_per_cubic_meter\" instead."};
6612 }
6613 return operator""_kilograms_per_cubic_meter(value);
6614}
6615
6616[[nodiscard]] consteval Density operator""_grams_per_cubic_centimeter(long double value) {
6617 return static_cast<Scalar>(value * 1000.0l) * KILOGRAMS_PER_CUBIC_METER;
6618}
6619
6620[[nodiscard]] consteval Density operator""_grams_per_cubic_centimeter(unsigned long long value) {
6621 return static_cast<Scalar>(value * 1000ull) * KILOGRAMS_PER_CUBIC_METER;
6622}
6623
6624[[nodiscard]] consteval Density operator""_gram_per_cubic_centimeter(long double value) {
6625 if (value != 1.0l) {
6626 throw physics::Error{"Syntax error: Expected \"1.0_gram_per_cubic_centimeter\". For values other than 1, use the plural form \"_grams_per_cubic_centimeter\" instead."};
6627 }
6628 return operator""_grams_per_cubic_centimeter(value);
6629}
6630
6631[[nodiscard]] consteval Density operator""_gram_per_cubic_centimeter(unsigned long long value) {
6632 if (value != 1ull) {
6633 throw physics::Error{"Syntax error: Expected \"1_gram_per_cubic_centimeter\". For values other than 1, use the plural form \"_grams_per_cubic_centimeter\" instead."};
6634 }
6635 return operator""_grams_per_cubic_centimeter(value);
6636}
6637
6638[[nodiscard]] consteval Frequency operator""_Hertz(long double value) {
6639 return static_cast<Scalar>(value) * HERTZ;
6640}
6641
6642[[nodiscard]] consteval Frequency operator""_Hertz(unsigned long long value) {
6643 return static_cast<Scalar>(value) * HERTZ;
6644}
6645
6646[[nodiscard]] consteval Frequency operator""_per_second(long double value) {
6647 return static_cast<Scalar>(value) * HERTZ;
6648}
6649
6650[[nodiscard]] consteval Frequency operator""_per_second(unsigned long long value) {
6651 return static_cast<Scalar>(value) * HERTZ;
6652}
6653
6654[[nodiscard]] consteval Frequency operator""_per_millisecond(long double value) {
6655 return static_cast<Scalar>(value * 1000.0l) * HERTZ;
6656}
6657
6658[[nodiscard]] consteval Frequency operator""_per_millisecond(unsigned long long value) {
6659 return static_cast<Scalar>(value * 1000ull) * HERTZ;
6660}
6661
6662[[nodiscard]] consteval Frequency operator""_per_minute(long double value) {
6663 return static_cast<Scalar>(value * 0.0166666666667l) * HERTZ;
6664}
6665
6666[[nodiscard]] consteval Frequency operator""_per_minute(unsigned long long value) {
6667 return static_cast<Scalar>(static_cast<long double>(value) * 0.0166666666667l) * HERTZ;
6668}
6669
6670[[nodiscard]] consteval Frequency operator""_per_hour(long double value) {
6671 return static_cast<Scalar>(value * 0.000277777777778l) * HERTZ;
6672}
6673
6674[[nodiscard]] consteval Frequency operator""_per_hour(unsigned long long value) {
6675 return static_cast<Scalar>(static_cast<long double>(value) * 0.000277777777778l) * HERTZ;
6676}
6677
6678[[nodiscard]] consteval LinearAbsement1D operator""_meter_seconds(long double value) {
6679 return static_cast<Scalar>(value) * METER_SECONDS;
6680}
6681
6682[[nodiscard]] consteval LinearAbsement1D operator""_meter_seconds(unsigned long long value) {
6683 return static_cast<Scalar>(value) * METER_SECONDS;
6684}
6685
6686[[nodiscard]] consteval LinearAbsement1D operator""_meter_second(long double value) {
6687 if (value != 1.0l) {
6688 throw physics::Error{"Syntax error: Expected \"1.0_meter_second\". For values other than 1, use the plural form \"_meter_seconds\" instead."};
6689 }
6690 return operator""_meter_seconds(value);
6691}
6692
6693[[nodiscard]] consteval LinearAbsement1D operator""_meter_second(unsigned long long value) {
6694 if (value != 1ull) {
6695 throw physics::Error{"Syntax error: Expected \"1_meter_second\". For values other than 1, use the plural form \"_meter_seconds\" instead."};
6696 }
6697 return operator""_meter_seconds(value);
6698}
6699
6700[[nodiscard]] consteval Wavenumber operator""_per_meter(long double value) {
6701 return static_cast<Scalar>(value) * PER_METER;
6702}
6703
6704[[nodiscard]] consteval Wavenumber operator""_per_meter(unsigned long long value) {
6705 return static_cast<Scalar>(value) * PER_METER;
6706}
6707
6708[[nodiscard]] consteval Speed operator""_meters_per_second(long double value) {
6709 return static_cast<Scalar>(value) * METERS_PER_SECOND;
6710}
6711
6712[[nodiscard]] consteval Speed operator""_meters_per_second(unsigned long long value) {
6713 return static_cast<Scalar>(value) * METERS_PER_SECOND;
6714}
6715
6716[[nodiscard]] consteval Speed operator""_meter_per_second(long double value) {
6717 if (value != 1.0l) {
6718 throw physics::Error{"Syntax error: Expected \"1.0_meter_per_second\". For values other than 1, use the plural form \"_meters_per_second\" instead."};
6719 }
6720 return operator""_meters_per_second(value);
6721}
6722
6723[[nodiscard]] consteval Speed operator""_meter_per_second(unsigned long long value) {
6724 if (value != 1ull) {
6725 throw physics::Error{"Syntax error: Expected \"1_meter_per_second\". For values other than 1, use the plural form \"_meters_per_second\" instead."};
6726 }
6727 return operator""_meters_per_second(value);
6728}
6729
6730[[nodiscard]] consteval Speed operator""_kilometers_per_second(long double value) {
6731 return static_cast<Scalar>(value * 1000.0l) * METERS_PER_SECOND;
6732}
6733
6734[[nodiscard]] consteval Speed operator""_kilometers_per_second(unsigned long long value) {
6735 return static_cast<Scalar>(value * 1000ull) * METERS_PER_SECOND;
6736}
6737
6738[[nodiscard]] consteval Speed operator""_kilometer_per_second(long double value) {
6739 if (value != 1.0l) {
6740 throw physics::Error{"Syntax error: Expected \"1.0_kilometer_per_second\". For values other than 1, use the plural form \"_kilometers_per_second\" instead."};
6741 }
6742 return operator""_kilometers_per_second(value);
6743}
6744
6745[[nodiscard]] consteval Speed operator""_kilometer_per_second(unsigned long long value) {
6746 if (value != 1ull) {
6747 throw physics::Error{"Syntax error: Expected \"1_kilometer_per_second\". For values other than 1, use the plural form \"_kilometers_per_second\" instead."};
6748 }
6749 return operator""_kilometers_per_second(value);
6750}
6751
6752[[nodiscard]] consteval Speed operator""_decimeters_per_second(long double value) {
6753 return static_cast<Scalar>(value * 0.1l) * METERS_PER_SECOND;
6754}
6755
6756[[nodiscard]] consteval Speed operator""_decimeters_per_second(unsigned long long value) {
6757 return static_cast<Scalar>(static_cast<long double>(value) * 0.1l) * METERS_PER_SECOND;
6758}
6759
6760[[nodiscard]] consteval Speed operator""_decimeter_per_second(long double value) {
6761 if (value != 1.0l) {
6762 throw physics::Error{"Syntax error: Expected \"1.0_decimeter_per_second\". For values other than 1, use the plural form \"_decimeters_per_second\" instead."};
6763 }
6764 return operator""_decimeters_per_second(value);
6765}
6766
6767[[nodiscard]] consteval Speed operator""_decimeter_per_second(unsigned long long value) {
6768 if (value != 1ull) {
6769 throw physics::Error{"Syntax error: Expected \"1_decimeter_per_second\". For values other than 1, use the plural form \"_decimeters_per_second\" instead."};
6770 }
6771 return operator""_decimeters_per_second(value);
6772}
6773
6774[[nodiscard]] consteval Speed operator""_centimeters_per_second(long double value) {
6775 return static_cast<Scalar>(value * 0.01l) * METERS_PER_SECOND;
6776}
6777
6778[[nodiscard]] consteval Speed operator""_centimeters_per_second(unsigned long long value) {
6779 return static_cast<Scalar>(static_cast<long double>(value) * 0.01l) * METERS_PER_SECOND;
6780}
6781
6782[[nodiscard]] consteval Speed operator""_centimeter_per_second(long double value) {
6783 if (value != 1.0l) {
6784 throw physics::Error{"Syntax error: Expected \"1.0_centimeter_per_second\". For values other than 1, use the plural form \"_centimeters_per_second\" instead."};
6785 }
6786 return operator""_centimeters_per_second(value);
6787}
6788
6789[[nodiscard]] consteval Speed operator""_centimeter_per_second(unsigned long long value) {
6790 if (value != 1ull) {
6791 throw physics::Error{"Syntax error: Expected \"1_centimeter_per_second\". For values other than 1, use the plural form \"_centimeters_per_second\" instead."};
6792 }
6793 return operator""_centimeters_per_second(value);
6794}
6795
6796[[nodiscard]] consteval Speed operator""_millimeters_per_second(long double value) {
6797 return static_cast<Scalar>(value * 0.001l) * METERS_PER_SECOND;
6798}
6799
6800[[nodiscard]] consteval Speed operator""_millimeters_per_second(unsigned long long value) {
6801 return static_cast<Scalar>(static_cast<long double>(value) * 0.001l) * METERS_PER_SECOND;
6802}
6803
6804[[nodiscard]] consteval Speed operator""_millimeter_per_second(long double value) {
6805 if (value != 1.0l) {
6806 throw physics::Error{"Syntax error: Expected \"1.0_millimeter_per_second\". For values other than 1, use the plural form \"_millimeters_per_second\" instead."};
6807 }
6808 return operator""_millimeters_per_second(value);
6809}
6810
6811[[nodiscard]] consteval Speed operator""_millimeter_per_second(unsigned long long value) {
6812 if (value != 1ull) {
6813 throw physics::Error{"Syntax error: Expected \"1_millimeter_per_second\". For values other than 1, use the plural form \"_millimeters_per_second\" instead."};
6814 }
6815 return operator""_millimeters_per_second(value);
6816}
6817
6818[[nodiscard]] consteval Speed operator""_kilometers_per_hour(long double value) {
6819 return static_cast<Scalar>(value * 0.277777778l) * METERS_PER_SECOND;
6820}
6821
6822[[nodiscard]] consteval Speed operator""_kilometers_per_hour(unsigned long long value) {
6823 return static_cast<Scalar>(static_cast<long double>(value) * 0.277777778l) * METERS_PER_SECOND;
6824}
6825
6826[[nodiscard]] consteval Speed operator""_kilometer_per_hour(long double value) {
6827 if (value != 1.0l) {
6828 throw physics::Error{"Syntax error: Expected \"1.0_kilometer_per_hour\". For values other than 1, use the plural form \"_kilometers_per_hour\" instead."};
6829 }
6830 return operator""_kilometers_per_hour(value);
6831}
6832
6833[[nodiscard]] consteval Speed operator""_kilometer_per_hour(unsigned long long value) {
6834 if (value != 1ull) {
6835 throw physics::Error{"Syntax error: Expected \"1_kilometer_per_hour\". For values other than 1, use the plural form \"_kilometers_per_hour\" instead."};
6836 }
6837 return operator""_kilometers_per_hour(value);
6838}
6839
6840[[nodiscard]] consteval Acceleration operator""_meters_per_second_squared(long double value) {
6841 return static_cast<Scalar>(value) * METERS_PER_SECOND_SQUARED;
6842}
6843
6844[[nodiscard]] consteval Acceleration operator""_meters_per_second_squared(unsigned long long value) {
6845 return static_cast<Scalar>(value) * METERS_PER_SECOND_SQUARED;
6846}
6847
6848[[nodiscard]] consteval Acceleration operator""_meter_per_second_squared(long double value) {
6849 if (value != 1.0l) {
6850 throw physics::Error{"Syntax error: Expected \"1.0_meter_per_second_squared\". For values other than 1, use the plural form \"_meters_per_second_squared\" instead."};
6851 }
6852 return operator""_meters_per_second_squared(value);
6853}
6854
6855[[nodiscard]] consteval Acceleration operator""_meter_per_second_squared(unsigned long long value) {
6856 if (value != 1ull) {
6857 throw physics::Error{"Syntax error: Expected \"1_meter_per_second_squared\". For values other than 1, use the plural form \"_meters_per_second_squared\" instead."};
6858 }
6859 return operator""_meters_per_second_squared(value);
6860}
6861
6862[[nodiscard]] consteval Force1D operator""_Newton(long double value) {
6863 return static_cast<Scalar>(value) * NEWTON;
6864}
6865
6866[[nodiscard]] consteval Force1D operator""_Newton(unsigned long long value) {
6867 return static_cast<Scalar>(value) * NEWTON;
6868}
6869
6870[[nodiscard]] consteval Force1D operator""_kilogram_meters_per_second_squared(long double value) {
6871 return static_cast<Scalar>(value) * NEWTON;
6872}
6873
6874[[nodiscard]] consteval Force1D operator""_kilogram_meters_per_second_squared(unsigned long long value) {
6875 return static_cast<Scalar>(value) * NEWTON;
6876}
6877
6878[[nodiscard]] consteval Force1D operator""_kilogram_meter_per_second_squared(long double value) {
6879 if (value != 1.0l) {
6880 throw physics::Error{
6881 "Syntax error: Expected \"1.0_kilogram_meter_per_second_squared\". For values other than 1, use the plural form \"_kilogram_meters_per_second_squared\" instead."};
6882 }
6883 return operator""_kilogram_meters_per_second_squared(value);
6884}
6885
6886[[nodiscard]] consteval Force1D operator""_kilogram_meter_per_second_squared(unsigned long long value) {
6887 if (value != 1ull) {
6888 throw physics::Error{
6889 "Syntax error: Expected \"1_kilogram_meter_per_second_squared\". For values other than 1, use the plural form \"_kilogram_meters_per_second_squared\" instead."};
6890 }
6891 return operator""_kilogram_meters_per_second_squared(value);
6892}
6893
6894[[nodiscard]] consteval Torque2D operator""_Newton_meters(long double value) {
6895 return static_cast<Scalar>(value) * NEWTON_METERS;
6896}
6897
6898[[nodiscard]] consteval Torque2D operator""_Newton_meters(unsigned long long value) {
6899 return static_cast<Scalar>(value) * NEWTON_METERS;
6900}
6901
6902[[nodiscard]] consteval Torque2D operator""_Newton_meter(long double value) {
6903 if (value != 1.0l) {
6904 throw physics::Error{"Syntax error: Expected \"1.0_Newton_meter\". For values other than 1, use the plural form \"_Newton_meters\" instead."};
6905 }
6906 return operator""_Newton_meters(value);
6907}
6908
6909[[nodiscard]] consteval Torque2D operator""_Newton_meter(unsigned long long value) {
6910 if (value != 1ull) {
6911 throw physics::Error{"Syntax error: Expected \"1_Newton_meter\". For values other than 1, use the plural form \"_Newton_meters\" instead."};
6912 }
6913 return operator""_Newton_meters(value);
6914}
6915
6916[[nodiscard]] consteval Torque2D operator""_kilogram_square_meters_per_second_squared(long double value) {
6917 return static_cast<Scalar>(value) * NEWTON_METERS;
6918}
6919
6920[[nodiscard]] consteval Torque2D operator""_kilogram_square_meters_per_second_squared(unsigned long long value) {
6921 return static_cast<Scalar>(value) * NEWTON_METERS;
6922}
6923
6924[[nodiscard]] consteval Torque2D operator""_kilogram_square_meter_per_second_squared(long double value) {
6925 if (value != 1.0l) {
6926 throw physics::Error{
6927 "Syntax error: Expected \"1.0_kilogram_square_meter_per_second_squared\". For values other than 1, use the plural form "
6928 "\"_kilogram_square_meters_per_second_squared\" instead."};
6929 }
6930 return operator""_kilogram_square_meters_per_second_squared(value);
6931}
6932
6933[[nodiscard]] consteval Torque2D operator""_kilogram_square_meter_per_second_squared(unsigned long long value) {
6934 if (value != 1ull) {
6935 throw physics::Error{
6936 "Syntax error: Expected \"1_kilogram_square_meter_per_second_squared\". For values other than 1, use the plural form \"_kilogram_square_meters_per_second_squared\" "
6937 "instead."};
6938 }
6939 return operator""_kilogram_square_meters_per_second_squared(value);
6940}
6941
6942[[nodiscard]] consteval Impulse operator""_Newton_seconds(long double value) {
6943 return static_cast<Scalar>(value) * NEWTON_SECONDS;
6944}
6945
6946[[nodiscard]] consteval Impulse operator""_Newton_seconds(unsigned long long value) {
6947 return static_cast<Scalar>(value) * NEWTON_SECONDS;
6948}
6949
6950[[nodiscard]] consteval Impulse operator""_Newton_second(long double value) {
6951 if (value != 1.0l) {
6952 throw physics::Error{"Syntax error: Expected \"1.0_Newton_second\". For values other than 1, use the plural form \"_Newton_seconds\" instead."};
6953 }
6954 return operator""_Newton_seconds(value);
6955}
6956
6957[[nodiscard]] consteval Impulse operator""_Newton_second(unsigned long long value) {
6958 if (value != 1ull) {
6959 throw physics::Error{"Syntax error: Expected \"1_Newton_second\". For values other than 1, use the plural form \"_Newton_seconds\" instead."};
6960 }
6961 return operator""_Newton_seconds(value);
6962}
6963
6964[[nodiscard]] consteval Momentum operator""_kilogram_meters_per_second(long double value) {
6965 return static_cast<Scalar>(value) * KILOGRAM_METERS_PER_SECOND;
6966}
6967
6968[[nodiscard]] consteval Momentum operator""_kilogram_meters_per_second(unsigned long long value) {
6969 return static_cast<Scalar>(value) * KILOGRAM_METERS_PER_SECOND;
6970}
6971
6972[[nodiscard]] consteval Momentum operator""_kilogram_meter_per_second(long double value) {
6973 if (value != 1.0l) {
6974 throw physics::Error{"Syntax error: Expected \"1.0_kilogram_meter_per_second\". For values other than 1, use the plural form \"_kilogram_meters_per_second\" instead."};
6975 }
6976 return operator""_kilogram_meters_per_second(value);
6977}
6978
6979[[nodiscard]] consteval Momentum operator""_kilogram_meter_per_second(unsigned long long value) {
6980 if (value != 1ull) {
6981 throw physics::Error{"Syntax error: Expected \"1_kilogram_meter_per_second\". For values other than 1, use the plural form \"_kilogram_meters_per_second\" instead."};
6982 }
6983 return operator""_kilogram_meters_per_second(value);
6984}
6985
6986[[nodiscard]] consteval MomentOfInertia2D operator""_kilogram_square_meters(long double value) {
6987 return static_cast<Scalar>(value) * KILOGRAM_SQUARE_METERS;
6988}
6989
6990[[nodiscard]] consteval MomentOfInertia2D operator""_kilogram_square_meters(unsigned long long value) {
6991 return static_cast<Scalar>(value) * KILOGRAM_SQUARE_METERS;
6992}
6993
6994[[nodiscard]] consteval MomentOfInertia2D operator""_kilogram_square_meter(long double value) {
6995 if (value != 1.0l) {
6996 throw physics::Error{"Syntax error: Expected \"1.0_kilogram_square_meter\". For values other than 1, use the plural form \"_kilogram_square_meters\" instead."};
6997 }
6998 return operator""_kilogram_square_meters(value);
6999}
7000
7001[[nodiscard]] consteval MomentOfInertia2D operator""_kilogram_square_meter(unsigned long long value) {
7002 if (value != 1ull) {
7003 throw physics::Error{"Syntax error: Expected \"1_kilogram_square_meter\". For values other than 1, use the plural form \"_kilogram_square_meters\" instead."};
7004 }
7005 return operator""_kilogram_square_meters(value);
7006}
7007
7008[[nodiscard]] consteval AngularAbsement2D operator""_radian_seconds(long double value) {
7009 return static_cast<Scalar>(value) * RADIAN_SECONDS;
7010}
7011
7012[[nodiscard]] consteval AngularAbsement2D operator""_radian_seconds(unsigned long long value) {
7013 return static_cast<Scalar>(value) * RADIAN_SECONDS;
7014}
7015
7016[[nodiscard]] consteval AngularAbsement2D operator""_radian_second(long double value) {
7017 if (value != 1.0l) {
7018 throw physics::Error{"Syntax error: Expected \"1.0_radian_second\". For values other than 1, use the plural form \"_radian_seconds\" instead."};
7019 }
7020 return operator""_radian_seconds(value);
7021}
7022
7023[[nodiscard]] consteval AngularAbsement2D operator""_radian_second(unsigned long long value) {
7024 if (value != 1ull) {
7025 throw physics::Error{"Syntax error: Expected \"1_radian_second\". For values other than 1, use the plural form \"_radian_seconds\" instead."};
7026 }
7027 return operator""_radian_seconds(value);
7028}
7029
7030[[nodiscard]] consteval AngularAbsement2D operator""_degree_seconds(long double value) {
7031 return static_cast<Scalar>(value * 0.01745329251994329576923690768489l) * RADIAN_SECONDS;
7032}
7033
7034[[nodiscard]] consteval AngularAbsement2D operator""_degree_seconds(unsigned long long value) {
7035 return static_cast<Scalar>(static_cast<long double>(value) * 0.01745329251994329576923690768489l) * RADIAN_SECONDS;
7036}
7037
7038[[nodiscard]] consteval AngularAbsement2D operator""_degree_second(long double value) {
7039 if (value != 1.0l) {
7040 throw physics::Error{"Syntax error: Expected \"1.0_degree_second\". For values other than 1, use the plural form \"_degree_seconds\" instead."};
7041 }
7042 return operator""_degree_seconds(value);
7043}
7044
7045[[nodiscard]] consteval AngularAbsement2D operator""_degree_second(unsigned long long value) {
7046 if (value != 1ull) {
7047 throw physics::Error{"Syntax error: Expected \"1_degree_second\". For values other than 1, use the plural form \"_degree_seconds\" instead."};
7048 }
7049 return operator""_degree_seconds(value);
7050}
7051
7052[[nodiscard]] consteval AngularAbsement2D operator""_turn_seconds(long double value) {
7053 return static_cast<Scalar>(value * 6.28318530718l) * RADIAN_SECONDS;
7054}
7055
7056[[nodiscard]] consteval AngularAbsement2D operator""_turn_seconds(unsigned long long value) {
7057 return static_cast<Scalar>(static_cast<long double>(value) * 6.28318530718l) * RADIAN_SECONDS;
7058}
7059
7060[[nodiscard]] consteval AngularAbsement2D operator""_turn_second(long double value) {
7061 if (value != 1.0l) {
7062 throw physics::Error{"Syntax error: Expected \"1.0_turn_second\". For values other than 1, use the plural form \"_turn_seconds\" instead."};
7063 }
7064 return operator""_turn_seconds(value);
7065}
7066
7067[[nodiscard]] consteval AngularAbsement2D operator""_turn_second(unsigned long long value) {
7068 if (value != 1ull) {
7069 throw physics::Error{"Syntax error: Expected \"1_turn_second\". For values other than 1, use the plural form \"_turn_seconds\" instead."};
7070 }
7071 return operator""_turn_seconds(value);
7072}
7073
7074[[nodiscard]] consteval AngularVelocity2D operator""_radians_per_second(long double value) {
7075 return static_cast<Scalar>(value) * RADIANS_PER_SECOND;
7076}
7077
7078[[nodiscard]] consteval AngularVelocity2D operator""_radians_per_second(unsigned long long value) {
7079 return static_cast<Scalar>(value) * RADIANS_PER_SECOND;
7080}
7081
7082[[nodiscard]] consteval AngularVelocity2D operator""_radian_per_second(long double value) {
7083 if (value != 1.0l) {
7084 throw physics::Error{"Syntax error: Expected \"1.0_radian_per_second\". For values other than 1, use the plural form \"_radians_per_second\" instead."};
7085 }
7086 return operator""_radians_per_second(value);
7087}
7088
7089[[nodiscard]] consteval AngularVelocity2D operator""_radian_per_second(unsigned long long value) {
7090 if (value != 1ull) {
7091 throw physics::Error{"Syntax error: Expected \"1_radian_per_second\". For values other than 1, use the plural form \"_radians_per_second\" instead."};
7092 }
7093 return operator""_radians_per_second(value);
7094}
7095
7096[[nodiscard]] consteval AngularVelocity2D operator""_degrees_per_second(long double value) {
7097 return static_cast<Scalar>(value * 0.01745329251994329576923690768489l) * RADIANS_PER_SECOND;
7098}
7099
7100[[nodiscard]] consteval AngularVelocity2D operator""_degrees_per_second(unsigned long long value) {
7101 return static_cast<Scalar>(static_cast<long double>(value) * 0.01745329251994329576923690768489l) * RADIANS_PER_SECOND;
7102}
7103
7104[[nodiscard]] consteval AngularVelocity2D operator""_degree_per_second(long double value) {
7105 if (value != 1.0l) {
7106 throw physics::Error{"Syntax error: Expected \"1.0_degree_per_second\". For values other than 1, use the plural form \"_degrees_per_second\" instead."};
7107 }
7108 return operator""_degrees_per_second(value);
7109}
7110
7111[[nodiscard]] consteval AngularVelocity2D operator""_degree_per_second(unsigned long long value) {
7112 if (value != 1ull) {
7113 throw physics::Error{"Syntax error: Expected \"1_degree_per_second\". For values other than 1, use the plural form \"_degrees_per_second\" instead."};
7114 }
7115 return operator""_degrees_per_second(value);
7116}
7117
7118[[nodiscard]] consteval AngularVelocity2D operator""_turns_per_second(long double value) {
7119 return static_cast<Scalar>(value * 6.28318530718l) * RADIANS_PER_SECOND;
7120}
7121
7122[[nodiscard]] consteval AngularVelocity2D operator""_turns_per_second(unsigned long long value) {
7123 return static_cast<Scalar>(static_cast<long double>(value) * 6.28318530718l) * RADIANS_PER_SECOND;
7124}
7125
7126[[nodiscard]] consteval AngularVelocity2D operator""_turn_per_second(long double value) {
7127 if (value != 1.0l) {
7128 throw physics::Error{"Syntax error: Expected \"1.0_turn_per_second\". For values other than 1, use the plural form \"_turns_per_second\" instead."};
7129 }
7130 return operator""_turns_per_second(value);
7131}
7132
7133[[nodiscard]] consteval AngularVelocity2D operator""_turn_per_second(unsigned long long value) {
7134 if (value != 1ull) {
7135 throw physics::Error{"Syntax error: Expected \"1_turn_per_second\". For values other than 1, use the plural form \"_turns_per_second\" instead."};
7136 }
7137 return operator""_turns_per_second(value);
7138}
7139
7140[[nodiscard]] consteval AngularVelocity2D operator""_revolutions_per_minute(long double value) {
7141 return static_cast<Scalar>(value * 0.10471975511965977462l) * RADIANS_PER_SECOND;
7142}
7143
7144[[nodiscard]] consteval AngularVelocity2D operator""_revolutions_per_minute(unsigned long long value) {
7145 return static_cast<Scalar>(static_cast<long double>(value) * 0.10471975511965977462l) * RADIANS_PER_SECOND;
7146}
7147
7148[[nodiscard]] consteval AngularVelocity2D operator""_revolution_per_minute(long double value) {
7149 if (value != 1.0l) {
7150 throw physics::Error{"Syntax error: Expected \"1.0_revolution_per_minute\". For values other than 1, use the plural form \"_revolutions_per_minute\" instead."};
7151 }
7152 return operator""_revolutions_per_minute(value);
7153}
7154
7155[[nodiscard]] consteval AngularVelocity2D operator""_revolution_per_minute(unsigned long long value) {
7156 if (value != 1ull) {
7157 throw physics::Error{"Syntax error: Expected \"1_revolution_per_minute\". For values other than 1, use the plural form \"_revolutions_per_minute\" instead."};
7158 }
7159 return operator""_revolutions_per_minute(value);
7160}
7161
7162[[nodiscard]] consteval AngularAcceleration2D operator""_radians_per_second_squared(long double value) {
7163 return static_cast<Scalar>(value) * RADIANS_PER_SECOND_SQUARED;
7164}
7165
7166[[nodiscard]] consteval AngularAcceleration2D operator""_radians_per_second_squared(unsigned long long value) {
7167 return static_cast<Scalar>(value) * RADIANS_PER_SECOND_SQUARED;
7168}
7169
7170[[nodiscard]] consteval AngularAcceleration2D operator""_radian_per_second_squared(long double value) {
7171 if (value != 1.0l) {
7172 throw physics::Error{"Syntax error: Expected \"1.0_radian_per_second_squared\". For values other than 1, use the plural form \"_radians_per_second_squared\" instead."};
7173 }
7174 return operator""_radians_per_second_squared(value);
7175}
7176
7177[[nodiscard]] consteval AngularAcceleration2D operator""_radian_per_second_squared(unsigned long long value) {
7178 if (value != 1ull) {
7179 throw physics::Error{"Syntax error: Expected \"1_radian_per_second_squared\". For values other than 1, use the plural form \"_radians_per_second_squared\" instead."};
7180 }
7181 return operator""_radians_per_second_squared(value);
7182}
7183
7184[[nodiscard]] consteval LinearViscousDamping operator""_Newton_seconds_per_meter(long double value) {
7185 return static_cast<Scalar>(value) * NEWTON_SECONDS_PER_METER;
7186}
7187
7188[[nodiscard]] consteval LinearViscousDamping operator""_Newton_seconds_per_meter(unsigned long long value) {
7189 return static_cast<Scalar>(value) * NEWTON_SECONDS_PER_METER;
7190}
7191
7192[[nodiscard]] consteval LinearViscousDamping operator""_Newton_second_per_meter(long double value) {
7193 if (value != 1.0l) {
7194 throw physics::Error{"Syntax error: Expected \"1.0_Newton_second_per_meter\". For values other than 1, use the plural form \"_Newton_seconds_per_meter\" instead."};
7195 }
7196 return operator""_Newton_seconds_per_meter(value);
7197}
7198
7199[[nodiscard]] consteval LinearViscousDamping operator""_Newton_second_per_meter(unsigned long long value) {
7200 if (value != 1ull) {
7201 throw physics::Error{"Syntax error: Expected \"1_Newton_second_per_meter\". For values other than 1, use the plural form \"_Newton_seconds_per_meter\" instead."};
7202 }
7203 return operator""_Newton_seconds_per_meter(value);
7204}
7205
7206[[nodiscard]] consteval AngularViscousDamping operator""_Newton_meter_seconds_per_radian(long double value) {
7207 return static_cast<Scalar>(value) * NEWTON_METER_SECONDS_PER_RADIAN;
7208}
7209
7210[[nodiscard]] consteval AngularViscousDamping operator""_Newton_meter_seconds_per_radian(unsigned long long value) {
7211 return static_cast<Scalar>(value) * NEWTON_METER_SECONDS_PER_RADIAN;
7212}
7213
7214[[nodiscard]] consteval AngularViscousDamping operator""_Newton_meter_second_per_radian(long double value) {
7215 if (value != 1.0l) {
7216 throw physics::Error{
7217 "Syntax error: Expected \"1.0_Newton_meter_second_per_radian\". For values other than 1, use the plural form \"_Newton_meter_seconds_per_radian\" instead."};
7218 }
7219 return operator""_Newton_meter_seconds_per_radian(value);
7220}
7221
7222[[nodiscard]] consteval AngularViscousDamping operator""_Newton_meter_second_per_radian(unsigned long long value) {
7223 if (value != 1ull) {
7224 throw physics::Error{
7225 "Syntax error: Expected \"1_Newton_meter_second_per_radian\". For values other than 1, use the plural form \"_Newton_meter_seconds_per_radian\" instead."};
7226 }
7227 return operator""_Newton_meter_seconds_per_radian(value);
7228}
7229
7230[[nodiscard]] consteval MassFlowRate operator""_kilograms_per_second(long double value) {
7231 return static_cast<Scalar>(value) * KILOGRAMS_PER_SECOND;
7232}
7233
7234[[nodiscard]] consteval MassFlowRate operator""_kilograms_per_second(unsigned long long value) {
7235 return static_cast<Scalar>(value) * KILOGRAMS_PER_SECOND;
7236}
7237
7238[[nodiscard]] consteval MassFlowRate operator""_kilogram_per_second(long double value) {
7239 if (value != 1.0l) {
7240 throw physics::Error{"Syntax error: Expected \"1.0_kilogram_per_second\". For values other than 1, use the plural form \"_kilograms_per_second\" instead."};
7241 }
7242 return operator""_kilograms_per_second(value);
7243}
7244
7245[[nodiscard]] consteval MassFlowRate operator""_kilogram_per_second(unsigned long long value) {
7246 if (value != 1ull) {
7247 throw physics::Error{"Syntax error: Expected \"1_kilogram_per_second\". For values other than 1, use the plural form \"_kilograms_per_second\" instead."};
7248 }
7249 return operator""_kilograms_per_second(value);
7250}
7251
7252[[nodiscard]] consteval VolumetricFlowRate operator""_cubic_meters_per_second(long double value) {
7253 return static_cast<Scalar>(value) * CUBIC_METERS_PER_SECOND;
7254}
7255
7256[[nodiscard]] consteval VolumetricFlowRate operator""_cubic_meters_per_second(unsigned long long value) {
7257 return static_cast<Scalar>(value) * CUBIC_METERS_PER_SECOND;
7258}
7259
7260[[nodiscard]] consteval VolumetricFlowRate operator""_cubic_meter_per_second(long double value) {
7261 if (value != 1.0l) {
7262 throw physics::Error{"Syntax error: Expected \"1.0_cubic_meter_per_second\". For values other than 1, use the plural form \"_cubic_meters_per_second\" instead."};
7263 }
7264 return operator""_cubic_meters_per_second(value);
7265}
7266
7267[[nodiscard]] consteval VolumetricFlowRate operator""_cubic_meter_per_second(unsigned long long value) {
7268 if (value != 1ull) {
7269 throw physics::Error{"Syntax error: Expected \"1_cubic_meter_per_second\". For values other than 1, use the plural form \"_cubic_meters_per_second\" instead."};
7270 }
7271 return operator""_cubic_meters_per_second(value);
7272}
7273
7274[[nodiscard]] consteval Power operator""_Watts(long double value) {
7275 return static_cast<Scalar>(value) * WATTS;
7276}
7277
7278[[nodiscard]] consteval Power operator""_Watts(unsigned long long value) {
7279 return static_cast<Scalar>(value) * WATTS;
7280}
7281
7282[[nodiscard]] consteval Power operator""_Watt(long double value) {
7283 return operator""_Watts(value);
7284}
7285
7286[[nodiscard]] consteval Power operator""_Watt(unsigned long long value) {
7287 return operator""_Watts(value);
7288}
7289
7290[[nodiscard]] consteval Power operator""_kilowatts(long double value) {
7291 return static_cast<Scalar>(value * 1000.0l) * WATTS;
7292}
7293
7294[[nodiscard]] consteval Power operator""_kilowatts(unsigned long long value) {
7295 return static_cast<Scalar>(static_cast<long double>(value) * 1000.0l) * WATTS;
7296}
7297
7298[[nodiscard]] consteval Power operator""_kilowatt(long double value) {
7299 return operator""_kilowatts(value);
7300}
7301
7302[[nodiscard]] consteval Power operator""_kilowatt(unsigned long long value) {
7303 return operator""_kilowatts(value);
7304}
7305
7306[[nodiscard]] consteval Power operator""_megawatts(long double value) {
7307 return static_cast<Scalar>(value * 1000000.0l) * WATTS;
7308}
7309
7310[[nodiscard]] consteval Power operator""_megawatts(unsigned long long value) {
7311 return static_cast<Scalar>(static_cast<long double>(value) * 1000000.0l) * WATTS;
7312}
7313
7314[[nodiscard]] consteval Power operator""_megawatt(long double value) {
7315 return operator""_megawatts(value);
7316}
7317
7318[[nodiscard]] consteval Power operator""_megawatt(unsigned long long value) {
7319 return operator""_megawatts(value);
7320}
7321
7322[[nodiscard]] consteval Energy operator""_Joules(long double value) {
7323 return static_cast<Scalar>(value) * JOULES;
7324}
7325
7326[[nodiscard]] consteval Energy operator""_Joules(unsigned long long value) {
7327 return static_cast<Scalar>(value) * JOULES;
7328}
7329
7330[[nodiscard]] consteval Energy operator""_Joule(long double value) {
7331 return operator""_Joules(value);
7332}
7333
7334[[nodiscard]] consteval Energy operator""_Joule(unsigned long long value) {
7335 return operator""_Joules(value);
7336}
7337
7338[[nodiscard]] consteval Energy operator""_kilojoules(long double value) {
7339 return static_cast<Scalar>(value * 1000.0l) * JOULES;
7340}
7341
7342[[nodiscard]] consteval Energy operator""_kilojoules(unsigned long long value) {
7343 return static_cast<Scalar>(static_cast<long double>(value) * 1000.0l) * JOULES;
7344}
7345
7346[[nodiscard]] consteval Energy operator""_kilojoule(long double value) {
7347 return operator""_kilojoules(value);
7348}
7349
7350[[nodiscard]] consteval Energy operator""_kilojoule(unsigned long long value) {
7351 return operator""_kilojoules(value);
7352}
7353
7354[[nodiscard]] consteval Energy operator""_megajoules(long double value) {
7355 return static_cast<Scalar>(value * 1000000.0l) * JOULES;
7356}
7357
7358[[nodiscard]] consteval Energy operator""_megajoules(unsigned long long value) {
7359 return static_cast<Scalar>(static_cast<long double>(value) * 1000000.0l) * JOULES;
7360}
7361
7362[[nodiscard]] consteval Energy operator""_megajoule(long double value) {
7363 return operator""_megajoules(value);
7364}
7365
7366[[nodiscard]] consteval Energy operator""_megajoule(unsigned long long value) {
7367 return operator""_megajoules(value);
7368}
7369
7370[[nodiscard]] consteval Energy operator""_kilowatt_hours(long double value) {
7371 return static_cast<Scalar>(value * 3600000.0l) * JOULES;
7372}
7373
7374[[nodiscard]] consteval Energy operator""_kilowatt_hours(unsigned long long value) {
7375 return static_cast<Scalar>(static_cast<long double>(value) * 3600000.0l) * JOULES;
7376}
7377
7378[[nodiscard]] consteval Energy operator""_kilowatt_hour(long double value) {
7379 if (value != 1.0l) {
7380 throw physics::Error{"Syntax error: Expected \"1.0_kilowatt_hour\". For values other than 1, use the plural form \"_kilowatt_hours\" instead."};
7381 }
7382 return operator""_kilowatt_hours(value);
7383}
7384
7385[[nodiscard]] consteval Energy operator""_kilowatt_hour(unsigned long long value) {
7386 if (value != 1ull) {
7387 throw physics::Error{"Syntax error: Expected \"1_kilowatt_hour\". For values other than 1, use the plural form \"_kilowatt_hours\" instead."};
7388 }
7389 return operator""_kilowatt_hours(value);
7390}
7391
7392[[nodiscard]] consteval Energy operator""_megawatt_hours(long double value) {
7393 return static_cast<Scalar>(value * 3600000000.0l) * JOULES;
7394}
7395
7396[[nodiscard]] consteval Energy operator""_megawatt_hours(unsigned long long value) {
7397 return static_cast<Scalar>(static_cast<long double>(value) * 3600000000.0l) * JOULES;
7398}
7399
7400[[nodiscard]] consteval Energy operator""_megawatt_hour(long double value) {
7401 if (value != 1.0l) {
7402 throw physics::Error{"Syntax error: Expected \"1.0_megawatt_hour\". For values other than 1, use the plural form \"_megawatt_hours\" instead."};
7403 }
7404 return operator""_megawatt_hours(value);
7405}
7406
7407[[nodiscard]] consteval Energy operator""_megawatt_hour(unsigned long long value) {
7408 if (value != 1ull) {
7409 throw physics::Error{"Syntax error: Expected \"1_megawatt_hour\". For values other than 1, use the plural form \"_megawatt_hours\" instead."};
7410 }
7411 return operator""_megawatt_hours(value);
7412}
7413
7414[[nodiscard]] consteval Stiffness operator""_Newton_per_meter(long double value) {
7415 return static_cast<Scalar>(value) * NEWTON_PER_METER;
7416}
7417
7418[[nodiscard]] consteval Stiffness operator""_Newton_per_meter(unsigned long long value) {
7419 return static_cast<Scalar>(value) * NEWTON_PER_METER;
7420}
7421
7422[[nodiscard]] consteval Stiffness operator""_Newton_per_millimeter(long double value) {
7423 return static_cast<Scalar>(value * 1000.0l) * NEWTON_PER_METER;
7424}
7425
7426[[nodiscard]] consteval Stiffness operator""_Newton_per_millimeter(unsigned long long value) {
7427 return static_cast<Scalar>(static_cast<long double>(value) * 1000.0l) * NEWTON_PER_METER;
7428}
7429
7430[[nodiscard]] consteval Compliance operator""_meters_per_Newton(long double value) {
7431 return static_cast<Scalar>(value) * METERS_PER_NEWTON;
7432}
7433
7434[[nodiscard]] consteval Compliance operator""_meters_per_Newton(unsigned long long value) {
7435 return static_cast<Scalar>(value) * METERS_PER_NEWTON;
7436}
7437
7438[[nodiscard]] consteval Compliance operator""_meter_per_Newton(long double value) {
7439 if (value != 1.0l) {
7440 throw physics::Error{"Syntax error: Expected \"1.0_meter_per_Newton\". For values other than 1, use the plural form \"_meters_per_Newton\" instead."};
7441 }
7442 return operator""_meters_per_Newton(value);
7443}
7444
7445[[nodiscard]] consteval Compliance operator""_meter_per_Newton(unsigned long long value) {
7446 if (value != 1ull) {
7447 throw physics::Error{"Syntax error: Expected \"1_meter_per_Newton\". For values other than 1, use the plural form \"_meters_per_Newton\" instead."};
7448 }
7449 return operator""_meters_per_Newton(value);
7450}
7451
7452[[nodiscard]] consteval Compliance operator""_millimeters_per_Newton(long double value) {
7453 return static_cast<Scalar>(value * 0.001l) * METERS_PER_NEWTON;
7454}
7455
7456[[nodiscard]] consteval Compliance operator""_millimeters_per_Newton(unsigned long long value) {
7457 return static_cast<Scalar>(value * 0.001l) * METERS_PER_NEWTON;
7458}
7459
7460[[nodiscard]] consteval Compliance operator""_millimeter_per_Newton(long double value) {
7461 if (value != 1.0l) {
7462 throw physics::Error{"Syntax error: Expected \"1.0_millimeter_per_Newton\". For values other than 1, use the plural form \"_millimeters_per_Newton\" instead."};
7463 }
7464 return operator""_millimeters_per_Newton(value);
7465}
7466
7467[[nodiscard]] consteval Compliance operator""_millimeter_per_Newton(unsigned long long value) {
7468 if (value != 1ull) {
7469 throw physics::Error{"Syntax error: Expected \"1_millimeter_per_Newton\". For values other than 1, use the plural form \"_millimeters_per_Newton\" instead."};
7470 }
7471 return operator""_millimeters_per_Newton(value);
7472}
7473
7474} // namespace literals
7475
7476} // namespace grem::physics
7477
7478namespace grem {
7479namespace physics_literals = grem::physics::literals; // NOLINT(misc-unused-alias-decls)
7480} // namespace grem
7481
7482template <typename UnitT>
7483struct grem::Formatter<grem::physics::Quantity<1, UnitT>> : Formatter<physics::Scalar> {
7485
7486 [[nodiscard]] constexpr const char* parseFormatSpecification(const char* p) {
7488 if (*p == 'z') {
7489 symbolSeparator = {};
7490 ++p;
7491 }
7492 return p;
7493 }
7494
7496 Formatter<physics::Scalar>::formatTo(output, value._private_getUnderlyingValue());
7497 const auto symbolString = UnitT::getSymbolString();
7498 if (!symbolString.empty()) {
7499 output.append(symbolSeparator);
7500 output.append(StringView{symbolString});
7501 }
7502 }
7503};
7504
7505template <typename UnitT>
7506struct grem::Formatter<grem::physics::Quantity<2, UnitT>> : Formatter<vec<2, physics::Scalar>> {
7508
7509 [[nodiscard]] constexpr const char* parseFormatSpecification(const char* p) {
7511 if (*p == 'z') {
7512 symbolSeparator = {};
7513 ++p;
7514 }
7515 return p;
7516 }
7517
7519 Formatter<vec<2, physics::Scalar>>::formatTo(output, value._private_getUnderlyingValue());
7520 const auto symbolString = UnitT::getSymbolString();
7521 if (!symbolString.empty()) {
7522 output.append(symbolSeparator);
7523 output.append(StringView{symbolString});
7524 }
7525 }
7526};
7527
7528template <typename UnitT>
7529struct grem::Formatter<grem::physics::Quantity<3, UnitT>> : Formatter<vec<3, physics::Scalar>> {
7531
7532 [[nodiscard]] constexpr const char* parseFormatSpecification(const char* p) {
7534 if (*p == 'z') {
7535 symbolSeparator = {};
7536 ++p;
7537 }
7538 return p;
7539 }
7540
7542 Formatter<vec<3, physics::Scalar>>::formatTo(output, value._private_getUnderlyingValue());
7543 const auto symbolString = UnitT::getSymbolString();
7544 if (!symbolString.empty()) {
7545 output.append(symbolSeparator);
7546 output.append(StringView{symbolString});
7547 }
7548 }
7549};
7550
7551template <typename UnitT>
7552struct grem::Formatter<grem::physics::TensorQuantity<2, UnitT>> : Formatter<mat<2, 2, physics::Scalar>> {
7554
7555 [[nodiscard]] constexpr const char* parseFormatSpecification(const char* p) {
7557 if (*p == 'z') {
7558 symbolSeparator = {};
7559 ++p;
7560 }
7561 return p;
7562 }
7563
7565 Formatter<mat<2, 2, physics::Scalar>>::formatTo(output, value._private_value);
7566 const auto symbolString = UnitT::getSymbolString();
7567 if (!symbolString.empty()) {
7568 output.append(symbolSeparator);
7569 output.append(StringView{symbolString});
7570 }
7571 }
7572};
7573
7574template <typename UnitT>
7575struct grem::Formatter<grem::physics::TensorQuantity<3, UnitT>> : Formatter<mat<3, 3, physics::Scalar>> {
7577
7578 [[nodiscard]] constexpr const char* parseFormatSpecification(const char* p) {
7580 if (*p == 'z') {
7581 symbolSeparator = {};
7582 ++p;
7583 }
7584 return p;
7585 }
7586
7588 Formatter<mat<3, 3, physics::Scalar>>::formatTo(output, value._private_value);
7589 const auto symbolString = UnitT::getSymbolString();
7590 if (!symbolString.empty()) {
7591 output.append(symbolSeparator);
7592 output.append(StringView{symbolString});
7593 }
7594 }
7595};
7596
7597template <size_t N>
7598struct grem::Formatter<grem::physics::Direction<N>> : Formatter<grem::physics::Scale<N>> {};
7599
7600template <size_t N>
7601struct grem::Formatter<grem::physics::OrthonormalBasis<N>> : Formatter<grem::physics::Basis<N>> {};
7602
7603template <>
7604struct grem::Formatter<grem::physics::Orientation<2>> : Formatter<physics::Scalar> {
7606
7607 [[nodiscard]] constexpr const char* parseFormatSpecification(const char* p) {
7609 if (*p == 'z') {
7610 symbolSeparator = {};
7611 ++p;
7612 }
7613 return p;
7614 }
7615
7616 void formatTo(FormatOutput& output, physics::Orientation<2> value) const {
7617 Formatter<physics::Scalar>::formatTo(output, value._private_value);
7618 output.append(symbolSeparator);
7619 output.append("rad");
7620 }
7621};
7622
7623template <>
7624struct grem::Formatter<grem::physics::Orientation<3>> : Formatter<qua<physics::Scalar>> {
7625 void formatTo(FormatOutput& output, physics::Orientation<3> value) const {
7626 Formatter<qua<physics::Scalar>>::formatTo(output, value._private_value);
7627 }
7628};
7629
7630template <>
7636
7637template <>
7638struct grem::Formatter<grem::physics::LocalInertiaOrientation<3>> : Formatter<physics::Orientation<3>> {
7642};
7643
7644namespace grem::json {
7645
7646template <typename T>
7647struct Serializer; // Forward declaration, to avoid including json.hpp.
7648
7649template <typename T>
7650struct Deserializer; // Forward declaration, to avoid including json.hpp.
7651
7652} // namespace grem::json
7653
7654template <grem::size_t N, typename UnitT>
7656 void serializeTo(auto& writer, const grem::physics::Quantity<N, UnitT>& value) {
7657 writer.serialize(value._private_getUnderlyingValue());
7658 }
7659};
7660
7661template <grem::size_t N, typename UnitT>
7664 decltype(value._private_getUnderlyingValue()) underlyingValue{};
7665 reader.deserialize(underlyingValue);
7666 value = grem::physics::Quantity<N, UnitT>::reinterpret(underlyingValue);
7667 }
7668};
7669
7670#endif
#define GREM_ALWAYS_INLINE
Definition attributes.hpp:10
#define GREM_VECTORCALL
Definition attributes.hpp:51
Definition formatting.hpp:41
virtual constexpr void append(StringView string)=0
Optional value type that holds either a value or no value.
Definition Optional.hpp:58
GREM_ALWAYS_INLINE ComponentProxy operator=(Quantity< 1, UnitT > value) const noexcept
Definition quantities.hpp:1867
GREM_ALWAYS_INLINE ComponentProxy operator+=(Quantity< 1, OtherUnitT > value) const noexcept
Definition quantities.hpp:1910
GREM_ALWAYS_INLINE ComponentProxy operator*=(Scalar value) const noexcept
Definition quantities.hpp:1955
GREM_ALWAYS_INLINE ComponentProxy operator-=(Quantity< 1, OtherUnitT > value) const noexcept
Definition quantities.hpp:1933
GREM_ALWAYS_INLINE ComponentProxy operator=(Zero) const noexcept
Definition quantities.hpp:1888
GREM_ALWAYS_INLINE ComponentProxy operator/=(Scalar value) const noexcept
Definition quantities.hpp:1975
GREM_ALWAYS_INLINE constexpr ComponentProxy(Quantity< N, UnitT > &quantity) noexcept
Definition quantities.hpp:1864
GREM_ALWAYS_INLINE constexpr ConstComponentProxy(const Quantity< N, UnitT > &quantity) noexcept
Definition quantities.hpp:1732
typename Unit::MagnitudeType MagnitudeType
Definition quantities.hpp:1726
GREM_ALWAYS_INLINE constexpr auto operator<=>(const Quantity< 1, OtherUnitT > &other) const noexcept
Definition quantities.hpp:1775
GREM_ALWAYS_INLINE constexpr Quantity< 1, Unitless > in(OtherUnitT unit) const
Definition quantities.hpp:1811
GREM_ALWAYS_INLINE constexpr Quantity< 1, OtherUnitT > as(OtherUnitT unit) const
Definition quantities.hpp:1816
typename Unit::DimensionType DimensionType
Definition quantities.hpp:1725
GREM_ALWAYS_INLINE constexpr auto operator<=>(Arithmetic other) const noexcept
Definition quantities.hpp:1785
GREM_ALWAYS_INLINE constexpr auto operator<=>(const ConstComponentProxy< OtherN, OtherUnitT, OtherIndex > &other) const noexcept
Definition quantities.hpp:1765
static constexpr size_t RANK
Definition quantities.hpp:1727
GREM_ALWAYS_INLINE constexpr bool operator==(const ConstComponentProxy< OtherN, OtherUnitT, OtherIndex > &other) const noexcept
Definition quantities.hpp:1760
GREM_ALWAYS_INLINE constexpr bool operator==(const Quantity< 1, OtherUnitT > &other) const noexcept
Definition quantities.hpp:1770
static constexpr DimensionType DIMENSION
Definition quantities.hpp:1729
const Quantity< N, UnitT > * quantity
Definition quantities.hpp:1834
GREM_ALWAYS_INLINE constexpr auto operator<=>(Zero) const noexcept
Definition quantities.hpp:1794
GREM_ALWAYS_INLINE size_t getMaxIndex() const
Definition quantities.hpp:1829
GREM_ALWAYS_INLINE constexpr bool operator==(Arithmetic other) const noexcept
Definition quantities.hpp:1780
GREM_ALWAYS_INLINE constexpr bool operator==(Zero) const noexcept
Definition quantities.hpp:1790
GREM_ALWAYS_INLINE constexpr size_t size() const noexcept
Definition quantities.hpp:1821
GREM_ALWAYS_INLINE constexpr bool operator==(const DurationBase< Rep, Period > &other) const noexcept
Definition quantities.hpp:1799
static constexpr MagnitudeType MAGNITUDE
Definition quantities.hpp:1730
UnitT Unit
Definition quantities.hpp:1724
GREM_ALWAYS_INLINE size_t getMinIndex() const
Definition quantities.hpp:1825
GREM_ALWAYS_INLINE constexpr auto operator<=>(const DurationBase< Rep, Period > &other) const noexcept
Definition quantities.hpp:1805
GREM_ALWAYS_INLINE constexpr Quantity< 1, UnitT > getValue() const noexcept
Definition quantities.hpp:1836
static constexpr Unit UNIT
Definition quantities.hpp:1728
Inverse of an affine transformation in local space.
Definition quantities.hpp:5231
GREM_ALWAYS_INLINE LocalTransformation< N > GREM_VECTORCALL operator*(LocalTransformation< N > b) const
Definition quantities.hpp:5266
GREM_ALWAYS_INLINE Distance GREM_VECTORCALL getDistance(Length< N > localOffset) const
Definition quantities.hpp:5249
GREM_ALWAYS_INLINE Length< N > GREM_VECTORCALL getOriginalOffset() const
Definition quantities.hpp:5241
GREM_ALWAYS_INLINE Distance GREM_VECTORCALL getDistance2(Length< N > localOffset) const
Definition quantities.hpp:5253
GREM_ALWAYS_INLINE Direction< N > GREM_VECTORCALL getDirection(Direction< N > direction) const
Definition quantities.hpp:5262
GREM_ALWAYS_INLINE constexpr InverseLocalTransformation() noexcept=default
GREM_ALWAYS_INLINE friend InverseLocalTransformation< OtherN > GREM_VECTORCALL inverseTranslateScale(Length< OtherN > localOffset, Scale< OtherN > localScale)
GREM_ALWAYS_INLINE friend InverseLocalTransformation< OtherN > GREM_VECTORCALL inverseTranslateRotateScale(Length< OtherN > localOffset, Orientation< OtherN > localOrientation, Scale< OtherN > localScale)
GREM_ALWAYS_INLINE friend InverseLocalTransformation< OtherN > GREM_VECTORCALL inverse(LocalTransformation< OtherN > a)
GREM_ALWAYS_INLINE friend InverseLocalTransformation< OtherN > GREM_VECTORCALL inverseTranslateRotate(Length< OtherN > localOffset, Orientation< OtherN > localOrientation)
GREM_ALWAYS_INLINE friend LocalTransformation< OtherN > GREM_VECTORCALL inverse(InverseLocalTransformation< OtherN > a)
GREM_ALWAYS_INLINE Basis< N > GREM_VECTORCALL getBasis() const
Definition quantities.hpp:5245
GREM_ALWAYS_INLINE Quantity< N, UnitT > GREM_VECTORCALL getRelative(Quantity< N, UnitT > localQuantity) const
Definition quantities.hpp:5258
GREM_ALWAYS_INLINE friend InverseLocalTransformation< OtherN > GREM_VECTORCALL inverseTranslate(Length< OtherN > localOffset)
Inverse of an affine transformation in world space.
Definition quantities.hpp:5359
GREM_ALWAYS_INLINE friend InverseTransformation< OtherN > GREM_VECTORCALL inverse(Transformation< OtherN > a)
GREM_ALWAYS_INLINE friend InverseTransformation< OtherN > GREM_VECTORCALL inverseTranslateScale(Position< OtherN > position, Scale< OtherN > scale)
GREM_ALWAYS_INLINE Position< N > GREM_VECTORCALL getOriginalOrigin() const
Definition quantities.hpp:5369
GREM_ALWAYS_INLINE constexpr InverseTransformation() noexcept=default
GREM_ALWAYS_INLINE Basis< N > GREM_VECTORCALL getBasis() const
Definition quantities.hpp:5373
GREM_ALWAYS_INLINE friend InverseTransformation< OtherN > GREM_VECTORCALL inverseTranslate(Position< OtherN > position)
GREM_ALWAYS_INLINE Distance GREM_VECTORCALL getDistance(Length< N > localOffset) const
Definition quantities.hpp:5377
GREM_ALWAYS_INLINE friend InverseTransformation< OtherN > GREM_VECTORCALL inverseTranslateRotate(Position< OtherN > position, Orientation< OtherN > orientation)
GREM_ALWAYS_INLINE friend InverseTransformation< OtherN > GREM_VECTORCALL inverseTranslateRotateScale(Position< OtherN > position, Orientation< OtherN > orientation, Scale< OtherN > scale)
GREM_ALWAYS_INLINE LocalTransformation< N > GREM_VECTORCALL operator*(Transformation< N > b) const
Definition quantities.hpp:5394
GREM_ALWAYS_INLINE Quantity< N, UnitT > GREM_VECTORCALL getRelative(Quantity< N, UnitT > localQuantity) const
Definition quantities.hpp:5386
GREM_ALWAYS_INLINE Distance GREM_VECTORCALL getDistance2(Length< N > localOffset) const
Definition quantities.hpp:5381
GREM_ALWAYS_INLINE friend Transformation< OtherN > GREM_VECTORCALL inverse(InverseTransformation< OtherN > a)
GREM_ALWAYS_INLINE Direction< N > GREM_VECTORCALL getDirection(Direction< N > direction) const
Definition quantities.hpp:5390
Affine transformation in local space.
Definition quantities.hpp:4984
GREM_ALWAYS_INLINE Length< N > GREM_VECTORCALL getOffset() const
Definition quantities.hpp:5030
GREM_ALWAYS_INLINE constexpr LocalTransformation(Length< N > offset, Basis< N > basis)
Definition quantities.hpp:4992
GREM_ALWAYS_INLINE constexpr LocalTransformation(Zero, Basis< N > basis)
Definition quantities.hpp:4996
GREM_ALWAYS_INLINE Basis< N > GREM_VECTORCALL getBasis() const
Definition quantities.hpp:5034
GREM_ALWAYS_INLINE Distance GREM_VECTORCALL getDistance(Length< N > localOffset) const
Definition quantities.hpp:5038
GREM_ALWAYS_INLINE Direction< N > GREM_VECTORCALL getDirection(Direction< N > direction) const
Definition quantities.hpp:5051
GREM_ALWAYS_INLINE Distance GREM_VECTORCALL getDistance2(Length< N > localOffset) const
Definition quantities.hpp:5042
GREM_ALWAYS_INLINE Length< N > GREM_VECTORCALL operator()(Length< N > b) const
Definition quantities.hpp:5026
GREM_ALWAYS_INLINE constexpr LocalTransformation() noexcept=default
GREM_ALWAYS_INLINE Quantity< N, UnitT > GREM_VECTORCALL getRelative(Quantity< N, UnitT > localQuantity) const
Definition quantities.hpp:5047
GREM_ALWAYS_INLINE constexpr bool operator==(const LocalTransformation &) const noexcept=default
Affine transformation in world space.
Definition quantities.hpp:5104
GREM_ALWAYS_INLINE constexpr bool operator==(const Transformation &) const noexcept=default
GREM_ALWAYS_INLINE Direction< N > GREM_VECTORCALL getDirection(Direction< N > direction) const
Definition quantities.hpp:5175
GREM_ALWAYS_INLINE constexpr Transformation() noexcept=default
GREM_ALWAYS_INLINE Position< N > GREM_VECTORCALL operator()(Length< N > b) const
Definition quantities.hpp:5150
GREM_ALWAYS_INLINE Basis< N > GREM_VECTORCALL getBasis() const
Definition quantities.hpp:5158
GREM_ALWAYS_INLINE constexpr Transformation(Position< N > origin, const LocalTransformation< N > &localTransformation)
Definition quantities.hpp:5116
GREM_ALWAYS_INLINE Position< N > GREM_VECTORCALL getOrigin() const
Definition quantities.hpp:5154
GREM_ALWAYS_INLINE Distance GREM_VECTORCALL getDistance(Length< N > localOffset) const
Definition quantities.hpp:5162
GREM_ALWAYS_INLINE constexpr Transformation(Zero, Basis< N > basis)
Definition quantities.hpp:5112
GREM_ALWAYS_INLINE constexpr Transformation(Zero, const LocalTransformation< N > &localTransformation)
Definition quantities.hpp:5120
GREM_ALWAYS_INLINE Distance GREM_VECTORCALL getDistance2(Length< N > localOffset) const
Definition quantities.hpp:5166
GREM_ALWAYS_INLINE Quantity< N, UnitT > GREM_VECTORCALL getRelative(Quantity< N, UnitT > localQuantity) const
Definition quantities.hpp:5171
Definition concepts.hpp:85
Concept that checks if a type is a valid physical dimension type.
Definition quantities.hpp:40
Concept that checks if a type is a valid physical magnitude type.
Definition quantities.hpp:311
Concept that checks if a type is a valid physical unit type.
Definition quantities.hpp:515
Definition concepts.hpp:35
@ N
'n'
Definition keyboard.hpp:84
@ T
't'
Definition keyboard.hpp:90
Definition aliases.hpp:15
Definition quantities.hpp:6134
Definition Broadphase.hpp:24
AngularVelocityTensor< 2 > AngularVelocityTensor2D
Tensor of angular velocity quantities in 2-dimensional space. Unit: Radians per second.
Definition quantities.hpp:5966
Rate< 3 > Rate3D
Frequency in 3-dimensional space. Unit: Hertz (AKA per second).
Definition quantities.hpp:5566
GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL notEqual(A a, B b)
Definition quantities.hpp:3561
GREM_ALWAYS_INLINE LocalTransformation< N > GREM_VECTORCALL translateRotate(Length< N > localOffset, Orientation< N > localOrientation)
Definition quantities.hpp:5076
Length1D Distance
Scalar length quantity.
Definition quantities.hpp:4962
canonical_unit_t< BaseSqrt< UnitT > > Sqrt
The canonical unit type resulting from taking the square root of a quantity of the given unit.
Definition quantities.hpp:1040
BaseUnit<(UnitT1::DIMENSION+...+UnitTs::DIMENSION),(UnitT1::MAGNITUDE+...+UnitTs::MAGNITUDE)> BaseSum
The base unit type resulting from adding a set of quantities of the given units.
Definition quantities.hpp:830
canonical_unit_t< BaseKilo< UnitT > > Kilo
The canonical unit type corresponding to a given unit with its magnitude scaled by 1000.
Definition quantities.hpp:1165
GREM_ALWAYS_INLINE constexpr auto rotate90DegreesClockwise(A a)
Definition quantities.hpp:4232
constexpr Dimension ANGULAR_ABSEMENT
T.
Definition quantities.hpp:203
consteval auto operator*(const UnitT1 &a, const UnitlessT2 &b)
Get the unit resulting from multiplying a unit by a dimensionless unit with a magnitude of 1.
Definition quantities.hpp:759
LinearAccelerationTensor< 3 > LinearAccelerationTensor3D
Tensor of linear acceleration quantities in 3-dimensional space. Unit: Meters per second squared.
Definition quantities.hpp:5683
GREM_ALWAYS_INLINE auto GREM_VECTORCALL abs(A a)
Definition quantities.hpp:3217
AngularImpulse< 2 > AngularImpulse2D
Angular impulse in 2-dimensional space. Unit: Newton meter seconds.
Definition quantities.hpp:6030
Force< 1 > Force1D
Force in 1-dimensional space. Unit: Newton (AKA kilogram meters per second squared).
Definition quantities.hpp:5694
GREM_ALWAYS_INLINE Direction3D getAxis(Orientation3D orientation)
Definition quantities.hpp:4785
AbsoluteAngles< 3 > PitchYawRoll
Absolute angles in 3-dimensional space.
Definition quantities.hpp:4062
GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL distance2(A a, B b)
Definition quantities.hpp:3316
ForceTensor< 2 > ForceTensor2D
Tensor of force quantities in 2-dimensional space. Unit: Newton (AKA kilogram meters per second squar...
Definition quantities.hpp:5707
LocalTransformation< 2 > LocalTransformation2D
Affine transformation in 2-dimensional local space.
Definition quantities.hpp:5059
AngularQuantity< N, NewtonMeters > Torque
Torque quantity.
Definition quantities.hpp:5718
Direction< 2 > Direction2D
Normalized unit vector in 2-dimensional space. Unitless.
Definition quantities.hpp:4151
GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL minComponent(A a)
Definition quantities.hpp:3082
GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL lessThan(A a, B b)
Definition quantities.hpp:3595
InverseLocalTransformation< 2 > InverseLocalTransformation2D
Inverse of an affine transformation in 2-dimensional local space.
Definition quantities.hpp:5303
GREM_ALWAYS_INLINE constexpr Quantity< N, UnitT > &GREM_VECTORCALL operator+=(Quantity< N, UnitT > &a, detail::quantity_convertible auto b)
Definition quantities.hpp:2897
Force< 2 > Force2D
Force in 2-dimensional space. Unit: Newton (AKA kilogram meters per second squared).
Definition quantities.hpp:5695
BaseUnit< D, Magnitude< 1.0l >{}> BaseSIUnit
The base relative SI unit type for a given dimension.
Definition quantities.hpp:1283
Quantity< N, MetersPerSecondSquared > LinearAcceleration
Linear acceleration quantity.
Definition quantities.hpp:5660
AngularImpulse< 3 > AngularImpulse3D
Angular impulse in 3-dimensional space. Unit: Newton meter seconds.
Definition quantities.hpp:6031
LinearVelocityTensor< 2 > LinearVelocityTensor2D
Tensor of linear velocity quantities in 2-dimensional space. Unit: Meters per second.
Definition quantities.hpp:5642
GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL length(A a)
Definition quantities.hpp:3302
GREM_ALWAYS_INLINE constexpr Quantity< N, UnitT > &GREM_VECTORCALL operator/=(Quantity< N, UnitT > &a, detail::quantity_convertible auto b)
Definition quantities.hpp:2977
GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL cross(A a, B b)
Definition quantities.hpp:3239
Quantity< 1, MetersPerNewton > Compliance
Compliance quantity.
Definition quantities.hpp:6132
canonical_unit_t< BaseReciprocal< UnitT > > Reciprocal
The canonical unit type resulting from taking the multiplicative inverse of a quantity of the given u...
Definition quantities.hpp:1072
TorqueTensor< 3 > TorqueTensor3D
Tensor of torque quantities in 3-dimensional space. Unit: Newton meters (AKA kilogram square meters p...
Definition quantities.hpp:5732
AbsoluteAngles< 2 > Roll
Absolute angle in 2-dimensional space.
Definition quantities.hpp:4048
GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL lessThanEqual(A a, B b)
Definition quantities.hpp:3629
SquaredLength SquaredDistance
Scalar squared length quantity.
Definition quantities.hpp:4976
AngularSpeed RollRate
Time derivative of roll.
Definition quantities.hpp:5981
constexpr Dimension ENERGY
M L^2 T^-2.
Definition quantities.hpp:216
AngularVelocity< 2 > AngularVelocity2D
Angular velocity in 2-dimensional space. Unit: Radians per second.
Definition quantities.hpp:5947
AngularFrequency< 3 > AngularFrequency3D
Angular frequency in 3-dimensional space. Unit: Hertz (AKA per second).
Definition quantities.hpp:5588
GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL unlerp(A value, B minValue, C maxValue)
Definition quantities.hpp:3414
BaseProduct< UnitT, UnitT, UnitT > BaseCubic
The base unit type resulting from taking the cube of a quantity of the given unit.
Definition quantities.hpp:1124
GREM_ALWAYS_INLINE InverseLocalTransformation< N > GREM_VECTORCALL inverseTranslate(Length< N > localOffset)
Definition quantities.hpp:5339
constexpr SIUnit< D > SI_UNIT
The canonical relative SI unit for a given dimension.
Definition quantities.hpp:1299
constexpr Direction2D Y_AXIS_2D
The Y axis in 2-dimensional space.
Definition quantities.hpp:4902
constexpr Dimension ANGULAR_VELOCITY
T^-1.
Definition quantities.hpp:204
GREM_ALWAYS_INLINE AbsoluteAngle getPitch(Orientation3D orientation)
Definition quantities.hpp:4789
Quantity< 1, RadiansPerSecond > AngularSpeed
Scalar angular speed quantity.
Definition quantities.hpp:5955
Quantity< 1, Absolute< Radians > > AbsoluteAngle
Absolute angle in world space.
Definition quantities.hpp:4031
GREM_ALWAYS_INLINE OrthonormalBasis2D rotate(RollRotation r)
Definition quantities.hpp:4723
InverseLocalTransformation< 3 > InverseLocalTransformation3D
Inverse of an affine transformation in 3-dimensional local space.
Definition quantities.hpp:5304
Quantity< 1, SquareMeters > Area
Scalar area quantity.
Definition quantities.hpp:5525
constexpr Direction3D Z_AXIS_3D
The Z axis in 3-dimensional space.
Definition quantities.hpp:4914
LinearVelocityTensor< 3 > LinearVelocityTensor3D
Tensor of linear velocity quantities in 3-dimensional space. Unit: Meters per second.
Definition quantities.hpp:5643
GREM_ALWAYS_INLINE auto GREM_VECTORCALL signbit(A a)
Definition quantities.hpp:3150
AngularQuantity< N, NewtonMeterSeconds > AngularImpulse
Angular impulse quantity.
Definition quantities.hpp:6029
AngularAbsement< 2 > AngularAbsement2D
Angular absement in 2-dimensional space. Unit: Radian seconds.
Definition quantities.hpp:5935
MomentOfInertiaTensor< 3 > MomentOfInertiaTensor3D
Tensor of moment of inertia quantities in 3-dimensional space. Unit: Kilogram square meters.
Definition quantities.hpp:5826
GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL cos(A a)
Definition quantities.hpp:3340
Angle getAngleDifferenceAroundAxis(Direction3D axis, Quantity< 3, UnitT > a, Quantity< 3, UnitT > b)
Get the smallest signed angle around an axis between two relative vectors.
Definition quantities.hpp:4852
Quantity< 2, RadiansPerSecond > PitchYawRates
Time derivatives of pitch and yaw.
Definition quantities.hpp:5988
Quantity< 3, Radians > PitchYawRollRotations
Relative rotations of pitch, yaw and roll.
Definition quantities.hpp:4083
LinearVelocity< 1 > LinearVelocity1D
Linear velocity in 1-dimensional space. Unit: Meters per second.
Definition quantities.hpp:5619
std::conditional_t< N==3, TensorQuantity< 3, UnitT >, Quantity< 1, UnitT > > AngularTensorQuantity
Definition quantities.hpp:3857
GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL tryDivide(A a, B b)
Definition quantities.hpp:3383
GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL inversesqrt(A a)
Definition quantities.hpp:3287
GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL midpoint(A a, B b)
Definition quantities.hpp:3497
InverseTransformation< 3 > InverseTransformation3D
Inverse of an affine transformation in 3-dimensional space.
Definition quantities.hpp:5435
typename canonical_unit< UnitT >::type canonical_unit_t
Canonical unit type of a given unit.
Definition quantities.hpp:536
Quantity< 1, PerMeter > Wavenumber
Scalar wavenumber quantity.
Definition quantities.hpp:5608
consteval auto kilo(UnitT a)
Get the canonical unit corresponding to a given unit with its magnitude scaled by 1000.
Definition quantities.hpp:1176
GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL clamp(Quantity< N1, UnitT1 > a, Quantity< N2, UnitT2 > b, Quantity< N3, UnitT3 > c)
Definition quantities.hpp:3020
AngularFrequency< 2 > AngularFrequency2D
Angular frequency in 2-dimensional space. Unit: Hertz (AKA per second).
Definition quantities.hpp:5587
GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL min(Quantity< N1, UnitT1 > a, Quantity< N2, UnitT2 > b)
Definition quantities.hpp:2982
constexpr Dimension WORK
M L^2 T^-2.
Definition quantities.hpp:214
ForceTensor< 3 > ForceTensor3D
Tensor of force quantities in 3-dimensional space. Unit: Newton (AKA kilogram meters per second squar...
Definition quantities.hpp:5708
LinearAbsement< 2 > LinearAbsement2D
Linear absement in 2-dimensional space. Unit: Meter seconds.
Definition quantities.hpp:5600
InverseTransformation< 2 > InverseTransformation2D
Inverse of an affine transformation in 2-dimensional space.
Definition quantities.hpp:5434
consteval auto cubic(UnitT a)
Get the canonical unit resulting from taking the cube of a quantity of a given unit.
Definition quantities.hpp:1144
decltype(auto) getNormalComponent(Quantity< N, UnitT > &v)
Definition quantities.hpp:3950
float Scalar
Underlying scalar type of physics quantity components.
Definition quantities.hpp:1480
LinearImpulse< 2 > LinearImpulse2D
Linear impulse in 2-dimensional space. Unit: Newton seconds (AKA kilogram meters per second).
Definition quantities.hpp:5744
consteval auto operator+(const UnitT &a)
Get the unit resulting from taking the additive identity of a quantity of a unit.
Definition quantities.hpp:688
constexpr Dimension MOMENTUM
M L T^-1.
Definition quantities.hpp:201
std::conditional_t< N==3, Mask< N >, Mask< 1 > > AngularMask
Angular boolean quantity.
Definition quantities.hpp:2805
GREM_ALWAYS_INLINE constexpr auto inverseTranspose(const TensorQuantity< N, UnitT > &a)
Definition quantities.hpp:3875
constexpr Dimension ABSEMENT
L T.
Definition quantities.hpp:194
Quantity< 1, Square< CubicMeters > > SquaredVolume
Scalar squared volume quantity.
Definition quantities.hpp:5546
constexpr Dimension< 0, 0, 0 > DIMENSIONLESS
Identity dimension.
Definition quantities.hpp:185
OrthonormalBasis< 3 > OrthonormalBasis3D
Basis in 3-dimensional space whose columns are all unit vectors that are orthogonal to each other....
Definition quantities.hpp:4408
Quantity< N, NewtonSeconds > LinearImpulse
Linear impulse quantity.
Definition quantities.hpp:5742
constexpr OrthonormalBasis2D BASIS_2D
Identity basis in 2-dimensional space.
Definition quantities.hpp:4874
GREM_ALWAYS_INLINE constexpr auto flipY(A a)
Definition quantities.hpp:4258
GREM_ALWAYS_INLINE auto GREM_VECTORCALL fmod(A a, B b)
Definition quantities.hpp:3201
GREM_ALWAYS_INLINE LocalTransformation< N > GREM_VECTORCALL translateRotateScale(Length< N > localOffset, Orientation< N > localOrientation, Scale< N > localScale)
Definition quantities.hpp:5063
AngularVelocityTensor< 3 > AngularVelocityTensor3D
Tensor of angular velocity quantities in 3-dimensional space. Unit: Radians per second.
Definition quantities.hpp:5967
Mask< 3 > Mask3D
Boolean quantity in 3-dimensional space. Unitless.
Definition quantities.hpp:2795
LocalInertiaOrientation< 2 > LocalInertiaOrientation2D
Local inertia orientation of an object in 2-dimensional space. Unit: Radians.
Definition quantities.hpp:5885
GREM_ALWAYS_INLINE PitchYawRoll getPitchYawRoll(Orientation3D orientation)
Definition quantities.hpp:4805
Quantity< N, MeterSeconds > LinearAbsement
Linear absement quantity.
Definition quantities.hpp:5598
canonical_unit_t< BaseDifference< UnitT1, UnitT2 > > Difference
The canonical unit type resulting from subtracting two quantities of the given units.
Definition quantities.hpp:860
canonical_unit_t< BaseCenti< UnitT > > Centi
The canonical unit type corresponding to a given unit with its magnitude scaled by 1/100.
Definition quantities.hpp:1229
AngularQuantity< N, PerKilogramSquareMeter > InverseMomentOfInertia
Inverse moment of inertia quantity.
Definition quantities.hpp:5836
constexpr Dimension< 0, 1, 0 > LENGTH
L.
Definition quantities.hpp:187
constexpr Dimension INTEGRATED_ROTATIONAL_MOMENTUM
M L^2.
Definition quantities.hpp:211
Quantity< 1, KilogramsPerSecond > MassFlowRate
Scalar mass flow rate quantity.
Definition quantities.hpp:6090
constexpr Dimension MOMENT_OF_INERTIA
M L^2.
Definition quantities.hpp:202
Direction< 3 > Direction3D
Normalized unit vector in 3-dimensional space. Unitless.
Definition quantities.hpp:4152
Orientation< 2 > Orientation2D
Absolute orientation in 2-dimensional space. Unit: Radians.
Definition quantities.hpp:4592
GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL flipSignIf(A a, bool b)
Definition quantities.hpp:4155
OrthonormalBasis< 2 > OrthonormalBasis2D
Basis in 2-dimensional space whose columns are all unit vectors that are orthogonal to each other....
Definition quantities.hpp:4407
GREM_ALWAYS_INLINE auto GREM_VECTORCALL pow(A a, B b)
Definition quantities.hpp:3193
AngularQuantity< N, Unitless > AngularScale
Angular dimensionless scale.
Definition quantities.hpp:4010
AngularMask< 2 > AngularMask2D
Angular boolean quantity in 2-dimensional space. Unitless.
Definition quantities.hpp:2806
constexpr Dimension TORQUE
M L^2 T^-2.
Definition quantities.hpp:199
Position< 1 > Position1D
Absolute position in 1-dimensional space. Unit: Meters.
Definition quantities.hpp:4950
constexpr Dimension DENSITY
M L^-3.
Definition quantities.hpp:192
Orientation< 3 > Orientation3D
Absolute orientation in 3-dimensional space. Unit: Radians.
Definition quantities.hpp:4593
GREM_ALWAYS_INLINE constexpr auto transpose(const TensorQuantity< N, UnitT > &a)
Definition quantities.hpp:3870
AngularImpulseTensor< 3 > AngularImpulseTensor3D
Tensor of angular impulse quantities in 3-dimensional space. Unit: Newton meter seconds (AKA kilogram...
Definition quantities.hpp:6044
GREM_ALWAYS_INLINE constexpr auto inverse(Quantity< N, UnitT > a)
Definition quantities.hpp:3860
Basis< 3 > Basis3D
Basis matrix in 3-dimensional space. Unitless.
Definition quantities.hpp:4000
canonical_unit_t< BaseRelative< UnitT > > Relative
The canonical unit type corresponding to a given unit with its magnitude made relative.
Definition quantities.hpp:953
GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL distance(A a, B b)
Definition quantities.hpp:3309
InverseMomentOfInertiaTensor< 2 > InverseMomentOfInertiaTensor2D
Tensor of inverse moment of inertia quantities in 2-dimensional space. Unit: Per kilogram square mete...
Definition quantities.hpp:5849
consteval auto absolute(UnitT a)
Get the canonical unit corresponding to a given unit with its magnitude made absolute.
Definition quantities.hpp:1019
AngularQuantity< N, RadiansPerSecondSquared > AngularAcceleration
Angular acceleration quantity.
Definition quantities.hpp:6005
BaseUnit< sqrt(UnitT::DIMENSION), sqrt(UnitT::MAGNITUDE)> BaseSqrt
The base unit type resulting from taking the square root of a quantity of the given unit.
Definition quantities.hpp:1031
constexpr Dimension POWER
M L^2 T^-3.
Definition quantities.hpp:215
GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL acos(A a)
Definition quantities.hpp:3361
GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL greaterThanEqual(A a, B b)
Definition quantities.hpp:3697
typename in_base_units< UnitT >::type in_base_units_t
Corresponding instantiation of the BaseUnit type template of a given unit type.
Definition quantities.hpp:820
GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL asin(A a)
Definition quantities.hpp:3366
LengthTensor< 2 > LengthTensor2D
Tensor of length quantities in 2-dimensional space. Unit: Meters.
Definition quantities.hpp:4938
canonical_unit_t< BaseDeci< UnitT > > Deci
The canonical unit type corresponding to a given unit with its magnitude scaled by 1/10.
Definition quantities.hpp:1197
canonical_unit_t< BaseMilli< UnitT > > Milli
The canonical unit type corresponding to a given unit with its magnitude scaled by 1/1000.
Definition quantities.hpp:1261
constexpr ComponentSwizzle< 0 > X
Tag specifying the X component at index 0 of a vector.
Definition quantities.hpp:1492
GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL expDecay(A value, B targetValue, Frequency decayRate, Duration deltaTime)
Definition quantities.hpp:3477
Quantity< 1, Watts > Power
Scalar mechanical power quantity.
Definition quantities.hpp:6111
GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL clampLength(A value, B maxLength)
Definition quantities.hpp:3731
Quantity< 1, CubicMeters > Volume
Scalar volume quantity.
Definition quantities.hpp:5539
Quantity< 1, Seconds > Time
Scalar relative time duration quantity.
Definition quantities.hpp:5518
GREM_ALWAYS_INLINE Orientation3D GREM_VECTORCALL slerp(Orientation3D a, Orientation3D b, Coefficient alpha)
Definition quantities.hpp:4683
Quantity< 1, Joules > Work
Scalar mechanical work quantity.
Definition quantities.hpp:6104
LinearAcceleration< 2 > LinearAcceleration2D
Linear acceleration in 2-dimensional space. Unit: Meters per second squared.
Definition quantities.hpp:5662
TensorQuantity< N, MetersPerSecondSquared > LinearAccelerationTensor
Tensor of linear acceleration quantities.
Definition quantities.hpp:5681
Quantity< 1, PerKilogram > InverseMass
Scalar inverse mass quantity.
Definition quantities.hpp:5511
Quantity< 2, Absolute< Radians > > PitchYaw
Absolute angles in 3-dimensional space without roll.
Definition quantities.hpp:4055
GREM_ALWAYS_INLINE LocalTransformation< N > GREM_VECTORCALL translate(Length< N > localOffset)
Definition quantities.hpp:5094
TensorQuantity< N, NewtonSeconds > LinearImpulseTensor
Tensor of linear impulse quantities.
Definition quantities.hpp:5765
Force< 3 > Force3D
Force in 3-dimensional space. Unit: Newton (AKA kilogram meters per second squared).
Definition quantities.hpp:5696
constexpr Direction3D Y_AXIS_3D
The Y axis in 3-dimensional space.
Definition quantities.hpp:4903
constexpr Direction< N > Z_AXIS
The Z axis in the space with the given number of dimensions.
Definition quantities.hpp:4911
Scale< 3 > Scale3D
Dimensionless scale in 3-dimensional space. Unitless.
Definition quantities.hpp:3987
Quantity< 1, Square< SquareMeters > > SquaredArea
Scalar squared area quantity.
Definition quantities.hpp:5532
GREM_ALWAYS_INLINE auto GREM_VECTORCALL isfinite(A a)
Definition quantities.hpp:3124
GREM_ALWAYS_INLINE constexpr auto rotate90DegreesCounterclockwise(A a)
Definition quantities.hpp:4219
Basis< 2 > Basis2D
Basis matrix in 2-dimensional space. Unitless.
Definition quantities.hpp:3999
TensorQuantity< N, Unitless > Basis
Basis matrix.
Definition quantities.hpp:3998
Length< 1 > Length1D
Relative distance/length offset in 1-dimensional space. Unit: Meters.
Definition quantities.hpp:4925
GREM_ALWAYS_INLINE auto GREM_VECTORCALL exp2(A a)
Definition quantities.hpp:3186
GREM_ALWAYS_INLINE auto GREM_VECTORCALL exp(A a)
Definition quantities.hpp:3179
LinearMomentum< 2 > LinearMomentum2D
Linear momentum in 2-dimensional space. Unit: Kilogram meters per second.
Definition quantities.hpp:5779
AngularTensorQuantity< N, KilogramSquareMetersPerSecond > AngularMomentumTensor
Tensor of angular momentum quantities.
Definition quantities.hpp:6067
AngularMomentumTensor< 2 > AngularMomentumTensor2D
Tensor of angular momentum quantities in 2-dimensional space. Unit: Kilogram square meters per second...
Definition quantities.hpp:6068
Mask< 2 > Mask2D
Boolean quantity in 2-dimensional space. Unitless.
Definition quantities.hpp:2794
InverseMomentOfInertiaTensor< 3 > InverseMomentOfInertiaTensor3D
Tensor of inverse moment of inertia quantities in 3-dimensional space. Unit: Per kilogram square mete...
Definition quantities.hpp:5850
constexpr Dimension< 1, 0, 0 > MASS
M.
Definition quantities.hpp:186
AngularMomentum< 2 > AngularMomentum2D
Angular momentum in 2-dimensional space. Unit: kilogram square meters per second.
Definition quantities.hpp:6056
Quantity< 1, Joules > Energy
Scalar energy quantity.
Definition quantities.hpp:6118
GREM_ALWAYS_INLINE constexpr auto tryDecomposeMagnitudeDirection(A a)
Definition quantities.hpp:4299
Quantity< 1, NewtonPerMeter > Stiffness
Stiffness quantity.
Definition quantities.hpp:6125
constexpr Dimension ANGULAR_MOMENTUM
M L^2 T^-1.
Definition quantities.hpp:207
canonical_unit_t< BaseSIUnit< D > > SIUnit
The canonical relative SI unit type for a given dimension.
Definition quantities.hpp:1291
BaseMultipleOf< UnitT, 0.01l > BaseCenti
The base unit type corresponding to a given unit with its magnitude scaled by 1/100.
Definition quantities.hpp:1220
GREM_ALWAYS_INLINE auto GREM_VECTORCALL isnan(A a)
Definition quantities.hpp:3134
Quantity< 1, NewtonMeterSecondsPerRadian > AngularViscousDamping
Scalar angular viscous damping quantity.
Definition quantities.hpp:6083
Rate< 1 > Rate1D
Frequency in 1-dimensional space. Unit: Hertz (AKA per second).
Definition quantities.hpp:5564
LinearImpulseTensor< 2 > LinearImpulseTensor2D
Tensor of linear impulse quantities in 2-dimensional space. Unit: Newton seconds (AKA kilogram meters...
Definition quantities.hpp:5766
LinearMomentumTensor< 3 > LinearMomentumTensor3D
Tensor of linear momentum quantities in 3-dimensional space. Unit: Kilogram meters per second.
Definition quantities.hpp:5802
constexpr Direction< N > Y_AXIS
The Y axis in the space with the given number of dimensions.
Definition quantities.hpp:4897
GREM_ALWAYS_INLINE Direction2D convertAnglesToForwardDirection(Roll angles)
Definition quantities.hpp:4809
LinearImpulseTensor< 3 > LinearImpulseTensor3D
Tensor of linear impulse quantities in 3-dimensional space. Unit: Newton seconds (AKA kilogram meters...
Definition quantities.hpp:5767
AngularAcceleration< 3 > AngularAcceleration3D
Angular acceleration in 3-dimensional space. Unit: Radians per second squared.
Definition quantities.hpp:6007
GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL select(auto condition, A ifTrue, B ifFalse)
Definition quantities.hpp:3437
BaseUnit<(UnitT1::DIMENSION *... *UnitTs::DIMENSION),(UnitT1::MAGNITUDE *... *UnitTs::MAGNITUDE)> BaseProduct
The base unit type resulting from multiplying a set of quantities of the given units.
Definition quantities.hpp:870
AngularAcceleration< 2 > AngularAcceleration2D
Angular acceleration in 2-dimensional space. Unit: Radians per second squared.
Definition quantities.hpp:6006
LinearMomentum1D Momentum
Scalar linear momentum quantity.
Definition quantities.hpp:5790
GREM_ALWAYS_INLINE AbsoluteAngle getYaw(Orientation3D orientation)
Definition quantities.hpp:4793
GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL step(A edge, B value)
Definition quantities.hpp:3428
constexpr Dimension INTEGRATED_POSITIONAL_MOMENTUM
M L.
Definition quantities.hpp:209
MomentOfInertiaTensor< 2 > MomentOfInertiaTensor2D
Tensor of moment of inertia quantities in 2-dimensional space. Unit: Kilogram square meters.
Definition quantities.hpp:5825
constexpr Direction3D X_AXIS_3D
The X axis in 3-dimensional space.
Definition quantities.hpp:4889
AngularVelocity< 3 > AngularVelocity3D
Angular velocity in 3-dimensional space. Unit: Radians per second.
Definition quantities.hpp:5948
consteval auto operator-(const UnitT &a)
Get the unit resulting from taking the additive inverse of a quantity of a unit.
Definition quantities.hpp:705
GREM_ALWAYS_INLINE auto GREM_VECTORCALL wrap(A a, B b)
Definition quantities.hpp:3209
AngularTensorQuantity< N, NewtonMeterSeconds > AngularImpulseTensor
Tensor of angular impulse quantities.
Definition quantities.hpp:6041
GREM_ALWAYS_INLINE Basis< N > scale(Quantity< N, UnitT > s)
Definition quantities.hpp:4708
GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL lerp(A a, B b, C alpha)
Definition quantities.hpp:3404
constexpr Dimension AREA
L^2.
Definition quantities.hpp:190
GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL reflect(A a, B normal)
Definition quantities.hpp:3395
GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL greaterThan(A a, B b)
Definition quantities.hpp:3663
GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL product(A a)
Definition quantities.hpp:3054
LinearImpulse1D Impulse
Scalar linear impulse quantity.
Definition quantities.hpp:5755
GREM_ALWAYS_INLINE AbsoluteAngle getRoll(Orientation2D orientation)
Definition quantities.hpp:4797
GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL round(A a)
Definition quantities.hpp:3506
LinearAcceleration1D Acceleration
Linear acceleration quantity. Unit: Meters per second squared.
Definition quantities.hpp:5664
constexpr Dimension INTEGRATED_POSITIONAL_IMPULSE
M L.
Definition quantities.hpp:208
TensorQuantity< N, Newton > ForceTensor
Tensor of force quantities.
Definition quantities.hpp:5706
constexpr Dimension ANGULAR_IMPULSE
M L^2 T^-1.
Definition quantities.hpp:206
BaseUnit< UnitT::DIMENSION, Magnitude< UnitT::MagnitudeType::VALUE, false >{}> BaseRelative
The base unit type corresponding to a given unit with its magnitude made relative.
Definition quantities.hpp:944
GREM_ALWAYS_INLINE constexpr Quantity< N, UnitT > &GREM_VECTORCALL operator-=(Quantity< N, UnitT > &a, detail::quantity_convertible auto b)
Definition quantities.hpp:2921
MomentOfInertia< 3 > MomentOfInertia3D
Moment of inertia in 3-dimensional space. Unit: Kilogram square meters.
Definition quantities.hpp:5814
GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL ceil(A a)
Definition quantities.hpp:3520
GREM_ALWAYS_INLINE InverseLocalTransformation< N > GREM_VECTORCALL inverseTranslateRotateScale(Length< N > localOffset, Orientation< N > localOrientation, Scale< N > localScale)
Definition quantities.hpp:5307
consteval auto per(UnitT a)
Get the canonical unit resulting from taking the multiplicative inverse of a quantity of a given unit...
Definition quantities.hpp:1083
GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL tan(A a)
Definition quantities.hpp:3354
constexpr Direction< N > X_AXIS
The X axis in the space with the given number of dimensions.
Definition quantities.hpp:4883
LinearAbsement< 3 > LinearAbsement3D
Linear absement in 3-dimensional space. Unit: Meter seconds.
Definition quantities.hpp:5601
consteval auto deci(UnitT a)
Get the canonical unit corresponding to a given unit with its magnitude scaled by 1/10.
Definition quantities.hpp:1208
constexpr Quantity< 1, UnitT > Quantity< 1, UnitT >::MACHINE_EPSILON
Definition quantities.hpp:1702
GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL floor(A a)
Definition quantities.hpp:3513
GREM_ALWAYS_INLINE auto GREM_VECTORCALL isinf(A a)
Definition quantities.hpp:3129
consteval auto multipleOf(UnitT a)
Get the canonical unit corresponding to a given unit with its magnitude scaled by a given multiplier.
Definition quantities.hpp:932
constexpr Dimension WAVENUMBER
L^-1.
Definition quantities.hpp:195
Quantity< 1, Kilograms > Mass
Scalar mass quantity.
Definition quantities.hpp:5504
canonical_unit_t< BaseMultipleOf< UnitT, Multiple > > MultipleOf
The canonical unit type corresponding to a given unit with its magnitude scaled by a given multiplier...
Definition quantities.hpp:919
AngularAccelerationTensor< 2 > AngularAccelerationTensor2D
Tensor of angular acceleration quantities in 2-dimensional space. Unit: Radians per second squared.
Definition quantities.hpp:6018
GREM_ALWAYS_INLINE constexpr auto tryDecomposeMagnitudeAngle(A a)
Definition quantities.hpp:4321
MomentArmTensor< 3 > MomentArmTensor3D
Tensor of moment arm quantities in 3-dimensional space. Unit: Meters.
Definition quantities.hpp:5924
consteval auto square(UnitT a)
Get the canonical unit resulting from squaring a quantity of a given unit.
Definition quantities.hpp:1112
GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL sin(A a)
Definition quantities.hpp:3347
LinearVelocity1D Speed
Scalar linear velocity quantity.
Definition quantities.hpp:5631
Scale1D Coefficient
Unitless scalar quantity.
Definition quantities.hpp:3988
AngularTensorQuantity< N, PerKilogramSquareMeter > InverseMomentOfInertiaTensor
Tensor of inverse moment of inertia quantities.
Definition quantities.hpp:5848
GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL moveTowards(A value, B targetValue, C amount)
Definition quantities.hpp:3463
constexpr Dimension FORCE
M L T^-2.
Definition quantities.hpp:198
GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL normalize(A a)
Definition quantities.hpp:4187
constexpr Dimension< 0, 0, 1 > TIME
T.
Definition quantities.hpp:188
GREM_ALWAYS_INLINE auto GREM_VECTORCALL copysign(A a, B b)
Definition quantities.hpp:4175
LinearMomentum< 3 > LinearMomentum3D
Linear momentum in 3-dimensional space. Unit: Kilogram meters per second.
Definition quantities.hpp:5780
GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL length2(A a)
Definition quantities.hpp:3295
AngularQuantity< N, Absolute< Radians > > AbsoluteAngles
Absolute angles in world space.
Definition quantities.hpp:4041
GREM_ALWAYS_INLINE constexpr auto decomposeMagnitudeAngle(A a)
Definition quantities.hpp:4316
BaseMultipleOf< UnitT, 1000.0l > BaseKilo
The base unit type corresponding to a given unit with its magnitude scaled by 1000.
Definition quantities.hpp:1156
constexpr Dimension ANGULAR_ACCELERATION
T^-2.
Definition quantities.hpp:205
LinearVelocity< 2 > LinearVelocity2D
Linear velocity in 2-dimensional space. Unit: Meters per second.
Definition quantities.hpp:5620
TensorQuantity< N, Meters > LengthTensor
Tensor of length quantities.
Definition quantities.hpp:4937
consteval auto centi(UnitT a)
Get the canonical unit corresponding to a given unit with its magnitude scaled by 1/100.
Definition quantities.hpp:1240
Angle getAngleDifference(AbsoluteAngle a, AbsoluteAngle b)
Get the smallest signed angle between two absolute angles.
Definition quantities.hpp:4837
std::conditional_t< N==1, bool, vec< N, bool > > Mask
Boolean quantity.
Definition quantities.hpp:2792
Length< 3 > Length3D
Relative distance/length offset in 3-dimensional space. Unit: Meters.
Definition quantities.hpp:4927
GREM_ALWAYS_INLINE TensorQuantity< N, UnitT > rotateScale(Orientation< N > r, Quantity< N, UnitT > s)
Definition quantities.hpp:4757
Transformation< 2 > Transformation2D
Affine transformation in 2-dimensional space.
Definition quantities.hpp:5183
AngularTensorQuantity< N, RadiansPerSecondSquared > AngularAccelerationTensor
Tensor of angular acceleration quantities.
Definition quantities.hpp:6017
Quantity< N, Newton > Force
Force quantity.
Definition quantities.hpp:5693
MomentArmTensor< 2 > MomentArmTensor2D
Tensor of moment arm quantities in 2-dimensional space. Unit: Meters.
Definition quantities.hpp:5923
BaseMultipleOf< UnitT, 0.001l > BaseMilli
The base unit type corresponding to a given unit with its magnitude scaled by 1/1000.
Definition quantities.hpp:1252
Torque< 3 > Torque3D
Torque in 3-dimensional space. Unit: Newton meters (AKA kilogram square meters per second squared).
Definition quantities.hpp:5720
BaseUnit< DIMENSIONLESS/UnitT::DIMENSION, Magnitude< 1.0l/UnitT::MagnitudeType::VALUE, UnitT::MagnitudeType::IS_ABSOLUTE >{}> BaseReciprocal
The base unit type resulting from taking the multiplicative inverse of a quantity of the given unit.
Definition quantities.hpp:1063
MomentArm< 2 > MomentArm2D
Moment arm in 2-dimensional space. Unit: Meters.
Definition quantities.hpp:5911
constexpr Dimension ACCELERATION
L T^-2.
Definition quantities.hpp:197
AngularAbsement< 3 > AngularAbsement3D
Angular absement in 3-dimensional space. Unit: Radian seconds.
Definition quantities.hpp:5936
GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL getAngle(A a)
Definition quantities.hpp:3323
Quantity< 1, CubicMetersPerSecond > VolumetricFlowRate
Scalar volumetric flow rate quantity.
Definition quantities.hpp:6097
canonical_unit_t< BaseQuotient< UnitT1, UnitT2 > > Quotient
The canonical unit type resulting from dividing two quantities of the given units.
Definition quantities.hpp:899
Quantity< N, Meters > Length
Relative distance/length offset quantity.
Definition quantities.hpp:4924
GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL sum(A a)
Definition quantities.hpp:3025
Quantity< 1, SquareMeters > SquaredLength
Scalar squared length quantity.
Definition quantities.hpp:4969
Quantity< 2, Radians > PitchYawRotations
Relative rotations of pitch and yaw.
Definition quantities.hpp:4076
LocalInertiaOrientation< 3 > LocalInertiaOrientation3D
Local inertia orientation of an object in 3-dimensional space. Unit: Radians.
Definition quantities.hpp:5886
MomentArm< 3 > MomentArm3D
Moment arm in 3-dimensional space. Unit: Meters.
Definition quantities.hpp:5912
GREM_ALWAYS_INLINE LocalTransformation< N > GREM_VECTORCALL translateScale(Length< N > localOffset, Scale< N > localScale)
Definition quantities.hpp:5089
constexpr Dimension VELOCITY
L T^-1.
Definition quantities.hpp:196
Quantity< N, Hertz > Rate
Frequency quantity.
Definition quantities.hpp:5563
constexpr ComponentSwizzle< 2 > Z
Tag specifying the Z component at index 2 of a vector.
Definition quantities.hpp:1494
InversePrincipalMomentsOfInertia< 2 > InversePrincipalMomentsOfInertia2D
Inverse principal moments of inertia in 2-dimensional inertia major axis space. Unit: Per kilogram sq...
Definition quantities.hpp:5897
consteval auto sqrt(UnitT a)
Get the canonical unit resulting from taking the square root of a quantity of a given unit.
Definition quantities.hpp:1051
Rotation< 3 > Rotation3D
Relative rotation in 3-dimensional space. Unit: Radians.
Definition quantities.hpp:4095
Quantity< N, KilogramMetersPerSecond > LinearMomentum
Linear momentum quantity.
Definition quantities.hpp:5777
GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL sign(A a)
Definition quantities.hpp:3165
AngularQuantity< N, Radians > Rotation
Relative rotation quantity.
Definition quantities.hpp:4093
GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL dot(A a, B b)
Definition quantities.hpp:3234
AngularQuantity< N, RadiansPerSecond > AngularVelocity
Angular velocity quantity.
Definition quantities.hpp:5946
GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL tryNormalize(A a)
Definition quantities.hpp:4201
constexpr Dimension VOLUMETRIC_FLOW_RATE
L^3 T^-1.
Definition quantities.hpp:213
consteval auto relative(UnitT a)
Get the canonical unit corresponding to a given unit with its magnitude made relative.
Definition quantities.hpp:964
LinearAbsement< 1 > LinearAbsement1D
Linear absement in 1-dimensional space. Unit: Meter seconds.
Definition quantities.hpp:5599
Position< 3 > Position3D
Absolute position in 3-dimensional space. Unit: Meters.
Definition quantities.hpp:4952
GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL mix(A a, B b, C alpha)
Definition quantities.hpp:3423
TensorQuantity< N, Meters > MomentArmTensor
Tensor of moment arm quantities.
Definition quantities.hpp:5922
TensorQuantity< N, NewtonMeters > TorqueTensor
Tensor of torque quantities.
Definition quantities.hpp:5730
AngularTensorQuantity< N, RadiansPerSecond > AngularVelocityTensor
Tensor of angular velocity quantities.
Definition quantities.hpp:5965
Rate1D Frequency
Scalar frequency quantity.
Definition quantities.hpp:5576
PrincipalMomentsOfInertia< 3 > PrincipalMomentsOfInertia3D
Principal moments of inertia in 3-dimensional inertia major axis space. Unit: kilogram square meters.
Definition quantities.hpp:5862
Quantity< 1, KilogramsPerCubicMeter > Density
Scalar density quantity.
Definition quantities.hpp:5553
Quantity< N, Absolute< Meters > > Position
Absolute position in world space.
Definition quantities.hpp:4949
LinearImpulse< 1 > LinearImpulse1D
Linear impulse in 1-dimensional space. Unit: Newton seconds (AKA kilogram meters per second).
Definition quantities.hpp:5743
Quantity< N, Unitless > Scale
Dimensionless scale.
Definition quantities.hpp:3984
AngularQuantity< N, KilogramSquareMeters > MomentOfInertia
Moment of inertia quantity.
Definition quantities.hpp:5812
consteval auto operator/(const UnitT1 &a, const UnitlessT2 &b)
Get the unit resulting from dividing a unit by a dimensionless unit with a magnitude of 1.
Definition quantities.hpp:799
TorqueTensor< 2 > TorqueTensor2D
Tensor of torque quantities in 2-dimensional space. Unit: Newton meters (AKA kilogram square meters p...
Definition quantities.hpp:5731
BaseProduct< UnitT, UnitT > BaseSquare
The base unit type resulting from squaring a quantity of the given unit.
Definition quantities.hpp:1094
MomentOfInertia< 2 > MomentOfInertia2D
Moment of inertia in 2-dimensional space. Unit: Kilogram square meters.
Definition quantities.hpp:5813
InverseMomentOfInertia< 2 > InverseMomentOfInertia2D
Inverse moment of inertia in 2-dimensional space. Unit: Kilogram square meters.
Definition quantities.hpp:5837
constexpr ComponentSwizzle< 1 > Y
Tag specifying the Y component at index 1 of a vector.
Definition quantities.hpp:1493
std::conditional_t< N==3, Quantity< 3, UnitT >, Quantity< 1, UnitT > > AngularQuantity
Physical quantity type representing an angular quantity in world space, with one component in 2D and ...
Definition quantities.hpp:1515
GREM_ALWAYS_INLINE InverseLocalTransformation< N > GREM_VECTORCALL inverseTranslateRotate(Length< N > localOffset, Orientation< N > localOrientation)
Definition quantities.hpp:5321
LinearMomentum< 1 > LinearMomentum1D
Linear momentum in 1-dimensional space. Unit: Kilogram meters per second.
Definition quantities.hpp:5778
constexpr Angle PI
Pi constant.
Definition quantities.hpp:4024
Quantity< 1, NewtonSecondsPerMeter > LinearViscousDamping
Scalar linear viscous damping quantity.
Definition quantities.hpp:6076
AngularTensorQuantity< N, KilogramSquareMeters > MomentOfInertiaTensor
Tensor of moment of inertia quantities.
Definition quantities.hpp:5824
constexpr Dimension ANGLE
Definition quantities.hpp:189
PrincipalMomentsOfInertia< 2 > PrincipalMomentsOfInertia2D
Principal moments of inertia in 2-dimensional inertia major axis space. Unit: kilogram square meters.
Definition quantities.hpp:5861
constexpr OrthonormalBasis3D BASIS_3D
Identity basis in 3-dimensional space.
Definition quantities.hpp:4875
LinearVelocity< 3 > LinearVelocity3D
Linear velocity in 3-dimensional space. Unit: Meters per second.
Definition quantities.hpp:5621
AngularImpulseTensor< 2 > AngularImpulseTensor2D
Tensor of angular impulse quantities in 2-dimensional space. Unit: Newton meter seconds (AKA kilogram...
Definition quantities.hpp:6042
LinearMomentumTensor< 2 > LinearMomentumTensor2D
Tensor of linear momentum quantities in 2-dimensional space. Unit: Kilogram meters per second.
Definition quantities.hpp:5801
AngularMomentumTensor< 3 > AngularMomentumTensor3D
Tensor of angular momentum quantities in 3-dimensional space. Unit: Kilogram square meters per second...
Definition quantities.hpp:6069
GREM_ALWAYS_INLINE constexpr Quantity< N, UnitT > &GREM_VECTORCALL operator*=(Quantity< N, UnitT > &a, detail::quantity_convertible auto b)
Definition quantities.hpp:2949
GREM_ALWAYS_INLINE Roll convertForwardDirectionToAngles(Direction2D forward)
Definition quantities.hpp:4821
LinearImpulse< 3 > LinearImpulse3D
Linear impulse in 3-dimensional space. Unit: Newton seconds (AKA kilogram meters per second).
Definition quantities.hpp:5745
LengthTensor< 3 > LengthTensor3D
Tensor of length quantities in 3-dimensional space. Unit: Meters.
Definition quantities.hpp:4939
AngularAccelerationTensor< 3 > AngularAccelerationTensor3D
Tensor of angular acceleration quantities in 3-dimensional space. Unit: Radians per second squared.
Definition quantities.hpp:6019
Quantity< 1, Radians > Angle
Angle quantity.
Definition quantities.hpp:4019
Mask< 1 > Mask1D
Boolean quantity in 1-dimensional space. Unitless.
Definition quantities.hpp:2793
AngularQuantity< N, RadianSeconds > AngularAbsement
Angular absement quantity.
Definition quantities.hpp:5934
LinearAcceleration< 3 > LinearAcceleration3D
Linear acceleration in 3-dimensional space. Unit: Meters per second squared.
Definition quantities.hpp:5663
LocalTransformation< 3 > LocalTransformation3D
Affine transformation in 3-dimensional local space.
Definition quantities.hpp:5060
TensorQuantity< N, KilogramMetersPerSecond > LinearMomentumTensor
Tensor of linear momentum quantities.
Definition quantities.hpp:5800
GREM_ALWAYS_INLINE constexpr auto flipZ(A a)
Definition quantities.hpp:4272
BaseUnit<(UnitT1::DIMENSION/UnitT2::DIMENSION),(UnitT1::MAGNITUDE/UnitT2::MAGNITUDE)> BaseQuotient
The base unit type resulting from dividing two quantities of the given units.
Definition quantities.hpp:889
constexpr Direction2D X_AXIS_2D
The X axis in 2-dimensional space.
Definition quantities.hpp:4888
BaseUnit<(UnitT1::DIMENSION - UnitT2::DIMENSION),(UnitT1::MAGNITUDE - UnitT2::MAGNITUDE)> BaseDifference
The base unit type resulting from subtracting two quantities of the given units.
Definition quantities.hpp:850
auto getTangentialComponent(const Quantity< N, UnitT > &v)
Definition quantities.hpp:3968
BaseUnit< UnitT::DIMENSION, UnitT::MAGNITUDE *Magnitude< Multiple >{}> BaseMultipleOf
The base unit type corresponding to a given unit with its magnitude scaled by a given multiplier.
Definition quantities.hpp:909
consteval bool operator==(UnitT1 a, UnitT2 b)
Compare two physical units for equality.
Definition quantities.hpp:670
Quantity< N, MetersPerSecond > LinearVelocity
Linear velocity quantity.
Definition quantities.hpp:5618
GREM_ALWAYS_INLINE InverseLocalTransformation< N > GREM_VECTORCALL inverseTranslateScale(Length< N > localOffset, Scale< N > localScale)
Definition quantities.hpp:5334
InverseMomentOfInertia< 3 > InverseMomentOfInertia3D
Inverse moment of inertia in 3-dimensional space. Unit: Kilogram square meters.
Definition quantities.hpp:5838
Torque< 2 > Torque2D
Torque in 2-dimensional space. Unit: Newton meters (AKA kilogram square meters per second squared).
Definition quantities.hpp:5719
GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL atan2(A a, B b)
Definition quantities.hpp:3376
TensorQuantity< N, MetersPerSecond > LinearVelocityTensor
Tensor of linear velocity quantities.
Definition quantities.hpp:5641
Rate< 2 > Rate2D
Frequency in 2-dimensional space. Unit: Hertz (AKA per second).
Definition quantities.hpp:5565
Quantity< 3, RadiansPerSecond > PitchYawRollRates
Time derivatives of pitch, yaw and roll.
Definition quantities.hpp:5995
constexpr Dimension FREQUENCY
T^-1.
Definition quantities.hpp:193
GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL max(Quantity< N1, UnitT1 > a, Quantity< N2, UnitT2 > b)
Definition quantities.hpp:3001
GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL tryGetAngle(A a)
Definition quantities.hpp:3330
BaseUnit< UnitT::DIMENSION, Magnitude< UnitT::MagnitudeType::VALUE, true >{}> BaseAbsolute
The base unit type corresponding to a given unit with its magnitude made absolute.
Definition quantities.hpp:976
AngularQuantity< N, Hertz > AngularFrequency
Angular frequency quantity.
Definition quantities.hpp:5586
Quantity< 1, Square< MetersPerSecondSquared > > SquaredAcceleration
Scalar squared acceleration quantity.
Definition quantities.hpp:5671
LinearAccelerationTensor< 2 > LinearAccelerationTensor2D
Tensor of linear acceleration quantities in 2-dimensional space. Unit: Meters per second squared.
Definition quantities.hpp:5682
canonical_unit_t< BaseSquare< UnitT > > Square
The canonical unit type resulting from squaring a quantity of the given unit.
Definition quantities.hpp:1102
GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL maxComponent(A a)
Definition quantities.hpp:3103
Scale< 1 > Scale1D
Dimensionless scale in 1-dimensional space. Unitless.
Definition quantities.hpp:3985
AngularScale< 2 > AngularScale2D
Angular dimensionless scale in 2-dimensional space. Unitless.
Definition quantities.hpp:4011
Position< 2 > Position2D
Absolute position in 2-dimensional space. Unit: Meters.
Definition quantities.hpp:4951
constexpr Dimension VOLUME
L^3.
Definition quantities.hpp:191
constexpr Dimension MASS_FLOW_RATE
M T^-1.
Definition quantities.hpp:212
canonical_unit_t< BaseCubic< UnitT > > Cubic
The canonical unit type resulting from taking the cube of a quantity of the given unit.
Definition quantities.hpp:1133
AngularMask< 3 > AngularMask3D
Angular boolean quantity in 2-dimensional space. Unitless.
Definition quantities.hpp:2807
GREM_ALWAYS_INLINE constexpr auto flipX(A a)
Definition quantities.hpp:4245
constexpr Dimension IMPULSE
M L T^-1.
Definition quantities.hpp:200
canonical_unit_t< BaseSum< UnitT1, UnitTs... > > Sum
The canonical unit type resulting from adding a set of quantities of the given units.
Definition quantities.hpp:840
AngularQuantity< N, Reciprocal< KilogramSquareMeters > > InversePrincipalMomentsOfInertia
Inverse principal moments of inertia in inertia major axis space.
Definition quantities.hpp:5896
constexpr Dimension INTEGRATED_ROTATIONAL_IMPULSE
M L^2.
Definition quantities.hpp:210
GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL equal(A a, B b)
Definition quantities.hpp:3527
AngularMomentum< 3 > AngularMomentum3D
Angular momentum in 3-dimensional space. Unit: kilogram square meters per second.
Definition quantities.hpp:6057
consteval auto milli(UnitT a)
Get the canonical unit corresponding to a given unit with its magnitude scaled by 1/1000.
Definition quantities.hpp:1272
Scale< 2 > Scale2D
Dimensionless scale in 2-dimensional space. Unitless.
Definition quantities.hpp:3986
InversePrincipalMomentsOfInertia< 3 > InversePrincipalMomentsOfInertia3D
Inverse principal moments of inertia in 3-dimensional inertia major axis space. Unit: Per kilogram sq...
Definition quantities.hpp:5899
constexpr OrthonormalBasis< N > BASIS
Identity basis for the given number of dimensions.
Definition quantities.hpp:4862
Quantity< 1, Square< MetersPerSecond > > SquaredSpeed
Scalar squared speed quantity.
Definition quantities.hpp:5650
AngularQuantity< N, KilogramSquareMetersPerSecond > AngularMomentum
Angular momentum quantity.
Definition quantities.hpp:6055
AngularQuantity< N, KilogramSquareMeters > PrincipalMomentsOfInertia
Principal moments of inertia in inertia major axis space.
Definition quantities.hpp:5860
Quantity< 1, Square< RadiansPerSecond > > SquaredAngularSpeed
Scalar squared angular speed quantity.
Definition quantities.hpp:5974
canonical_unit_t< BaseProduct< UnitT1, UnitTs... > > Product
The canonical unit type resulting from multiplying a set of quantities of the given units.
Definition quantities.hpp:880
BaseMultipleOf< UnitT, 0.1l > BaseDeci
The base unit type corresponding to a given unit with its magnitude scaled by 1/10.
Definition quantities.hpp:1188
AngularScale< 3 > AngularScale3D
Angular dimensionless scale in 3-dimensional space. Unitless.
Definition quantities.hpp:4012
AngularQuantity< N, Meters > MomentArm
Moment arm quantity.
Definition quantities.hpp:5910
Rotation< 2 > Rotation2D
Relative rotation in 2-dimensional space. Unit: Radians.
Definition quantities.hpp:4094
GREM_ALWAYS_INLINE constexpr auto decomposeMagnitudeDirection(A a)
Definition quantities.hpp:4292
Length< 2 > Length2D
Relative distance/length offset in 2-dimensional space. Unit: Meters.
Definition quantities.hpp:4926
GREM_ALWAYS_INLINE constexpr auto GREM_VECTORCALL atan(A a)
Definition quantities.hpp:3371
Transformation< 3 > Transformation3D
Affine transformation in 3-dimensional space.
Definition quantities.hpp:5184
Angle RollRotation
Relative rotation of roll.
Definition quantities.hpp:4069
LinearAcceleration< 1 > LinearAcceleration1D
Linear acceleration in 1-dimensional space. Unit: Meters per second squared.
Definition quantities.hpp:5661
Definition aliases.hpp:20
Definition aliases.hpp:9
GREM_ALWAYS_INLINE qua< T > GREM_VECTORCALL quatLookAt(vec< 3, T > direction, vec< 3, T > up)
Definition math.hpp:3230
GREM_ALWAYS_INLINE constexpr bool GREM_VECTORCALL lessThan(T a, T b)
Definition math.hpp:1240
Clock::duration Duration
Definition Clock.hpp:25
GREM_ALWAYS_INLINE constexpr vec< N, T > GREM_VECTORCALL cos(vec< N, T > a)
Definition math.hpp:1389
constexpr tuple_element_t< Index, Pair< T1, T2 > > & get(Pair< T1, T2 > &t) noexcept
Definition Pair.hpp:202
GREM_ALWAYS_INLINE constexpr vec< N, T > GREM_VECTORCALL sin(vec< N, T > a)
Definition math.hpp:1393
GREM_ALWAYS_INLINE constexpr bool GREM_VECTORCALL lessThanEqual(T a, T b)
Definition math.hpp:1245
GREM_ALWAYS_INLINE constexpr vec< N, T > GREM_VECTORCALL asin(vec< N, T > a)
Definition math.hpp:1395
GREM_ALWAYS_INLINE constexpr T GREM_VECTORCALL flipSignIf(T value, bool flip)
Get a value with its sign flipped if a boolean is true.
Definition math.hpp:3983
GREM_ALWAYS_INLINE constexpr T GREM_VECTORCALL sqrt(T a)
Get the square root of a value.
Definition math.hpp:1114
GREM_ALWAYS_INLINE constexpr bool GREM_VECTORCALL notEqual(T a, T b)
Definition math.hpp:1235
GREM_ALWAYS_INLINE qua< T > GREM_VECTORCALL roll(T angle)
Definition math.hpp:3263
GREM_ALWAYS_INLINE constexpr vec< N, T > GREM_VECTORCALL normalize(vec< N, T > a)
Convert a vector to a unit vector of length 1 in the same direction.
Definition math.hpp:2057
GREM_ALWAYS_INLINE constexpr vec< N, T > flipY(vec< N, T > a)
Get a vector flipped along the Y axis.
Definition math.hpp:3943
vec< 4, bool > bvec4
Definition math.hpp:372
constexpr auto count(input_range auto &&range, const auto &value)
Definition algorithms.hpp:234
GREM_ALWAYS_INLINE constexpr T GREM_VECTORCALL wrap(T value, T limit) noexcept
Wrap a scalar value around a range of non-negative values.
Definition math.hpp:1218
GREM_ALWAYS_INLINE constexpr vec< N, T > GREM_VECTORCALL floor(vec< N, T > a)
Definition math.hpp:1421
GREM_ALWAYS_INLINE constexpr mat< 1, 1, T > GREM_VECTORCALL inverseTranspose(const mat< 1, 1, T > &a)
Definition math.hpp:2343
DurationBase< int64_t, Ratio< 60 *60, 1 > > Hours
Definition time.hpp:51
GREM_ALWAYS_INLINE constexpr decltype(auto) clamp(T &&value, Low &&minValue, High &&maxValue)
Clamp a value to a specific interval.
Definition fundamentals.hpp:630
GREM_ALWAYS_INLINE T GREM_VECTORCALL getPitch(qua< T > orientation)
Definition math.hpp:3190
GREM_ALWAYS_INLINE constexpr Optional< T > GREM_VECTORCALL tryDivide(T a, T b)
Try to divide a floating-point value by a scalar and produce a defined result.
Definition math.hpp:2101
GREM_ALWAYS_INLINE constexpr bool GREM_VECTORCALL greaterThan(T a, T b)
Definition math.hpp:1250
DurationBase< int64_t, Ratio< 1, 1 '000 > > Milliseconds
Definition time.hpp:54
float float32_t
Definition fundamentals.hpp:155
GREM_ALWAYS_INLINE constexpr qua< T > slerp(qua< T > a, qua< T > b, T alpha)
Perform spherical linear interpolation (slerp) between two quaternions.
Definition math.hpp:3814
GREM_ALWAYS_INLINE qua< T > GREM_VECTORCALL yaw(T angle)
Definition math.hpp:3257
GREM_ALWAYS_INLINE T copysign(T magnitude, T sign)
Get a value with the sign of a different value.
Definition math.hpp:3601
GREM_ALWAYS_INLINE qua< T > GREM_VECTORCALL pitch(T angle)
Definition math.hpp:3251
GREM_ALWAYS_INLINE constexpr mat< R, C, T > transpose(const mat< C, R, T > &a)
Definition math.hpp:2247
GREM_ALWAYS_INLINE constexpr T GREM_VECTORCALL cross(vec< 2, T > a, vec< 2, T > b)
Definition math.hpp:2426
GREM_ALWAYS_INLINE constexpr T GREM_VECTORCALL pow(T a, T b) noexcept
Calculate the result of raising a given value to a given power.
Definition math.hpp:1179
GREM_ALWAYS_INLINE constexpr vec< N, T > GREM_VECTORCALL abs(vec< N, T > a)
Definition math.hpp:1386
GREM_ALWAYS_INLINE constexpr T GREM_VECTORCALL exp(T a) noexcept
Calculate the result of Euler's number raised to a given power.
Definition math.hpp:1154
GREM_ALWAYS_INLINE constexpr T expDecay(T value, T targetValue, Frequency decayRate, Duration deltaTime)
Exponentially decay a value towards a target value over a given time.
Definition math.hpp:4118
GREM_ALWAYS_INLINE qua< T > GREM_VECTORCALL angleAxis(T angle, vec< 3, T > axis)
Definition math.hpp:3245
GREM_ALWAYS_INLINE constexpr T clampLength(T value, T maxLength)
Get a value with the same sign as a given value, but whose magnitude has been clamped to a maximum le...
Definition math.hpp:4025
GREM_ALWAYS_INLINE constexpr T GREM_VECTORCALL step(T edge, T value)
Evaluate a step function with a given edge value.
Definition math.hpp:3642
GREM_ALWAYS_INLINE constexpr vec< N, T > flipX(vec< N, T > a)
Get a vector flipped along the X axis.
Definition math.hpp:3930
GREM_ALWAYS_INLINE vec< 2, T > GREM_VECTORCALL convertAnglesToForwardDirection(T rollAngle)
Definition math.hpp:3336
GREM_ALWAYS_INLINE constexpr T GREM_VECTORCALL product(vec< 1, T > a)
Definition math.hpp:1876
std::ratio< Num, Den > Ratio
Definition time.hpp:19
String formatString(FormatString< Args... > format, const Args &... args)
Format specification syntax examples:
Definition formatting.hpp:448
constexpr auto rotate(forward_range auto &&range, auto middle)
Definition algorithms.hpp:641
GREM_ALWAYS_INLINE constexpr T GREM_VECTORCALL minComponent(vec< 1, T > a)
Definition math.hpp:1898
DurationBase< int64_t, Ratio< 60, 1 > > Minutes
Definition time.hpp:52
GREM_ALWAYS_INLINE T GREM_VECTORCALL getRoll(qua< T > orientation)
Definition math.hpp:3201
GREM_ALWAYS_INLINE vec< 1, bool > GREM_VECTORCALL isinf(const vec< 1, T > &values)
Check if each component of a vector is infinity.
Definition math.hpp:3480
vec< 3, bool > bvec3
Definition math.hpp:371
std::chrono::duration< Rep, Period > DurationBase
Definition time.hpp:39
GREM_ALWAYS_INLINE constexpr vec< N, T > reflect(vec< N, T > a, vec< N, T > normal)
Get a vector reflected against a plane with a given normal vector.
Definition math.hpp:3970
DurationBase< int64_t, Ratio< 1, 1 > > Seconds
Definition time.hpp:53
constexpr bool equal(input_range auto &&rangeA, input_range auto &&rangeB)
Definition algorithms.hpp:358
GREM_ALWAYS_INLINE constexpr T GREM_VECTORCALL mix(T a, T b, T alpha)
Blend between two values based on an alpha value.
Definition math.hpp:3837
GREM_ALWAYS_INLINE constexpr vec< N, T > GREM_VECTORCALL ceil(vec< N, T > a)
Definition math.hpp:1422
GREM_ALWAYS_INLINE constexpr vec< N, T > GREM_VECTORCALL atan(vec< N, T > a)
Definition math.hpp:1399
GREM_ALWAYS_INLINE T GREM_VECTORCALL convertForwardDirectionToAngles(vec< 2, T > forward)
Definition math.hpp:3351
StringBase< char, std::char_traits< char >, std::allocator< char > > String
Definition String.hpp:17
GREM_ALWAYS_INLINE constexpr decltype(auto) max(A &&a, B &&b)
Get the greater of two values, or the first value if they are equivalent.
Definition fundamentals.hpp:598
GREM_ALWAYS_INLINE constexpr T GREM_VECTORCALL fmod(T a, T b) noexcept
Calculate the floating-point remainder of a scalar division.
Definition math.hpp:1192
GREM_ALWAYS_INLINE constexpr vec< N, T > flipZ(vec< N, T > a)
Get a vector flipped along the Z axis.
Definition math.hpp:3956
GREM_ALWAYS_INLINE vec< N, bool > GREM_VECTORCALL signbit(vec< N, T > values)
Get the sign bits of the components of a vector.
Definition math.hpp:3584
GREM_ALWAYS_INLINE constexpr bool GREM_VECTORCALL greaterThanEqual(T a, T b)
Definition math.hpp:1255
GREM_ALWAYS_INLINE qua< T > GREM_VECTORCALL convertAnglesToQuaternion(T pitchAngle, T yawAngle, T rollAngle)
Definition math.hpp:3271
GREM_ALWAYS_INLINE constexpr vec< N, T > GREM_VECTORCALL round(vec< N, T > a)
Definition math.hpp:1418
GREM_ALWAYS_INLINE constexpr vec< N, T > GREM_VECTORCALL tan(vec< N, T > a)
Definition math.hpp:1397
GREM_ALWAYS_INLINE qua< T > GREM_VECTORCALL convert3x3MatrixToQuaternion(const mat< 3, 3, T > &a)
Definition math.hpp:2569
GREM_ALWAYS_INLINE qua< T > GREM_VECTORCALL rotation(vec< 3, T > from, vec< 3, T > to)
Definition math.hpp:3214
GREM_ALWAYS_INLINE constexpr T GREM_VECTORCALL exp2(T a) noexcept
Calculate the result of 2 raised to a given power.
Definition math.hpp:1166
GREM_ALWAYS_INLINE constexpr T GREM_VECTORCALL inversesqrt(T a)
Get the reciprocal of the square root of a value.
Definition math.hpp:1136
GREM_ALWAYS_INLINE constexpr qua< T > GREM_VECTORCALL conjugate(qua< T > a)
Definition math.hpp:2260
GREM_ALWAYS_INLINE constexpr T GREM_VECTORCALL getAngle(vec< 2, T > a)
Get the absolute angle of a 2-dimensional vector, in radians.
Definition math.hpp:2136
GREM_ALWAYS_INLINE vec< 1, bool > GREM_VECTORCALL isnan(const vec< 1, T > &values)
Check if each component of a vector is NaN (not a number).
Definition math.hpp:3532
GREM_ALWAYS_INLINE constexpr mat< 1, 1, T > GREM_VECTORCALL inverse(const mat< 1, 1, T > &a)
Definition math.hpp:2267
GREM_ALWAYS_INLINE vec< 3, T > GREM_VECTORCALL getAxis(qua< T > orientation)
Definition math.hpp:3182
StringViewBase< char, std::char_traits< char > > StringView
Definition StringView.hpp:16
GREM_ALWAYS_INLINE constexpr vec< N, T > GREM_VECTORCALL acos(vec< N, T > a)
Definition math.hpp:1391
GREM_ALWAYS_INLINE constexpr decltype(auto) min(A &&a, B &&b)
Get the smaller of two values, or the first value if they are equivalent.
Definition fundamentals.hpp:585
GREM_ALWAYS_INLINE constexpr T GREM_VECTORCALL sign(T a)
Get the sign multiplier of a scalar.
Definition math.hpp:1204
GREM_ALWAYS_INLINE constexpr Optional< T > GREM_VECTORCALL tryGetAngle(vec< 2, T > a)
Try to get the absolute angle of a 2-dimensional vector, in radians.
Definition math.hpp:2149
GREM_ALWAYS_INLINE constexpr T GREM_VECTORCALL sum(vec< 1, T > a)
Definition math.hpp:1854
GREM_ALWAYS_INLINE T GREM_VECTORCALL getYaw(qua< T > orientation)
Definition math.hpp:3195
GREM_ALWAYS_INLINE constexpr T GREM_VECTORCALL maxComponent(vec< 1, T > a)
Definition math.hpp:1920
GREM_ALWAYS_INLINE vec< 1, bool > GREM_VECTORCALL isfinite(const vec< 1, T > &values)
Check if each component of a vector is finite.
Definition math.hpp:3428
GREM_ALWAYS_INLINE constexpr T moveTowards(T value, T targetValue, T delta)
Move a value linearly towards a target by some distance, without overshoot.
Definition math.hpp:4077
GREM_ALWAYS_INLINE constexpr T select(bool condition, T ifTrue, T ifFalse)
Choose between two values based on a condition.
Definition math.hpp:927
void formatTo(FormatOutput &output, physics::LocalInertiaOrientation< 2 >) const
Definition quantities.hpp:7632
void formatTo(FormatOutput &output, physics::LocalInertiaOrientation< 3 > value) const
Definition quantities.hpp:7639
constexpr const char * parseFormatSpecification(const char *p)
Definition quantities.hpp:7607
void formatTo(FormatOutput &output, physics::Orientation< 2 > value) const
Definition quantities.hpp:7616
StringView symbolSeparator
Definition quantities.hpp:7605
void formatTo(FormatOutput &output, physics::Orientation< 3 > value) const
Definition quantities.hpp:7625
void formatTo(FormatOutput &output, physics::Quantity< 1, UnitT > value) const
Definition quantities.hpp:7495
constexpr const char * parseFormatSpecification(const char *p)
Definition quantities.hpp:7486
StringView symbolSeparator
Definition quantities.hpp:7484
void formatTo(FormatOutput &output, physics::Quantity< 2, UnitT > value) const
Definition quantities.hpp:7518
constexpr const char * parseFormatSpecification(const char *p)
Definition quantities.hpp:7509
StringView symbolSeparator
Definition quantities.hpp:7507
constexpr const char * parseFormatSpecification(const char *p)
Definition quantities.hpp:7532
void formatTo(FormatOutput &output, physics::Quantity< 3, UnitT > value) const
Definition quantities.hpp:7541
StringView symbolSeparator
Definition quantities.hpp:7530
void formatTo(FormatOutput &output, physics::TensorQuantity< 2, UnitT > value) const
Definition quantities.hpp:7564
StringView symbolSeparator
Definition quantities.hpp:7553
constexpr const char * parseFormatSpecification(const char *p)
Definition quantities.hpp:7555
void formatTo(FormatOutput &output, physics::TensorQuantity< 3, UnitT > value) const
Definition quantities.hpp:7587
constexpr const char * parseFormatSpecification(const char *p)
Definition quantities.hpp:7578
StringView symbolSeparator
Definition quantities.hpp:7576
Definition formatting.hpp:47
constexpr const char * parseFormatSpecification(const auto &p)
Definition formatting.hpp:50
void formatTo(FormatOutput &output, const auto &value) const
Definition formatting.hpp:56
Definition fundamentals.hpp:27
static constexpr T MAX
Definition fundamentals.hpp:29
static constexpr T MIN
Definition fundamentals.hpp:28
void deserializeFrom(auto &reader, grem::physics::Quantity< N, UnitT > &value)
Definition quantities.hpp:7663
Base template to specialize in order to implement JSON deserialization for a specific type.
Definition json.hpp:4569
void serializeTo(auto &writer, const grem::physics::Quantity< N, UnitT > &value)
Definition quantities.hpp:7656
Base template to specialize in order to implement JSON serialization for a specific type.
Definition json.hpp:4551
Definition math.hpp:663
Wrapper type for a compile-time constant value.
Definition metaprogramming.hpp:193
The canonical unit type corresponding to a given unit with its magnitude made absolute.
Definition quantities.hpp:985
consteval Absolute(UnitT other)
Implicitly convert a unit to its absolute unit.
Definition quantities.hpp:998
static constexpr auto getSymbolString()
Get an ASCII string representation of the unit symbol of this unit, e.g. "kg m^2/s" if D is ANGULAR_M...
Definition quantities.hpp:987
Physical base unit type template.
Definition quantities.hpp:545
static constexpr auto getSymbolString()
Get an ASCII string representation of the unit symbol of this unit, e.g. "kg m^2/s" if D is ANGULAR_M...
Definition quantities.hpp:557
consteval auto operator+(const OtherUnitT &other) const
Get the canonical unit resulting from adding a quantity of another unit to a quantity of this unit.
Definition quantities.hpp:609
consteval auto operator/(const OtherUnitT &other) const
Get the canonical unit resulting from dividing a quantity of this unit by a quantity of another unit.
Definition quantities.hpp:654
consteval auto operator-() const
Get the canonical unit resulting from taking the additive inverse of a quantity of this unit.
Definition quantities.hpp:595
consteval auto operator+() const
Get the canonical unit resulting from taking the additive identity of a quantity of this unit.
Definition quantities.hpp:584
consteval auto operator-(const OtherUnitT &other) const
Get the canonical unit resulting from subtracting a quantity of another unit from a quantity of this ...
Definition quantities.hpp:624
consteval auto operator*(const OtherUnitT &other) const
Get the canonical unit resulting from multiplying a quantity of this unit with a quantity of another ...
Definition quantities.hpp:639
std::remove_cvref_t< decltype(M)> MagnitudeType
Magintude type of the unit.
Definition quantities.hpp:547
std::remove_cvref_t< decltype(D)> DimensionType
Dimension type of the unit.
Definition quantities.hpp:546
Tag type for specifying a specific vector components.
Definition quantities.hpp:1489
static constexpr size_t INDEX
Index of the corresponding vector component.
Definition quantities.hpp:1490
Definition quantities.hpp:4310
Quantity< 1, Radians > angle
Definition quantities.hpp:4312
Direction< N > direction
Definition quantities.hpp:4288
Physical dimension type template.
Definition quantities.hpp:56
static constexpr int LENGTH
Length exponent of the dimension.
Definition quantities.hpp:58
consteval bool operator==(const Dimension &other) const noexcept
Compare this dimension to another for equality.
Definition quantities.hpp:76
static constexpr int MASS
Mass exponent of the dimension.
Definition quantities.hpp:57
friend consteval auto sqrt(const Dimension &dimension)
Get the dimension resulting from taking the square root of a quantity of a dimension.
Definition quantities.hpp:176
consteval bool operator==(const Dimension< OtherMass, OtherLength, OtherTime > &other) const noexcept
Compare this dimension to another for equality.
Definition quantities.hpp:89
consteval auto operator+(const Dimension &other) const
Get the dimension resulting from adding a quantity of another dimension to a quantity of this dimensi...
Definition quantities.hpp:122
consteval auto operator+() const
Get the dimension resulting from taking the additive identity of a quantity of this dimension.
Definition quantities.hpp:100
static constexpr auto getSIUnitSymbolString()
Get an ASCII string representation of the symbol of the SI unit for this dimension,...
Definition quantities.hpp:219
static constexpr int TIME
Time exponent of the dimension.
Definition quantities.hpp:59
consteval auto operator-(const Dimension &other) const
Get the dimension resulting from subtracting a quantity of another dimension from a quantity of this ...
Definition quantities.hpp:135
consteval auto operator-() const
Get the dimension resulting from taking the additive inverse of a quantity of this dimension.
Definition quantities.hpp:110
consteval auto operator/(const Dimension< OtherMass, OtherLength, OtherTime > &other) const
Get the dimension resulting from dividing a quantity of this dimension by a quantity of another dimen...
Definition quantities.hpp:163
consteval auto operator*(const Dimension< OtherMass, OtherLength, OtherTime > &other) const
Get the dimension resulting from multiplying a quantity of this dimension with a quantity of another ...
Definition quantities.hpp:149
Normalized unit vector.
Definition quantities.hpp:4105
GREM_ALWAYS_INLINE constexpr Direction() noexcept
Definition quantities.hpp:4121
GREM_ALWAYS_INLINE constexpr bool operator==(const Quantity< 2, OtherUnitT > &other) const noexcept
Definition quantities.hpp:4135
GREM_ALWAYS_INLINE constexpr Direction GREM_VECTORCALL operator-() const
Definition quantities.hpp:4143
GREM_ALWAYS_INLINE constexpr bool operator==(Zero other) const noexcept
Definition quantities.hpp:4139
GREM_ALWAYS_INLINE constexpr bool operator==(const Direction &other) const noexcept
Definition quantities.hpp:4130
static GREM_ALWAYS_INLINE constexpr Direction reinterpret(auto other)
Definition quantities.hpp:4117
Exception type for domain-specific errors originating from the grem::physics module.
Definition Error.hpp:17
Local inertia orientation of an object, rotating from inertia major axis space to shape-local space.
Definition quantities.hpp:5873
Physical magnitude type template.
Definition quantities.hpp:326
consteval auto operator*(const Magnitude< OtherValue, OtherIsAbsolute > &other) const
Get the magnitude resulting from multiplying a quantity of this magnitude with a quantity of another ...
Definition quantities.hpp:443
consteval auto operator-(const Magnitude< OtherValue, OtherIsAbsolute > &other) const
Get the magnitude resulting from subtracting a quantity of another magnitude from a quantity of this ...
Definition quantities.hpp:420
consteval auto operator-() const
Get the magnitude resulting from taking the additive inverse of a quantity of this magnitude.
Definition quantities.hpp:378
consteval bool operator==(const Magnitude &other) const noexcept
Compare this magnitude to another for equality.
Definition quantities.hpp:337
consteval bool operator==(const Magnitude< OtherValue, OtherIsAbsolute > &other) const noexcept
Compare this magnitude to another for equality.
Definition quantities.hpp:350
static constexpr bool IS_ABSOLUTE
Simplified indicator of the magnitude's reference frame (true for global world space,...
Definition quantities.hpp:328
consteval auto operator+(const Magnitude< OtherValue, OtherIsAbsolute > &other) const
Get the magnitude resulting from adding a quantity of another magnitude to a quantity of this magnitu...
Definition quantities.hpp:397
consteval auto operator+() const
Get the magnitude resulting from taking the additive identity of a quantity of this magnitude.
Definition quantities.hpp:363
friend consteval auto sqrt(const Magnitude &magnitude)
Get the magnitude resulting from taking the square root of a quantity of a magnitude.
Definition quantities.hpp:479
static constexpr long double VALUE
Quantity multiplier of the magnitude.
Definition quantities.hpp:327
consteval auto operator/(const Magnitude< OtherValue, OtherIsAbsolute > &other) const
Get the magnitude resulting from dividing a quantity of this magnitude by a quantity of another magni...
Definition quantities.hpp:463
static constexpr MagnitudeType MAGNITUDE
Definition quantities.hpp:4446
typename Unit::DimensionType DimensionType
Definition quantities.hpp:4441
GREM_ALWAYS_INLINE constexpr Orientation(Quantity< 1, OtherUnitT > angle) noexcept
Definition quantities.hpp:4459
GREM_ALWAYS_INLINE constexpr bool operator==(const Orientation &) const noexcept=default
static constexpr size_t RANK
Definition quantities.hpp:4443
GREM_ALWAYS_INLINE constexpr Quantity< 1, Unitless > in(OtherUnitT) const
Definition quantities.hpp:4476
GREM_ALWAYS_INLINE constexpr Orientation() noexcept=default
GREM_ALWAYS_INLINE Quantity< 1, UnitT > GREM_VECTORCALL operator()(Quantity< 1, UnitT > b) const
Definition quantities.hpp:4497
GREM_ALWAYS_INLINE constexpr Orientation(double angle) noexcept
Definition quantities.hpp:4455
static constexpr DimensionType DIMENSION
Definition quantities.hpp:4445
GREM_ALWAYS_INLINE Quantity< 2, UnitT > GREM_VECTORCALL operator()(Quantity< 2, UnitT > b) const
Definition quantities.hpp:4488
GREM_ALWAYS_INLINE Direction2D GREM_VECTORCALL operator()(Direction2D b) const
Definition quantities.hpp:4492
GREM_ALWAYS_INLINE constexpr size_t size() const noexcept
Definition quantities.hpp:4501
static constexpr Unit UNIT
Definition quantities.hpp:4444
typename Unit::MagnitudeType MagnitudeType
Definition quantities.hpp:4442
Absolute< Radians > Unit
Definition quantities.hpp:4440
GREM_ALWAYS_INLINE Quantity< 3, UnitT > GREM_VECTORCALL operator()(Quantity< 3, UnitT > b) const
Definition quantities.hpp:4579
typename Unit::DimensionType DimensionType
Definition quantities.hpp:4515
static GREM_ALWAYS_INLINE Orientation angleAxis(AbsoluteAngle angle, Scale3D axis)
Definition quantities.hpp:4530
static GREM_ALWAYS_INLINE Orientation pitch(AbsoluteAngle angle)
Definition quantities.hpp:4534
Absolute< Radians > Unit
Definition quantities.hpp:4514
GREM_ALWAYS_INLINE constexpr Orientation() noexcept=default
static GREM_ALWAYS_INLINE Orientation lookAt(Scale3D direction, Scale3D up)
Definition quantities.hpp:4526
static GREM_ALWAYS_INLINE Orientation roll(AbsoluteAngle angle)
Definition quantities.hpp:4542
typename Unit::MagnitudeType MagnitudeType
Definition quantities.hpp:4516
static constexpr MagnitudeType MAGNITUDE
Definition quantities.hpp:4520
static GREM_ALWAYS_INLINE Orientation rotation(Scale3D from, Scale3D to)
Definition quantities.hpp:4522
GREM_ALWAYS_INLINE constexpr Orientation(qua< double > quaternion) noexcept
Definition quantities.hpp:4565
static GREM_ALWAYS_INLINE Orientation fromAngles(PitchYawRoll angles)
Definition quantities.hpp:4550
GREM_ALWAYS_INLINE Direction3D GREM_VECTORCALL operator()(Direction3D b) const
Definition quantities.hpp:4583
static GREM_ALWAYS_INLINE Orientation yaw(AbsoluteAngle angle)
Definition quantities.hpp:4538
GREM_ALWAYS_INLINE constexpr bool operator==(const Orientation &) const noexcept=default
static constexpr size_t RANK
Definition quantities.hpp:4517
static constexpr DimensionType DIMENSION
Definition quantities.hpp:4519
static GREM_ALWAYS_INLINE Orientation fromAngles(AbsoluteAngle pitchAngle, AbsoluteAngle yawAngle, AbsoluteAngle rollAngle)
Definition quantities.hpp:4546
AbsoluteAngle Component
Definition quantities.hpp:4513
static constexpr Unit UNIT
Definition quantities.hpp:4518
GREM_ALWAYS_INLINE constexpr size_t size() const noexcept
Definition quantities.hpp:4587
static GREM_ALWAYS_INLINE Orientation fromBasis(const Basis3D &basis)
Definition quantities.hpp:4554
Absolute orientation in world space.
Definition quantities.hpp:4431
Basis whose columns are all unit vectors that are orthogonal to each other.
Definition quantities.hpp:4338
GREM_ALWAYS_INLINE Component operator[](meta::Constant< Index >) const noexcept
Definition quantities.hpp:4386
GREM_ALWAYS_INLINE constexpr bool operator==(const TensorQuantity< N, OtherUnitT > &other) const noexcept
Definition quantities.hpp:4359
GREM_ALWAYS_INLINE Component operator[](ComponentSwizzle< Index >) const noexcept
Definition quantities.hpp:4374
static GREM_ALWAYS_INLINE constexpr OrthonormalBasis reinterpret(const auto &value)
Definition quantities.hpp:4350
GREM_ALWAYS_INLINE Component operator[](ComponentSwizzle< Index >) noexcept
Definition quantities.hpp:4368
GREM_ALWAYS_INLINE Component operator[](meta::Constant< Index >) noexcept
Definition quantities.hpp:4380
GREM_ALWAYS_INLINE constexpr bool operator==(const OrthonormalBasis &other) const noexcept
Definition quantities.hpp:4354
GREM_ALWAYS_INLINE constexpr bool operator==(Zero other) const noexcept
Definition quantities.hpp:4363
Direction< N > Component
Definition quantities.hpp:4341
GREM_ALWAYS_INLINE Direction< N > GREM_VECTORCALL operator*(Direction< N > direction) const
Definition quantities.hpp:4399
GREM_ALWAYS_INLINE constexpr OrthonormalBasis GREM_VECTORCALL operator-() const
Definition quantities.hpp:4391
GREM_ALWAYS_INLINE OrthonormalBasis GREM_VECTORCALL operator*(const OrthonormalBasis &other) const
Definition quantities.hpp:4395
GREM_ALWAYS_INLINE constexpr Quantity(Quantity &&) noexcept=default
GREM_ALWAYS_INLINE constexpr size_t size() const noexcept
Definition quantities.hpp:1666
static constexpr DimensionType DIMENSION
Definition quantities.hpp:1524
GREM_ALWAYS_INLINE constexpr auto operator<=>(const Quantity &other) const noexcept
Definition quantities.hpp:1585
UnitT Unit
Definition quantities.hpp:1519
GREM_ALWAYS_INLINE constexpr Quantity & operator=(Zero)
Definition quantities.hpp:1571
GREM_ALWAYS_INLINE constexpr bool operator==(const Quantity &other) const noexcept
Definition quantities.hpp:1576
static constexpr size_t RANK
Definition quantities.hpp:1522
GREM_ALWAYS_INLINE constexpr bool operator==(const Quantity< 1, OtherUnitT > &other) const noexcept
Definition quantities.hpp:1581
GREM_ALWAYS_INLINE constexpr auto operator<=>(Arithmetic other) const noexcept
Definition quantities.hpp:1600
GREM_ALWAYS_INLINE constexpr Quantity(const Quantity &)=default
static constexpr Unit UNIT
Definition quantities.hpp:1523
GREM_ALWAYS_INLINE constexpr Quantity()=default
GREM_ALWAYS_INLINE size_t getMinIndex() const
Definition quantities.hpp:1670
GREM_ALWAYS_INLINE constexpr Quantity< 1, OtherUnitT > as(OtherUnitT) const
Definition quantities.hpp:1661
friend struct Quantity
Definition quantities.hpp:1680
static const Quantity SMALLEST_SUBNORMAL
Definition quantities.hpp:1529
GREM_ALWAYS_INLINE constexpr auto operator<=>(const Quantity< 1, OtherUnitT > &other) const noexcept
Definition quantities.hpp:1590
GREM_ALWAYS_INLINE constexpr auto operator<=>(Zero) const noexcept
Definition quantities.hpp:1608
GREM_ALWAYS_INLINE constexpr bool operator==(Zero) const noexcept
Definition quantities.hpp:1604
static constexpr MagnitudeType MAGNITUDE
Definition quantities.hpp:1525
static const Quantity MAX
Definition quantities.hpp:1527
GREM_ALWAYS_INLINE size_t getMaxIndex() const
Definition quantities.hpp:1674
static const Quantity MIN
Definition quantities.hpp:1526
static const Quantity QUIET_NAN
Definition quantities.hpp:1532
GREM_ALWAYS_INLINE constexpr Quantity(const DurationBase< Rep, Period > &duration)
Definition quantities.hpp:1568
static GREM_ALWAYS_INLINE constexpr Quantity reinterpret(floating_point auto value)
Definition quantities.hpp:1539
GREM_ALWAYS_INLINE constexpr bool operator==(Arithmetic other) const noexcept
Definition quantities.hpp:1595
static const Quantity INF
Definition quantities.hpp:1531
typename Unit::MagnitudeType MagnitudeType
Definition quantities.hpp:1521
GREM_ALWAYS_INLINE constexpr auto operator<=>(const DurationBase< Rep, Period > &other) const noexcept
Definition quantities.hpp:1622
GREM_ALWAYS_INLINE constexpr Quantity(const Quantity< 1, OtherUnitT > &q)
Definition quantities.hpp:1562
GREM_ALWAYS_INLINE constexpr bool operator==(const DurationBase< Rep, Period > &other) const noexcept
Definition quantities.hpp:1613
GREM_ALWAYS_INLINE constexpr Quantity< 1, Unitless > in(OtherUnitT) const
Definition quantities.hpp:1651
static const Quantity MACHINE_EPSILON
Definition quantities.hpp:1530
static GREM_ALWAYS_INLINE constexpr Quantity reinterpret(Quantity< 1, OtherUnitT > other)
Definition quantities.hpp:1535
typename Unit::DimensionType DimensionType
Definition quantities.hpp:1520
GREM_ALWAYS_INLINE constexpr Quantity(floating_point auto value)
Definition quantities.hpp:1558
static const Quantity SMALLEST_NORMAL
Definition quantities.hpp:1528
static const Quantity SMALLEST_NORMAL
Definition quantities.hpp:2008
static constexpr size_t RANK
Definition quantities.hpp:2002
GREM_ALWAYS_INLINE ComponentProxy< 2, UnitT, Index > operator[](meta::Constant< Index >) noexcept
Definition quantities.hpp:2201
GREM_ALWAYS_INLINE void setX(Component x) noexcept
Definition quantities.hpp:2096
GREM_ALWAYS_INLINE Component getY() const noexcept
Definition quantities.hpp:2184
GREM_ALWAYS_INLINE constexpr Quantity & operator=(Zero)
Definition quantities.hpp:2068
static const Quantity MAX
Definition quantities.hpp:2007
GREM_ALWAYS_INLINE constexpr Quantity< 2, OtherUnitT > as(OtherUnitT) const
Definition quantities.hpp:2231
static GREM_ALWAYS_INLINE constexpr Quantity reinterpret(Quantity< 2, OtherUnitT > other)
Definition quantities.hpp:2015
GREM_ALWAYS_INLINE constexpr Quantity(Quantity &&) noexcept=default
GREM_ALWAYS_INLINE constexpr Quantity(const Quantity &)=default
GREM_ALWAYS_INLINE constexpr Quantity(Zero, Component y)
Definition quantities.hpp:2048
GREM_ALWAYS_INLINE constexpr Quantity(const Quantity< 2, OtherUnitT > &q)
Definition quantities.hpp:2063
typename Unit::MagnitudeType MagnitudeType
Definition quantities.hpp:2001
GREM_ALWAYS_INLINE ComponentProxy< 2, UnitT, Index > operator[](ComponentSwizzle< Index >) noexcept
Definition quantities.hpp:2189
GREM_ALWAYS_INLINE ConstComponentProxy< 2, UnitT, Index > operator[](ComponentSwizzle< Index >) const noexcept
Definition quantities.hpp:2195
Quantity< 1, UnitT > Component
Definition quantities.hpp:1998
GREM_ALWAYS_INLINE Quantity< 2, UnitT > get(ComponentSwizzle< IndexX > SwizzleX, Zero) const noexcept
Definition quantities.hpp:2127
static constexpr MagnitudeType MAGNITUDE
Definition quantities.hpp:2005
GREM_ALWAYS_INLINE constexpr bool operator==(const Quantity< 2, OtherUnitT > &other) const noexcept
Definition quantities.hpp:2078
static const Quantity MACHINE_EPSILON
Definition quantities.hpp:2010
GREM_ALWAYS_INLINE Quantity< 3, UnitT > get(ComponentSwizzle< IndexX > SwizzleX, ComponentSwizzle< IndexY > SwizzleY, ComponentSwizzle< IndexZ > SwizzleZ) const noexcept
Definition quantities.hpp:2141
static GREM_ALWAYS_INLINE constexpr Quantity reinterpret(vec< 2, float > value)
Definition quantities.hpp:2019
GREM_ALWAYS_INLINE Quantity< 2, Unitless > in(OtherUnitT) const
Definition quantities.hpp:2221
friend class ComponentProxy
Definition quantities.hpp:2260
GREM_ALWAYS_INLINE Quantity< 2, UnitT > get(Zero, Zero) const noexcept
Definition quantities.hpp:2136
GREM_ALWAYS_INLINE Quantity< 3, UnitT > get(Zero, ComponentSwizzle< IndexY > SwizzleY, ComponentSwizzle< IndexZ > SwizzleZ) const noexcept
Definition quantities.hpp:2157
GREM_ALWAYS_INLINE constexpr bool operator==(const Quantity &other) const noexcept
Definition quantities.hpp:2073
static const Quantity INF
Definition quantities.hpp:2011
friend struct Quantity
Definition quantities.hpp:2254
GREM_ALWAYS_INLINE Quantity< 2, UnitT > get(ComponentSwizzle< IndexX > SwizzleX, ComponentSwizzle< IndexY > SwizzleY) const noexcept
Definition quantities.hpp:2122
static constexpr Unit UNIT
Definition quantities.hpp:2003
GREM_ALWAYS_INLINE constexpr size_t size() const noexcept
Definition quantities.hpp:2236
static constexpr DimensionType DIMENSION
Definition quantities.hpp:2004
GREM_ALWAYS_INLINE constexpr Quantity(Component x, Zero)
Definition quantities.hpp:2051
GREM_ALWAYS_INLINE Quantity< 3, UnitT > get(Zero, ComponentSwizzle< IndexY > SwizzleY, Zero) const noexcept
Definition quantities.hpp:2167
GREM_ALWAYS_INLINE size_t getMaxIndex() const
Definition quantities.hpp:2246
GREM_ALWAYS_INLINE Quantity< 3, UnitT > get(ComponentSwizzle< IndexX > SwizzleX, Zero, ComponentSwizzle< IndexZ > SwizzleZ) const noexcept
Definition quantities.hpp:2152
GREM_ALWAYS_INLINE constexpr Quantity(vec< 2, double > v)
Definition quantities.hpp:2059
GREM_ALWAYS_INLINE Component getX() const noexcept
Definition quantities.hpp:2180
GREM_ALWAYS_INLINE Quantity< 3, UnitT > get(Zero, Zero, Zero) const noexcept
Definition quantities.hpp:2176
static const Quantity SMALLEST_SUBNORMAL
Definition quantities.hpp:2009
GREM_ALWAYS_INLINE constexpr Quantity(Component x, Component y)
Definition quantities.hpp:2045
typename Unit::DimensionType DimensionType
Definition quantities.hpp:2000
static GREM_ALWAYS_INLINE constexpr Quantity reinterpret(vec< 2, double > value)
Definition quantities.hpp:2023
GREM_ALWAYS_INLINE Quantity< 2, UnitT > get(Zero, ComponentSwizzle< IndexY > SwizzleY) const noexcept
Definition quantities.hpp:2132
GREM_ALWAYS_INLINE Quantity< 3, UnitT > get(ComponentSwizzle< IndexX > SwizzleX, ComponentSwizzle< IndexY > SwizzleY, Zero) const noexcept
Definition quantities.hpp:2147
static const Quantity QUIET_NAN
Definition quantities.hpp:2012
GREM_ALWAYS_INLINE Quantity< 3, UnitT > get(Zero, Zero, ComponentSwizzle< IndexZ > SwizzleZ) const noexcept
Definition quantities.hpp:2172
GREM_ALWAYS_INLINE Component get(ComponentSwizzle< Index > Swizzle) const noexcept
Definition quantities.hpp:2113
GREM_ALWAYS_INLINE void setY(Component y) noexcept
Definition quantities.hpp:2104
GREM_ALWAYS_INLINE void setX(Zero) noexcept
Definition quantities.hpp:2100
friend class ConstComponentProxy
Definition quantities.hpp:2257
GREM_ALWAYS_INLINE Component get(Zero) const noexcept
Definition quantities.hpp:2117
GREM_ALWAYS_INLINE void setY(Zero) noexcept
Definition quantities.hpp:2108
static const Quantity MIN
Definition quantities.hpp:2006
GREM_ALWAYS_INLINE constexpr bool operator==(Zero) const noexcept
Definition quantities.hpp:2082
UnitT Unit
Definition quantities.hpp:1999
GREM_ALWAYS_INLINE ConstComponentProxy< 2, UnitT, Index > operator[](meta::Constant< Index >) const noexcept
Definition quantities.hpp:2207
GREM_ALWAYS_INLINE void set(ComponentSwizzle< Index > Swizzle, Zero) noexcept
Definition quantities.hpp:2092
GREM_ALWAYS_INLINE constexpr Quantity(Component value)
Definition quantities.hpp:2042
GREM_ALWAYS_INLINE void set(ComponentSwizzle< Index > Swizzle, Component value) noexcept
Definition quantities.hpp:2087
GREM_ALWAYS_INLINE size_t getMinIndex() const
Definition quantities.hpp:2240
GREM_ALWAYS_INLINE Quantity< 3, UnitT > get(ComponentSwizzle< IndexX > SwizzleX, Zero, Zero) const noexcept
Definition quantities.hpp:2162
GREM_ALWAYS_INLINE constexpr Quantity(Zero, Zero)
Definition quantities.hpp:2054
GREM_ALWAYS_INLINE constexpr Quantity(vec< 2, float > v)
Definition quantities.hpp:2056
GREM_ALWAYS_INLINE constexpr Quantity()=default
GREM_ALWAYS_INLINE constexpr Quantity(Zero, Component y, Zero)
Definition quantities.hpp:2379
GREM_ALWAYS_INLINE Quantity< 3, UnitT > get(Zero, ComponentSwizzle< IndexY > SwizzleY, ComponentSwizzle< IndexZ > SwizzleZ) const noexcept
Definition quantities.hpp:2525
GREM_ALWAYS_INLINE void setZ(Component z) noexcept
Definition quantities.hpp:2468
static GREM_ALWAYS_INLINE constexpr Quantity reinterpret(vec< 3, float > value)
Definition quantities.hpp:2318
GREM_ALWAYS_INLINE constexpr Quantity(Zero, Zero, Zero)
Definition quantities.hpp:2385
GREM_ALWAYS_INLINE constexpr Quantity(Component value)
Definition quantities.hpp:2355
GREM_ALWAYS_INLINE Component getZ() const noexcept
Definition quantities.hpp:2556
UnitT Unit
Definition quantities.hpp:2297
GREM_ALWAYS_INLINE Quantity< 3, UnitT > get(ComponentSwizzle< IndexX > SwizzleX, ComponentSwizzle< IndexY > SwizzleY, Zero) const noexcept
Definition quantities.hpp:2515
GREM_ALWAYS_INLINE constexpr Quantity(Quantity< 2, UnitT > xy, Zero)
Definition quantities.hpp:2403
GREM_ALWAYS_INLINE void set(ComponentSwizzle< Index > Swizzle, Component value) noexcept
Definition quantities.hpp:2443
GREM_ALWAYS_INLINE Quantity< 2, UnitT > get(ComponentSwizzle< IndexX > SwizzleX, Zero) const noexcept
Definition quantities.hpp:2491
GREM_ALWAYS_INLINE constexpr bool operator==(const Quantity< 3, OtherUnitT > &other) const noexcept
Definition quantities.hpp:2430
GREM_ALWAYS_INLINE Component getY() const noexcept
Definition quantities.hpp:2552
GREM_ALWAYS_INLINE void setX(Zero) noexcept
Definition quantities.hpp:2456
static constexpr Unit UNIT
Definition quantities.hpp:2301
GREM_ALWAYS_INLINE Quantity< 2, UnitT > get(Zero, Zero) const noexcept
Definition quantities.hpp:2500
GREM_ALWAYS_INLINE constexpr Quantity(Zero, Component y, Component z)
Definition quantities.hpp:2367
GREM_ALWAYS_INLINE Component get(Zero) const noexcept
Definition quantities.hpp:2481
Quantity< 1, UnitT > Component
Definition quantities.hpp:2296
GREM_ALWAYS_INLINE constexpr Quantity(const Quantity< 3, OtherUnitT > &q)
Definition quantities.hpp:2395
GREM_ALWAYS_INLINE constexpr Quantity(Zero, Zero, Component z)
Definition quantities.hpp:2373
friend class ComponentProxy
Definition quantities.hpp:2650
static const Quantity SMALLEST_SUBNORMAL
Definition quantities.hpp:2308
GREM_ALWAYS_INLINE constexpr Quantity(Zero, Quantity< 2, UnitT > yz)
Definition quantities.hpp:2409
GREM_ALWAYS_INLINE Quantity< 3, UnitT > get(ComponentSwizzle< IndexX > SwizzleX, Zero, Zero) const noexcept
Definition quantities.hpp:2530
GREM_ALWAYS_INLINE Quantity< 3, UnitT > get(ComponentSwizzle< IndexX > SwizzleX, ComponentSwizzle< IndexY > SwizzleY, ComponentSwizzle< IndexZ > SwizzleZ) const noexcept
Definition quantities.hpp:2505
GREM_ALWAYS_INLINE constexpr Quantity(Component x, Component y, Zero)
Definition quantities.hpp:2376
static GREM_ALWAYS_INLINE constexpr Quantity reinterpret(Quantity< 3, OtherUnitT > other)
Definition quantities.hpp:2314
static constexpr DimensionType DIMENSION
Definition quantities.hpp:2302
GREM_ALWAYS_INLINE void setZ(Zero) noexcept
Definition quantities.hpp:2472
friend struct Quantity
Definition quantities.hpp:2644
GREM_ALWAYS_INLINE void setY(Component y) noexcept
Definition quantities.hpp:2460
GREM_ALWAYS_INLINE size_t getMinIndex() const
Definition quantities.hpp:2612
GREM_ALWAYS_INLINE constexpr Quantity(Quantity< 2, UnitT > xy, Component z)
Definition quantities.hpp:2400
GREM_ALWAYS_INLINE constexpr Quantity(Quantity &&) noexcept=default
GREM_ALWAYS_INLINE Quantity< 3, UnitT > get(Zero, Zero, ComponentSwizzle< IndexZ > SwizzleZ) const noexcept
Definition quantities.hpp:2540
GREM_ALWAYS_INLINE constexpr Quantity< 3, OtherUnitT > as(OtherUnitT) const
Definition quantities.hpp:2603
GREM_ALWAYS_INLINE constexpr Quantity(vec< 3, float > v)
Definition quantities.hpp:2388
GREM_ALWAYS_INLINE Component get(ComponentSwizzle< Index > Swizzle) const noexcept
Definition quantities.hpp:2477
GREM_ALWAYS_INLINE void setY(Zero) noexcept
Definition quantities.hpp:2464
GREM_ALWAYS_INLINE constexpr bool operator==(const Quantity &other) const noexcept
Definition quantities.hpp:2421
GREM_ALWAYS_INLINE Quantity< 2, UnitT > get(Zero, ComponentSwizzle< IndexY > SwizzleY) const noexcept
Definition quantities.hpp:2496
GREM_ALWAYS_INLINE void set(ComponentSwizzle< Index > Swizzle, Zero) noexcept
Definition quantities.hpp:2448
typename Unit::MagnitudeType MagnitudeType
Definition quantities.hpp:2299
GREM_ALWAYS_INLINE constexpr size_t size() const noexcept
Definition quantities.hpp:2608
static GREM_ALWAYS_INLINE constexpr Quantity reinterpret(vec< 3, double > value)
Definition quantities.hpp:2322
GREM_ALWAYS_INLINE ComponentProxy< 3, UnitT, Index > operator[](ComponentSwizzle< Index >) noexcept
Definition quantities.hpp:2561
static const Quantity QUIET_NAN
Definition quantities.hpp:2311
GREM_ALWAYS_INLINE size_t getMaxIndex() const
Definition quantities.hpp:2627
GREM_ALWAYS_INLINE Quantity< 3, Unitless > in(OtherUnitT) const
Definition quantities.hpp:2593
GREM_ALWAYS_INLINE Component getX() const noexcept
Definition quantities.hpp:2548
GREM_ALWAYS_INLINE constexpr Quantity(Component x, Quantity< 2, UnitT > yz)
Definition quantities.hpp:2406
GREM_ALWAYS_INLINE ComponentProxy< 3, UnitT, Index > operator[](meta::Constant< Index >) noexcept
Definition quantities.hpp:2573
static const Quantity INF
Definition quantities.hpp:2310
GREM_ALWAYS_INLINE ConstComponentProxy< 3, UnitT, Index > operator[](meta::Constant< Index >) const noexcept
Definition quantities.hpp:2579
static const Quantity MACHINE_EPSILON
Definition quantities.hpp:2309
GREM_ALWAYS_INLINE constexpr Quantity()=default
static constexpr MagnitudeType MAGNITUDE
Definition quantities.hpp:2303
GREM_ALWAYS_INLINE Quantity< 3, UnitT > get(ComponentSwizzle< IndexX > SwizzleX, Zero, ComponentSwizzle< IndexZ > SwizzleZ) const noexcept
Definition quantities.hpp:2520
static const Quantity MIN
Definition quantities.hpp:2305
GREM_ALWAYS_INLINE constexpr Quantity(vec< 3, double > v)
Definition quantities.hpp:2391
GREM_ALWAYS_INLINE void setX(Component x) noexcept
Definition quantities.hpp:2452
GREM_ALWAYS_INLINE constexpr Quantity(Component x, Zero, Zero)
Definition quantities.hpp:2382
friend class ConstComponentProxy
Definition quantities.hpp:2647
static const Quantity SMALLEST_NORMAL
Definition quantities.hpp:2307
static constexpr size_t RANK
Definition quantities.hpp:2300
GREM_ALWAYS_INLINE Quantity< 3, UnitT > get(Zero, ComponentSwizzle< IndexY > SwizzleY, Zero) const noexcept
Definition quantities.hpp:2535
GREM_ALWAYS_INLINE constexpr Quantity(Component x, Zero, Component z)
Definition quantities.hpp:2370
typename Unit::DimensionType DimensionType
Definition quantities.hpp:2298
GREM_ALWAYS_INLINE constexpr Quantity(Component x, Component y, Component z)
Definition quantities.hpp:2358
static const Quantity MAX
Definition quantities.hpp:2306
GREM_ALWAYS_INLINE ConstComponentProxy< 3, UnitT, Index > operator[](ComponentSwizzle< Index >) const noexcept
Definition quantities.hpp:2567
GREM_ALWAYS_INLINE Quantity< 2, UnitT > get(ComponentSwizzle< IndexX > SwizzleX, ComponentSwizzle< IndexY > SwizzleY) const noexcept
Definition quantities.hpp:2486
GREM_ALWAYS_INLINE Quantity< 3, UnitT > get(Zero, Zero, Zero) const noexcept
Definition quantities.hpp:2544
static const Quantity ZERO
Definition quantities.hpp:2304
GREM_ALWAYS_INLINE constexpr Quantity & operator=(Zero)
Definition quantities.hpp:2412
GREM_ALWAYS_INLINE constexpr bool operator==(Zero) const noexcept
Definition quantities.hpp:2438
GREM_ALWAYS_INLINE constexpr Quantity(const Quantity &)=default
Physical quantity type.
Definition quantities.hpp:1504
Definition quantities.hpp:3740
static GREM_ALWAYS_INLINE constexpr TensorQuantity reinterpret(const TensorQuantity< N, OtherUnitT > &other)
Definition quantities.hpp:3751
static constexpr size_t RANK
Definition quantities.hpp:3745
GREM_ALWAYS_INLINE constexpr bool operator==(const TensorQuantity &other) const noexcept
Definition quantities.hpp:3806
typename Unit::MagnitudeType MagnitudeType
Definition quantities.hpp:3744
constexpr TensorQuantity(const mat< N, N, double > &value) noexcept
Definition quantities.hpp:3770
constexpr TensorQuantity(Component x, Component y) noexcept
Definition quantities.hpp:3776
constexpr TensorQuantity(Component x, Component y, Component z) noexcept
Definition quantities.hpp:3779
GREM_ALWAYS_INLINE Component operator[](meta::Constant< Index >) const noexcept
Definition quantities.hpp:3838
GREM_ALWAYS_INLINE constexpr bool operator==(const TensorQuantity< N, OtherUnitT > &other) const noexcept
Definition quantities.hpp:3811
static GREM_ALWAYS_INLINE constexpr TensorQuantity reinterpret(const mat< N, N, double > &value)
Definition quantities.hpp:3759
GREM_ALWAYS_INLINE constexpr bool operator==(Zero) const noexcept
Definition quantities.hpp:3815
typename Unit::DimensionType DimensionType
Definition quantities.hpp:3743
GREM_ALWAYS_INLINE Component operator[](meta::Constant< Index >) noexcept
Definition quantities.hpp:3832
GREM_ALWAYS_INLINE constexpr size_t size() const noexcept
Definition quantities.hpp:3843
constexpr TensorQuantity() noexcept=default
constexpr TensorQuantity(Quantity< 1, Unitless > value) noexcept
Definition quantities.hpp:3773
static constexpr DimensionType DIMENSION
Definition quantities.hpp:3747
GREM_ALWAYS_INLINE Component operator[](ComponentSwizzle< Index >) const noexcept
Definition quantities.hpp:3826
static GREM_ALWAYS_INLINE constexpr TensorQuantity reinterpret(const mat< N, N, float > &value)
Definition quantities.hpp:3755
GREM_ALWAYS_INLINE Quantity< N, Square< Relative< Unitless > > > getScale2() const noexcept
Definition quantities.hpp:3798
GREM_ALWAYS_INLINE Quantity< N, Relative< Unitless > > getScale() const noexcept
Definition quantities.hpp:3790
static constexpr Unit UNIT
Definition quantities.hpp:3746
UnitT Unit
Definition quantities.hpp:3742
Quantity< N, UnitT > Component
Definition quantities.hpp:3741
static constexpr MagnitudeType MAGNITUDE
Definition quantities.hpp:3748
GREM_ALWAYS_INLINE Component operator[](ComponentSwizzle< Index >) noexcept
Definition quantities.hpp:3820
Abstract physical quantity representing the origin of the global world space reference frame,...
Definition quantities.hpp:1417
GREM_ALWAYS_INLINE consteval Zero(Zero *value)
Implicitly convert a compile-time 0 literal to a zero.
Definition quantities.hpp:1468
GREM_ALWAYS_INLINE consteval Zero(double value)
Explicitly construct a zero from a compile-time double.
Definition quantities.hpp:1438
GREM_ALWAYS_INLINE consteval Zero(float value)
Explicitly construct a zero from a compile-time float.
Definition quantities.hpp:1425
GREM_ALWAYS_INLINE consteval Zero(int value)
Explicitly construct a zero from a compile-time int.
Definition quantities.hpp:1451
Definition math.hpp:825
T y
Definition math.hpp:830
T w
Definition math.hpp:832
T x
Definition math.hpp:829
T z
Definition math.hpp:831
Definition math.hpp:58