![]() |
ToyGine2 26.2.0
Game Engine for retro consoles
|
Mathematical types, constants, and utilities: fixed-point, vectors, point. More...
Namespaces | |
| namespace | constants |
| Variable templates for mathematical constants. | |
Classes | |
| class | fixed |
| Fixed-point numeric type with configurable storage and fractional precision. More... | |
| struct | is_fixed_point |
Unary type trait: true if T is an instantiation of toy::math::fixed, false otherwise. More... | |
| struct | is_fixed_point< fixed< Base, Intermediate, Fraction, Rounding > > |
| class | Point |
| 2D integer point for UI and input coordinates. More... | |
| class | Vector2 |
| 2D vector with floating-point or fixed-point components for positions, movement, and physics. More... | |
Concepts | |
| concept | FractionalConstantType |
| Type that can be used with toy::math::constants variable templates. | |
| concept | ValidFixedPointTypes |
| Concept constraining template parameters for toy::math::fixed. | |
| concept | fixed_point |
| Concept satisfied when T is an instantiation of toy::math::fixed. | |
| concept | PointScalar |
| Concept satisfied when T is a signed integral, floating-point, or fixed-point type. | |
| concept | Vector2Component |
| Concept satisfied when T is a component type allowed as toy::math::Vector2 template parameter. | |
Typedefs | |
| using | real_t = float |
| Floating‑point scalar type. | |
Functions | |
| template<typename Base, typename Intermediate, unsigned Fraction, bool Rounding> | |
| constexpr fixed< Base, Intermediate, Fraction, Rounding > | operator- (const fixed< Base, Intermediate, Fraction, Rounding > &value) noexcept |
| Unary minus: returns the negation of a toy::math::fixed value. | |
| template<typename Base, typename Intermediate, unsigned Fraction, bool Rounding, bool OtherRounding> | |
| constexpr fixed< Base, Intermediate, Fraction, Rounding > | operator+ (const fixed< Base, Intermediate, Fraction, Rounding > &a, const fixed< Base, Intermediate, Fraction, OtherRounding > &b) noexcept |
| Returns a + b as a new toy::math::fixed (same type as left operand). | |
| template<typename Base, typename Intermediate, unsigned Fraction, bool Rounding, typename T> | |
| constexpr fixed< Base, Intermediate, Fraction, Rounding > | operator+ (const fixed< Base, Intermediate, Fraction, Rounding > &a, const T &b) noexcept |
| Returns a + b as a new toy::math::fixed (fixed plus integral whole units). | |
| template<typename Base, typename Intermediate, unsigned Fraction, bool Rounding, typename T> | |
| constexpr fixed< Base, Intermediate, Fraction, Rounding > | operator+ (const T &a, const fixed< Base, Intermediate, Fraction, Rounding > &b) noexcept |
| Returns a + b as a new toy::math::fixed (integral whole units plus fixed). | |
| template<typename Base, typename Intermediate, unsigned Fraction, bool Rounding, bool OtherRounding> | |
| constexpr fixed< Base, Intermediate, Fraction, Rounding > | operator- (const fixed< Base, Intermediate, Fraction, Rounding > &a, const fixed< Base, Intermediate, Fraction, OtherRounding > &b) noexcept |
| Returns a - b as a new toy::math::fixed (same type as left operand). | |
| template<typename Base, typename Intermediate, unsigned Fraction, bool Rounding, typename T> | |
| constexpr fixed< Base, Intermediate, Fraction, Rounding > | operator- (const fixed< Base, Intermediate, Fraction, Rounding > &a, const T &b) noexcept |
| Returns a - b as a new toy::math::fixed (fixed minus integral whole units). | |
| template<typename Base, typename Intermediate, unsigned Fraction, bool Rounding, typename T> | |
| constexpr fixed< Base, Intermediate, Fraction, Rounding > | operator- (const T &a, const fixed< Base, Intermediate, Fraction, Rounding > &b) noexcept |
| Returns a - b as a new toy::math::fixed (integral whole units minus fixed). | |
| template<typename Base, typename Intermediate, unsigned Fraction, bool Rounding, bool OtherRounding> | |
| constexpr fixed< Base, Intermediate, Fraction, Rounding > | operator* (const fixed< Base, Intermediate, Fraction, Rounding > &a, const fixed< Base, Intermediate, Fraction, OtherRounding > &b) noexcept |
| Returns a * b as a new toy::math::fixed (same type as left toy::math::fixed operand). | |
| template<typename Base, typename Intermediate, unsigned Fraction, bool Rounding, typename T> | |
| constexpr fixed< Base, Intermediate, Fraction, Rounding > | operator* (const fixed< Base, Intermediate, Fraction, Rounding > &a, const T &b) noexcept |
| Returns a * b as a new toy::math::fixed (fixed times integral whole units). | |
| template<typename Base, typename Intermediate, unsigned Fraction, bool Rounding, typename T> | |
| constexpr fixed< Base, Intermediate, Fraction, Rounding > | operator* (const T &a, const fixed< Base, Intermediate, Fraction, Rounding > &b) noexcept |
| Returns a * b as a new toy::math::fixed (integral whole units times fixed). | |
| template<typename Base, typename Intermediate, unsigned Fraction, bool Rounding, bool OtherRounding> | |
| constexpr fixed< Base, Intermediate, Fraction, Rounding > | operator/ (const fixed< Base, Intermediate, Fraction, Rounding > &a, const fixed< Base, Intermediate, Fraction, OtherRounding > &b) noexcept |
| Returns a / b as a new toy::math::fixed. | |
| template<typename Base, typename Intermediate, unsigned Fraction, bool Rounding, typename T> | |
| constexpr fixed< Base, Intermediate, Fraction, Rounding > | operator/ (const fixed< Base, Intermediate, Fraction, Rounding > &a, const T &b) noexcept |
| Returns a / b as a new toy::math::fixed (fixed divided by integral whole units). | |
| template<typename Base, typename Intermediate, unsigned Fraction, bool Rounding, typename T> | |
| constexpr fixed< Base, Intermediate, Fraction, Rounding > | operator/ (const T &a, const fixed< Base, Intermediate, Fraction, Rounding > &b) noexcept |
| Returns a / b as a new toy::math::fixed (integral whole units divided by fixed). | |
| template<typename Base, typename Intermediate, unsigned Fraction, bool Rounding, bool OtherRounding> | |
| constexpr bool | operator== (const fixed< Base, Intermediate, Fraction, Rounding > &a, const fixed< Base, Intermediate, Fraction, OtherRounding > &b) noexcept |
| Compares two toy::math::fixed values for equality. | |
| template<typename Base, typename Intermediate, unsigned Fraction, bool Rounding, integral T> | |
| constexpr bool | operator== (const fixed< Base, Intermediate, Fraction, Rounding > &a, const T &b) noexcept |
| Compares a toy::math::fixed value with an integral for equality. | |
| template<typename Base, typename Intermediate, unsigned Fraction, bool Rounding, integral T> | |
| constexpr bool | operator== (const T &a, const fixed< Base, Intermediate, Fraction, Rounding > &b) noexcept |
| Compares an integral with a toy::math::fixed value for equality. | |
| template<typename Base, typename Intermediate, unsigned Fraction, bool Rounding, bool OtherRounding> | |
| constexpr strong_ordering | operator<=> (const fixed< Base, Intermediate, Fraction, Rounding > &a, const fixed< Base, Intermediate, Fraction, OtherRounding > &b) noexcept |
| Three-way comparison of two toy::math::fixed values. | |
| template<typename Base, typename Intermediate, unsigned Fraction, bool Rounding, integral T> | |
| constexpr strong_ordering | operator<=> (const fixed< Base, Intermediate, Fraction, Rounding > &a, const T &b) noexcept |
| Three-way comparison of a toy::math::fixed value with an integral. | |
| template<typename Base, typename Intermediate, unsigned Fraction, bool Rounding, integral T> | |
| constexpr strong_ordering | operator<=> (const T &a, const fixed< Base, Intermediate, Fraction, Rounding > &b) noexcept |
| Three-way comparison of an integral with a toy::math::fixed value. | |
| constexpr Point | operator- (const Point &point) noexcept |
| Unary minus: negated coordinates. | |
| constexpr Point | operator+ (const Point &left, const Point &right) noexcept |
| Addition of two points. | |
| constexpr Point | operator- (const Point &left, const Point &right) noexcept |
| Subtraction of two points. | |
| template<PointScalar T> | |
| constexpr Point | operator* (const Point &point, const T &scalar) noexcept |
| Point scaled by scalar and truncated to integer. | |
| template<PointScalar T> | |
| constexpr Point | operator* (const T &scalar, const Point &point) noexcept |
| Point scaled by scalar (scalar on the left). | |
| template<PointScalar T> | |
| constexpr Point | operator/ (const Point &point, const T &scalar) noexcept |
| Point divided by scalar and truncated to integer. | |
| constexpr bool | operator== (const Point &left, const Point &right) noexcept |
| Exact equality of two points. | |
| template<typename T> | |
| constexpr T | abs (const T &value) noexcept |
| Returns the absolute value of value. | |
| template<typename T> | |
| constexpr bool | isEqual (const T &a, const T &b, T absEpsilon=8 *numeric_limits< T >::epsilon(), T relEpsilon=64 *numeric_limits< T >::epsilon()) noexcept |
| Compares two values for approximate equality. | |
| template<typename T> | |
| constexpr T | deg2rad (const T &angle) noexcept |
| Converts angle from degrees to radians. | |
| template<typename T> | |
| constexpr T | rad2deg (const T &angle) noexcept |
| Converts angle from radians to degrees. | |
| template<Vector2Component T> | |
| constexpr Vector2< T > | operator- (const Vector2< T > &vector) noexcept |
| Unary minus: negated components. | |
| template<Vector2Component T> | |
| constexpr Vector2< T > | operator+ (const Vector2< T > &left, const Vector2< T > &right) noexcept |
| Addition of two vectors. | |
| template<Vector2Component T> | |
| constexpr Vector2< T > | operator- (const Vector2< T > &left, const Vector2< T > &right) noexcept |
| Subtraction of two vectors. | |
| template<Vector2Component T> | |
| constexpr Vector2< T > | operator* (const Vector2< T > &left, const T &right) noexcept |
| Vector scaled by scalar. | |
| template<Vector2Component T> | |
| constexpr Vector2< T > | operator* (const T &left, const Vector2< T > &right) noexcept |
| Vector scaled by scalar (scalar on the left). | |
| template<Vector2Component T> | |
| constexpr T | operator* (const Vector2< T > &left, const Vector2< T > &right) noexcept |
| Dot product of two vectors. | |
| template<Vector2Component T> | |
| constexpr Vector2< T > | operator/ (const Vector2< T > &left, const T &right) noexcept |
| Vector divided by scalar. | |
| template<Vector2Component T> | |
| constexpr bool | operator== (const Vector2< T > &left, const Vector2< T > &right) noexcept |
| Exact equality of two vectors. | |
| template<Vector2Component T> | |
| constexpr bool | operator!= (const Vector2< T > &left, const Vector2< T > &right) noexcept |
| Inequality of two vectors. | |
| template<Vector2Component T> | |
| constexpr T | cross (const Vector2< T > &left, const Vector2< T > &right) noexcept |
| 2D cross product (scalar result). | |
| template<Vector2Component T> | |
| Vector2 (const T &, const T &) -> Vector2< T > | |
Deduction guide: enables Vector2(x, y) without an explicit template argument when both arguments have the same toy::math::Vector2Component type. | |
Variables | |
| template<typename T> | |
| constexpr bool | is_fixed_point_v = is_fixed_point<T>::value |
Helper variable template: true if T is toy::math::fixed, false otherwise. | |
Mathematical types, constants, and utilities: fixed-point, vectors, point.
| using toy::math::real_t = float |
Floating‑point scalar type.
|
nodiscardconstexprnoexcept |
2D cross product (scalar result).
| left | First operand. |
| right | Second operand. |
|
nodiscardconstexprnoexcept |
Inequality of two vectors.
| left | First operand. |
| right | Second operand. |
true if !(left == right).
|
nodiscardconstexprnoexcept |
Returns a * b as a new toy::math::fixed (same type as left toy::math::fixed operand).
| a | Left operand (fixed-point value). |
| b | Right operand (fixed-point value). |
|
nodiscardconstexprnoexcept |
Returns a * b as a new toy::math::fixed (fixed times integral whole units).
| a | Fixed-point value. |
| b | Integral value (whole units). |
|
nodiscardconstexprnoexcept |
Point scaled by scalar and truncated to integer.
| T | Type satisfying toy::math::PointScalar. |
| point | Point operand. |
| scalar | Scale factor. |
int32_t.
|
nodiscardconstexprnoexcept |
Returns a * b as a new toy::math::fixed (integral whole units times fixed).
| a | Integral value (whole units). |
| b | Fixed-point value. |
|
nodiscardconstexprnoexcept |
Vector scaled by scalar (scalar on the left).
| T | Component type satisfy toy::math::Vector2Component. |
| left | Scale factor. |
| right | Vector operand. |
|
nodiscardconstexprnoexcept |
Point scaled by scalar (scalar on the left).
| T | Type satisfying toy::math::PointScalar (signed integral, floating-point, or fixed-point). |
| scalar | Scale factor. |
| point | Point operand. |
int32_t.
|
nodiscardconstexprnoexcept |
Vector scaled by scalar.
| T | Component type satisfy toy::math::Vector2Component. |
| left | Vector operand. |
| right | Scale factor. |
|
nodiscardconstexprnoexcept |
Dot product of two vectors.
| left | First operand. |
| right | Second operand. |
|
nodiscardconstexprnoexcept |
Returns a + b as a new toy::math::fixed (same type as left operand).
b may be a toy::math::fixed with different rounding (OtherRounding) or an integral; the result uses Rounding of the toy::math::fixed operand.
| a | Left operand (fixed-point value). |
| b | Right operand (fixed-point or integral whole units). |
|
nodiscardconstexprnoexcept |
Returns a + b as a new toy::math::fixed (fixed plus integral whole units).
| a | Fixed-point value. |
| b | Integral value (whole units). |
Addition of two points.
| left | First operand. |
| right | Second operand. |
|
nodiscardconstexprnoexcept |
Returns a + b as a new toy::math::fixed (integral whole units plus fixed).
| a | Integral value (whole units). |
| b | Fixed-point value. |
|
nodiscardconstexprnoexcept |
Addition of two vectors.
| left | First operand. |
| right | Second operand. |
|
nodiscardconstexprnoexcept |
Returns a - b as a new toy::math::fixed (same type as left operand).
| a | Left operand (fixed-point value). |
| b | Right operand (fixed-point value). |
|
nodiscardconstexprnoexcept |
Returns a - b as a new toy::math::fixed (fixed minus integral whole units).
| a | Fixed-point value. |
| b | Integral value (whole units). |
|
nodiscardconstexprnoexcept |
Unary minus: returns the negation of a toy::math::fixed value.
The result has the same raw storage as value with sign flipped. The operand is not modified.
| value | Fixed-point value to negate. |
-value. Subtraction of two points.
| left | First operand. |
| right | Second operand. |
Unary minus: negated coordinates.
| point | Operand. |
|
nodiscardconstexprnoexcept |
Returns a - b as a new toy::math::fixed (integral whole units minus fixed).
| a | Integral value (whole units). |
| b | Fixed-point value. |
|
nodiscardconstexprnoexcept |
Subtraction of two vectors.
| left | First operand. |
| right | Second operand. |
|
nodiscardconstexprnoexcept |
Unary minus: negated components.
| vector | Operand. |
|
nodiscardconstexprnoexcept |
Returns a / b as a new toy::math::fixed.
Behavior is undefined if b is zero.
| a | Dividend (fixed-point value). |
| b | Divisor (fixed-point value, must not be zero). |
|
nodiscardconstexprnoexcept |
Returns a / b as a new toy::math::fixed (fixed divided by integral whole units).
Behavior is undefined if b is zero.
| a | Dividend (fixed-point value). |
| b | Divisor (integral, must not be zero). |
|
nodiscardconstexprnoexcept |
Point divided by scalar and truncated to integer.
| T | Type satisfying toy::math::PointScalar (signed integral, floating-point, or fixed-point). |
| point | Point operand. |
| scalar | Divisor. |
int32_t.0.
|
nodiscardconstexprnoexcept |
Returns a / b as a new toy::math::fixed (integral whole units divided by fixed).
Behavior is undefined if b is zero.
| a | Dividend (integral value). |
| b | Divisor (fixed-point value, must not be zero). |
|
nodiscardconstexprnoexcept |
Vector divided by scalar.
| T | Component type satisfy toy::math::Vector2Component. |
| left | Vector operand. |
| right | Divisor. |
0.
|
nodiscardconstexprnoexcept |
Three-way comparison of two toy::math::fixed values.
Compares raw storage values; Rounding of either operand does not affect the result. Enables <, <=, >, >=, and != via the compiler-generated operators.
| Base | Storage type (shared by both operands). |
| Intermediate | Intermediate type (shared by both operands). |
| Fraction | Number of fractional bits (shared by both operands). |
| Rounding | Rounding policy of the left operand. |
| OtherRounding | Rounding policy of the right operand. |
| a | Left operand. |
| b | Right operand. |
strong_ordering::less if a is less than b, strong_ordering::equal if equal, strong_ordering::greater if a is greater than b.
|
nodiscardconstexprnoexcept |
Three-way comparison of a toy::math::fixed value with an integral.
Converts b to the same toy::math::fixed type and compares raw storage values. Enables <, <=, >, >=, and != for fixed and integral operands.
| Base | Storage type of the fixed operand. |
| Intermediate | Intermediate type of the fixed operand. |
| Fraction | Number of fractional bits of the fixed operand. |
| Rounding | Rounding policy of the fixed operand. |
| T | Integral type; must satisfy integral. |
| a | Left operand (fixed-point). |
| b | Right operand (integral whole units). |
strong_ordering::less if a is less than b, strong_ordering::equal if equal, strong_ordering::greater if a is greater than b.
|
nodiscardconstexprnoexcept |
Three-way comparison of an integral with a toy::math::fixed value.
Converts a to the same toy::math::fixed type as b and compares raw storage values. Enables <, <=, >, >=, and != for integral and fixed operands.
| Base | Storage type of the fixed operand. |
| Intermediate | Intermediate type of the fixed operand. |
| Fraction | Number of fractional bits of the fixed operand. |
| Rounding | Rounding policy of the fixed operand. |
| T | Integral type; must satisfy integral. |
| a | Left operand (integral whole units). |
| b | Right operand (fixed-point). |
strong_ordering::less if a is less than b, strong_ordering::equal if equal, strong_ordering::greater if a is greater than b.
|
nodiscardconstexprnoexcept |
Compares two toy::math::fixed values for equality.
Compares raw storage values; Rounding of either operand does not affect the result. Two values are equal if and only if their raw values are equal.
| Base | Storage type (shared by both operands). |
| Intermediate | Intermediate type (shared by both operands). |
| Fraction | Number of fractional bits (shared by both operands). |
| Rounding | Rounding policy of the left operand. |
| OtherRounding | Rounding policy of the right operand. |
| a | Left operand. |
| b | Right operand. |
true if a and b represent the same value, false otherwise.
|
nodiscardconstexprnoexcept |
Compares a toy::math::fixed value with an integral for equality.
Converts b to the same toy::math::fixed type and compares raw storage values. Two values are equal if and only if their raw values are equal.
| Base | Storage type of the fixed operand. |
| Intermediate | Intermediate type (shared). |
| Fraction | Number of fractional bits. |
| Rounding | Rounding policy of the fixed operand. |
| T | Integral type; must satisfy integral. |
| a | Left operand (fixed-point). |
| b | Right operand (integral whole units). |
true if a and b represent the same value, false otherwise. Exact equality of two points.
| left | First operand. |
| right | Second operand. |
true if left.x == right.x and left.y == right.y, false otherwise.
|
nodiscardconstexprnoexcept |
Compares an integral with a toy::math::fixed value for equality.
Converts a to the same toy::math::fixed type as b and compares raw storage values. Two values are equal if and only if their raw values are equal.
| Base | Storage type of the fixed operand. |
| Intermediate | Intermediate type (shared). |
| Fraction | Number of fractional bits. |
| Rounding | Rounding policy of the fixed operand. |
| T | Integral type; must satisfy integral. |
| a | Left operand (integral whole units). |
| b | Right operand (fixed-point). |
true if a and b represent the same value, false otherwise.
|
nodiscardconstexprnoexcept |
Exact equality of two vectors.
For floating-point T, delegates to isEqual() with default epsilons. For fixed-point T, compares raw storage of both components.
| left | First operand. |
| right | Second operand. |
true if isEqual(right) with default tolerances. For fixed-point T: true if left and right have equal raw component values.| toy::math::Vector2 | ( | const T & | , |
| const T & | ) -> Vector2< T > |
Deduction guide: enables Vector2(x, y) without an explicit template argument when both arguments have the same toy::math::Vector2Component type.
| T | Component type; must satisfy toy::math::Vector2Component. |
|
inlineconstexpr |
Helper variable template: true if T is toy::math::fixed, false otherwise.