Infinity Engine v0.6.20
C++ API Documentation
Loading...
Searching...
No Matches
Infinity::Types::Math Namespace Reference

Classes

class  Ramp
 Interpolated gradient for smoothly transitioning between values. More...
 
struct  Rect
 Axis-aligned rectangle defined by left, right, top, and bottom edges. More...
 
struct  Stop
 Represents a control point in a gradient or interpolation ramp. More...
 
struct  t_Matrix3
 Template structure representing a 3x3 matrix. More...
 
struct  t_Matrix4
 Template structure representing a 4x4 matrix. More...
 
struct  t_Vector2
 Template structure representing a 2-component vector. More...
 
struct  t_Vector3
 Template structure representing a 3-component vector. More...
 
struct  t_Vector4
 Template structure representing a 4-component vector. More...
 

Typedefs

using Matrix3 = t_Matrix3< float >
 Alias for t_Matrix3<float>, single-precision 3x3 matrix.
 
using Matrix3d = t_Matrix3< double >
 Alias for t_Matrix3<double>, double-precision 3x3 matrix.
 
using Matrix4 = t_Matrix4< float >
 Alias for t_Matrix4<float>, single-precision 4x4 matrix.
 
using Matrix4d = t_Matrix4< double >
 Alias for t_Matrix4<double>, double-precision 4x4 matrix.
 
using ValueRamp = Ramp< float >
 Alias for Ramp<float>, a scalar interpolation curve.
 
using Value2Ramp = Ramp< Vector2 >
 Alias for Ramp<Vector2>, a 2D vector interpolation curve.
 
using Value3Ramp = Ramp< Vector3 >
 Alias for Ramp<Vector3>, a 3D vector interpolation curve.
 
using Value4Ramp = Ramp< Vector4 >
 Alias for Ramp<Vector4>, a 4D vector interpolation curve.
 
using ValueStop = Stop< float >
 Alias for Stop<float>, a scalar gradient control point.
 
using Value2Stop = Stop< Vector2 >
 Alias for Stop<Vector2>, a 2D vector gradient control point.
 
using Value3Stop = Stop< Vector3 >
 Alias for Stop<Vector3>, a 3D vector gradient control point.
 
using Value4Stop = Stop< Vector4 >
 Alias for Stop<Vector4>, a 4D vector gradient control point.
 
using Vector2 = t_Vector2< float >
 Alias for t_Vector2<float>, the default 2D vector type.
 
using Vector2f = t_Vector2< float >
 Alias for t_Vector2<float>, single-precision floating-point vector.
 
using Vector2d = t_Vector2< double >
 Alias for t_Vector2<double>, double-precision floating-point vector.
 
using Vector2b = t_Vector2< int8_t >
 Alias for t_Vector2<int8_t>, signed 8-bit integer vector.
 
using Vector2s = t_Vector2< int16_t >
 Alias for t_Vector2<int16_t>, signed 16-bit integer vector.
 
using Vector2i = t_Vector2< int32_t >
 Alias for t_Vector2<int32_t>, signed 32-bit integer vector.
 
using Vector2l = t_Vector2< int64_t >
 Alias for t_Vector2<int64_t>, signed 64-bit integer vector.
 
using Vector2ub = t_Vector2< uint8_t >
 Alias for t_Vector2<uint8_t>, unsigned 8-bit integer vector.
 
using Vector2us = t_Vector2< uint16_t >
 Alias for t_Vector2<uint16_t>, unsigned 16-bit integer vector.
 
using Vector2ui = t_Vector2< uint32_t >
 Alias for t_Vector2<uint32_t>, unsigned 32-bit integer vector.
 
using Vector2ul = t_Vector2< uint64_t >
 Alias for t_Vector2<uint64_t>, unsigned 64-bit integer vector.
 
using Vector3 = t_Vector3< float >
 Alias for t_Vector3<float>, the default 3D vector type.
 
using Vector3f = t_Vector3< float >
 Alias for t_Vector3<float>, single-precision floating-point vector.
 
using Vector3d = t_Vector3< double >
 Alias for t_Vector3<double>, double-precision floating-point vector.
 
using Vector3b = t_Vector3< int8_t >
 Alias for t_Vector3<int8_t>, signed 8-bit integer vector.
 
using Vector3s = t_Vector3< int16_t >
 Alias for t_Vector3<int16_t>, signed 16-bit integer vector.
 
using Vector3i = t_Vector3< int32_t >
 Alias for t_Vector3<int32_t>, signed 32-bit integer vector.
 
using Vector3l = t_Vector3< int64_t >
 Alias for t_Vector3<int64_t>, signed 64-bit integer vector.
 
using Vector3ub = t_Vector3< uint8_t >
 Alias for t_Vector3<uint8_t>, unsigned 8-bit integer vector.
 
using Vector3us = t_Vector3< uint16_t >
 Alias for t_Vector3<uint16_t>, unsigned 16-bit integer vector.
 
using Vector3ui = t_Vector3< uint32_t >
 Alias for t_Vector3<uint32_t>, unsigned 32-bit integer vector.
 
using Vector3ul = t_Vector3< uint64_t >
 Alias for t_Vector3<uint64_t>, unsigned 64-bit integer vector.
 
using Vector4 = t_Vector4< float >
 Alias for t_Vector4<float>, the default 4D vector type.
 
using Quaternion = t_Vector4< float >
 Alias for t_Vector4<float>, used for representing rotations.
 
using Vector4f = t_Vector4< float >
 Alias for t_Vector4<float>, single-precision floating-point vector.
 
using Vector4d = t_Vector4< double >
 Alias for t_Vector4<double>, double-precision floating-point vector.
 
using Vector4b = t_Vector4< int8_t >
 Alias for t_Vector4<int8_t>, signed 8-bit integer vector.
 
using Vector4s = t_Vector4< int16_t >
 Alias for t_Vector4<int16_t>, signed 16-bit integer vector.
 
using Vector4i = t_Vector4< int32_t >
 Alias for t_Vector4<int32_t>, signed 32-bit integer vector.
 
using Vector4l = t_Vector4< int64_t >
 Alias for t_Vector4<int64_t>, signed 64-bit integer vector.
 
using Vector4ub = t_Vector4< uint8_t >
 Alias for t_Vector4<uint8_t>, unsigned 8-bit integer vector.
 
using Vector4us = t_Vector4< uint16_t >
 Alias for t_Vector4<uint16_t>, unsigned 16-bit integer vector.
 
using Vector4ui = t_Vector4< uint32_t >
 Alias for t_Vector4<uint32_t>, unsigned 32-bit integer vector.
 
using Vector4ul = t_Vector4< uint64_t >
 Alias for t_Vector4<uint64_t>, unsigned 64-bit integer vector.
 

Functions

constexpr float radians (float degrees)
 Converts degrees to radians (float).
 
constexpr double radians (double degrees)
 Converts degrees to radians (double).
 
constexpr float degrees (float radians)
 Converts radians to degrees (float).
 
constexpr double degrees (double radians)
 Converts radians to degrees (double).
 
float normalizeAngle (float angle)
 Normalizes an angle in radians to the range [-PI, PI].
 
double normalizeAngle (double angle)
 Normalizes an angle in radians to the range [-PI, PI] (double precision).
 
float normalizeAngleDegrees (float angle)
 Normalizes an angle in degrees to the range [-180, 180].
 
double normalizeAngleDegrees (double angle)
 Normalizes an angle in degrees to the range [-180, 180] (double precision).
 
Vector3 INFINITY_API_PUBLIC lerp (const Vector3 &a, const Vector3 &b, float t)
 Linear interpolation between two 3D vectors.
 
Vector3 INFINITY_API_PUBLIC mix (const Vector3 &a, const Vector3 &b, float t)
 Linear interpolation between two 3D vectors (alias for lerp).
 
Vector3 INFINITY_API_PUBLIC quatToEuler (Quaternion quat)
 Converts a quaternion to Euler angles.
 
Quaternion INFINITY_API_PUBLIC eulerToQuat (Vector3 euler)
 Converts Euler angles to a quaternion.
 
float INFINITY_API_PUBLIC smoothstep (float s1, float s2, float val)
 Smooth Hermite interpolation between two values.
 
template<typename T >
std::ostream & operator<< (std::ostream &out, const t_Matrix3< T > &m)
 Stream insertion operator for single-line text output.
 
template<typename T >
std::istream & operator>> (std::istream &in, t_Matrix3< T > &m)
 Stream extraction operator for single-line text input.
 
template<typename T >
std::ostream & operator<< (std::ostream &out, const t_Matrix4< T > &m)
 Stream insertion operator for single-line text output.
 
template<typename T >
std::istream & operator>> (std::istream &in, t_Matrix4< T > &m)
 Stream extraction operator for single-line text input.
 
constexpr bool operator== (const Rect &lhs, const Rect &rhs)
 Equality comparison operator.
 
constexpr bool operator!= (const Rect &lhs, const Rect &rhs)
 Inequality comparison operator.
 
constexpr Rect operator- (const Rect &lhs, const Rect &rhs)
 Rectangle subtraction operator.
 
constexpr Rect operator- (const Rect &v)
 Unary negation operator.
 
constexpr Rect operator+ (const Rect &lhs, const Rect &rhs)
 Rectangle addition operator.
 
std::ostream & operator<< (std::ostream &out, const Rect &r)
 Stream insertion operator for single-line text output.
 
std::istream & operator>> (std::istream &in, Rect &r)
 Stream extraction operator for single-line text input.
 
template<typename T >
std::ostream & operator<< (std::ostream &out, const Stop< T > &s)
 Stream insertion operator for single-line text output.
 
template<typename T >
std::istream & operator>> (std::istream &in, Stop< T > &s)
 Stream extraction operator for single-line text input.
 
template<typename T >
constexpr bool operator== (const t_Vector2< T > &lhs, const t_Vector2< T > &rhs)
 Equality comparison operator.
 
template<typename T >
constexpr bool operator!= (const t_Vector2< T > &lhs, const t_Vector2< T > &rhs)
 Inequality comparison operator.
 
template<typename T >
constexpr bool operator< (const t_Vector2< T > &lhs, const t_Vector2< T > &rhs)
 Less-than comparison operator for ordering.
 
template<typename T >
constexpr t_Vector2< T > operator- (const t_Vector2< T > &lhs, const t_Vector2< T > &rhs)
 Component-wise vector subtraction.
 
template<typename T >
constexpr t_Vector2< T > operator- (const t_Vector2< T > &v)
 Unary negation operator.
 
template<typename T >
constexpr t_Vector2< T > operator+ (const t_Vector2< T > &lhs, const t_Vector2< T > &rhs)
 Component-wise vector addition.
 
template<typename T >
constexpr t_Vector2< T > operator* (const t_Vector2< T > &lhs, T rhs)
 Scalar multiplication.
 
template<typename T >
constexpr t_Vector2< T > operator* (const t_Vector2< T > &lhs, const t_Vector2< T > &rhs)
 Component-wise vector multiplication.
 
template<typename T >
constexpr t_Vector2< T > operator/ (const t_Vector2< T > &lhs, T rhs)
 Scalar division.
 
template<typename T >
std::ostream & operator<< (std::ostream &out, const t_Vector2< T > &v)
 Stream insertion operator for single-line text output.
 
template<typename T >
std::istream & operator>> (std::istream &in, t_Vector2< T > &v)
 Stream extraction operator for single-line text input.
 
template<>
std::istream & operator>> (std::istream &in, t_Vector2< uint8_t > &v)
 Stream extraction specialization for uint8_t vectors.
 
template<typename T >
constexpr bool operator== (const t_Vector3< T > &lhs, const t_Vector3< T > &rhs)
 Equality comparison operator.
 
template<typename T >
constexpr bool operator!= (const t_Vector3< T > &lhs, const t_Vector3< T > &rhs)
 Inequality comparison operator.
 
template<typename T >
constexpr bool operator< (const t_Vector3< T > &lhs, const t_Vector3< T > &rhs)
 Less-than comparison operator for ordering.
 
template<typename T >
constexpr t_Vector3< T > operator- (const t_Vector3< T > &lhs, const t_Vector3< T > &rhs)
 Component-wise vector subtraction.
 
template<typename T >
constexpr t_Vector3< T > operator- (const t_Vector3< T > &v)
 Unary negation operator.
 
template<typename T >
constexpr t_Vector3< T > operator+ (const t_Vector3< T > &lhs, const t_Vector3< T > &rhs)
 Component-wise vector addition.
 
template<typename T >
constexpr t_Vector3< T > operator* (const t_Vector3< T > &lhs, T rhs)
 Scalar multiplication.
 
template<typename T >
constexpr t_Vector3< T > operator* (const t_Vector3< T > &lhs, const t_Vector3< T > &rhs)
 Component-wise vector multiplication.
 
template<typename T >
constexpr t_Vector3< T > operator/ (const t_Vector3< T > &lhs, T rhs)
 Scalar division.
 
template<typename T >
std::ostream & operator<< (std::ostream &out, const t_Vector3< T > &v)
 Stream insertion operator for single-line text output.
 
template<typename T >
std::istream & operator>> (std::istream &in, t_Vector3< T > &v)
 Stream extraction operator for single-line text input.
 
template<>
std::istream & operator>> (std::istream &in, t_Vector3< uint8_t > &v)
 Stream extraction specialization for uint8_t vectors.
 
template<typename T >
constexpr bool operator== (const t_Vector4< T > &lhs, const t_Vector4< T > &rhs)
 Equality comparison operator.
 
template<typename T >
constexpr bool operator!= (const t_Vector4< T > &lhs, const t_Vector4< T > &rhs)
 Inequality comparison operator.
 
template<typename T >
constexpr bool operator< (const t_Vector4< T > &lhs, const t_Vector4< T > &rhs)
 Less-than comparison operator for ordering.
 
template<typename T >
constexpr t_Vector4< T > operator- (const t_Vector4< T > &lhs, const t_Vector4< T > &rhs)
 Component-wise vector subtraction.
 
template<typename T >
constexpr t_Vector4< T > operator- (const t_Vector4< T > &v)
 Unary negation operator.
 
template<typename T >
constexpr t_Vector4< T > operator+ (const t_Vector4< T > &lhs, const t_Vector4< T > &rhs)
 Component-wise vector addition.
 
template<typename T >
constexpr t_Vector4< T > operator* (const t_Vector4< T > &lhs, T rhs)
 Scalar multiplication.
 
template<typename T >
constexpr t_Vector4< T > operator* (const t_Vector4< T > &lhs, const t_Vector4< T > &rhs)
 Component-wise vector multiplication.
 
template<typename T >
constexpr t_Vector4< T > operator/ (const t_Vector4< T > &lhs, T rhs)
 Scalar division.
 
template<typename T >
std::ostream & operator<< (std::ostream &out, const t_Vector4< T > &v)
 Stream insertion operator for single-line text output.
 
template<typename T >
std::istream & operator>> (std::istream &in, t_Vector4< T > &v)
 Stream extraction operator for single-line text input.
 
template<>
std::istream & operator>> (std::istream &in, t_Vector4< uint8_t > &v)
 Stream extraction specialization for uint8_t vectors.
 

Variables

constexpr float PI = 3.14159265358979323846f
 Mathematical constants.
 
constexpr float TWO_PI = 6.28318530717958647692f
 
constexpr float HALF_PI = 1.57079632679489661923f
 
constexpr float INV_PI = 0.31830988618379067154f
 
constexpr double PI_D = 3.14159265358979323846
 
constexpr double TWO_PI_D = 6.28318530717958647692
 
constexpr double HALF_PI_D = 1.57079632679489661923
 
constexpr double INV_PI_D = 0.31830988618379067154
 

Typedef Documentation

◆ Matrix3

Alias for t_Matrix3<float>, single-precision 3x3 matrix.

◆ Matrix3d

Alias for t_Matrix3<double>, double-precision 3x3 matrix.

◆ Matrix4

Alias for t_Matrix4<float>, single-precision 4x4 matrix.

The standard matrix type for 3D transformations in procedural generation and rendering pipelines.

◆ Matrix4d

Alias for t_Matrix4<double>, double-precision 4x4 matrix.

Used when higher precision is required for transformations, such as astronomical calculations or long transformation chains where error accumulation is a concern.

◆ Quaternion

Alias for t_Vector4<float>, used for representing rotations.

Quaternions provide a compact, efficient representation of 3D rotations that avoids gimbal lock. The components (x, y, z, w) represent the rotation axis scaled by sin(θ/2) and w is cos(θ/2), where θ is the rotation angle. A normalized quaternion (length = 1) represents a valid rotation.

◆ Value2Ramp

Alias for Ramp<Vector2>, a 2D vector interpolation curve.

Used for 2D transitions such as:

  • UV coordinate mappings
  • 2D position curves
  • 2-channel data gradients

◆ Value2Stop

Alias for Stop<Vector2>, a 2D vector gradient control point.

Used for 2D interpolation curves such as:

  • UV coordinate mappings
  • 2D position curves
  • 2-channel data transitions

◆ Value3Ramp

Alias for Ramp<Vector3>, a 3D vector interpolation curve.

Used for 3D transitions such as:

  • RGB color gradients
  • 3D position/direction curves
  • Normal vector transitions
  • Scale factor curves

◆ Value3Stop

Alias for Stop<Vector3>, a 3D vector gradient control point.

Used for 3D interpolation curves such as:

  • RGB color gradients
  • 3D position/direction curves
  • Normal vector transitions
  • Scale factor curves

◆ Value4Ramp

Alias for Ramp<Vector4>, a 4D vector interpolation curve.

Used for 4D transitions such as:

  • RGBA color gradients with alpha
  • Homogeneous coordinate curves
  • Quaternion interpolation curves

◆ Value4Stop

Alias for Stop<Vector4>, a 4D vector gradient control point.

Used for 4D interpolation curves such as:

  • RGBA color gradients with alpha
  • Homogeneous coordinate curves
  • Quaternion interpolation keyframes

◆ ValueRamp

Alias for Ramp<float>, a scalar interpolation curve.

Used for single-value transitions such as:

  • Height/elevation curves
  • Density falloffs
  • Alpha/opacity gradients
  • Scalar parameter animations

◆ ValueStop

Alias for Stop<float>, a scalar gradient control point.

Used for single-value interpolation curves such as:

  • Height/elevation curves
  • Density falloffs
  • Alpha/opacity transitions
  • Scalar parameter animations

◆ Vector2

Alias for t_Vector2<float>, the default 2D vector type.

◆ Vector2b

Alias for t_Vector2<int8_t>, signed 8-bit integer vector.

◆ Vector2d

Alias for t_Vector2<double>, double-precision floating-point vector.

◆ Vector2f

Alias for t_Vector2<float>, single-precision floating-point vector.

◆ Vector2i

Alias for t_Vector2<int32_t>, signed 32-bit integer vector.

◆ Vector2l

Alias for t_Vector2<int64_t>, signed 64-bit integer vector.

◆ Vector2s

Alias for t_Vector2<int16_t>, signed 16-bit integer vector.

◆ Vector2ub

Alias for t_Vector2<uint8_t>, unsigned 8-bit integer vector.

◆ Vector2ui

Alias for t_Vector2<uint32_t>, unsigned 32-bit integer vector.

◆ Vector2ul

Alias for t_Vector2<uint64_t>, unsigned 64-bit integer vector.

◆ Vector2us

Alias for t_Vector2<uint16_t>, unsigned 16-bit integer vector.

◆ Vector3

Alias for t_Vector3<float>, the default 3D vector type.

◆ Vector3b

Alias for t_Vector3<int8_t>, signed 8-bit integer vector.

◆ Vector3d

Alias for t_Vector3<double>, double-precision floating-point vector.

◆ Vector3f

Alias for t_Vector3<float>, single-precision floating-point vector.

◆ Vector3i

Alias for t_Vector3<int32_t>, signed 32-bit integer vector.

◆ Vector3l

Alias for t_Vector3<int64_t>, signed 64-bit integer vector.

◆ Vector3s

Alias for t_Vector3<int16_t>, signed 16-bit integer vector.

◆ Vector3ub

Alias for t_Vector3<uint8_t>, unsigned 8-bit integer vector.

◆ Vector3ui

Alias for t_Vector3<uint32_t>, unsigned 32-bit integer vector.

◆ Vector3ul

Alias for t_Vector3<uint64_t>, unsigned 64-bit integer vector.

◆ Vector3us

Alias for t_Vector3<uint16_t>, unsigned 16-bit integer vector.

◆ Vector4

Alias for t_Vector4<float>, the default 4D vector type.

◆ Vector4b

Alias for t_Vector4<int8_t>, signed 8-bit integer vector.

◆ Vector4d

Alias for t_Vector4<double>, double-precision floating-point vector.

◆ Vector4f

Alias for t_Vector4<float>, single-precision floating-point vector.

◆ Vector4i

Alias for t_Vector4<int32_t>, signed 32-bit integer vector.

◆ Vector4l

Alias for t_Vector4<int64_t>, signed 64-bit integer vector.

◆ Vector4s

Alias for t_Vector4<int16_t>, signed 16-bit integer vector.

◆ Vector4ub

Alias for t_Vector4<uint8_t>, unsigned 8-bit integer vector.

◆ Vector4ui

Alias for t_Vector4<uint32_t>, unsigned 32-bit integer vector.

◆ Vector4ul

Alias for t_Vector4<uint64_t>, unsigned 64-bit integer vector.

◆ Vector4us

Alias for t_Vector4<uint16_t>, unsigned 16-bit integer vector.

Function Documentation

◆ degrees() [1/2]

constexpr double Infinity::Types::Math::degrees ( double  radians)
inlineconstexpr

Converts radians to degrees (double).

Parameters
radiansAngle in radians.
Returns
Angle in degrees.

◆ degrees() [2/2]

constexpr float Infinity::Types::Math::degrees ( float  radians)
inlineconstexpr

Converts radians to degrees (float).

Parameters
radiansAngle in radians.
Returns
Angle in degrees.

◆ eulerToQuat()

Quaternion INFINITY_API_PUBLIC Infinity::Types::Math::eulerToQuat ( Vector3  euler)

Converts Euler angles to a quaternion.

Creates a quaternion representing the rotation specified by Euler angles. The input vector contains rotations in radians around the X, Y, and Z axes.

Parameters
eulerVector3 containing Euler angles in radians (x=pitch, y=yaw, z=roll).
Returns
Quaternion representing the rotation.
Note
The rotation order convention determines how the angles are applied. Different rotation orders (XYZ, ZYX, etc.) produce different results for the same angles.
Quaternions avoid gimbal lock and are more stable for animation and interpolation than Euler angles.
Vector3 euler(0, PI / 2, 0); // 90 degree rotation around Y axis
Quaternion rotation = eulerToQuat(euler);
Quaternion INFINITY_API_PUBLIC eulerToQuat(Vector3 euler)
Converts Euler angles to a quaternion.
constexpr float PI
Mathematical constants.
Definition Math.hpp:11
Template structure representing a 3-component vector.
Definition Vector3.hpp:82
Template structure representing a 4-component vector.
Definition Vector4.hpp:85

◆ lerp()

Vector3 INFINITY_API_PUBLIC Infinity::Types::Math::lerp ( const Vector3 a,
const Vector3 b,
float  t 
)

Linear interpolation between two 3D vectors.

Computes a + (b - a) * t, providing smooth linear blending between two vectors. When t = 0, returns a; when t = 1, returns b.

Common uses in procedural generation:

  • Smooth position transitions
  • Color blending
  • Animating procedural parameters
  • Gradient generation
Parameters
aStart vector (returned when t = 0).
bEnd vector (returned when t = 1).
tInterpolation parameter (typically 0-1, but any value is valid).
Returns
Interpolated vector.
Vector3 start(0, 0, 0);
Vector3 end(10, 10, 10);
Vector3 midpoint = lerp(start, end, 0.5f); // (5, 5, 5)
Vector3 extrapolated = lerp(start, end, 2.0f); // (20, 20, 20)
Vector3 INFINITY_API_PUBLIC lerp(const Vector3 &a, const Vector3 &b, float t)
Linear interpolation between two 3D vectors.

◆ mix()

Vector3 INFINITY_API_PUBLIC Infinity::Types::Math::mix ( const Vector3 a,
const Vector3 b,
float  t 
)

Linear interpolation between two 3D vectors (alias for lerp).

Identical to lerp(), provided for API consistency with GLSL naming conventions.

Parameters
aStart vector.
bEnd vector.
tInterpolation parameter.
Returns
Interpolated vector.
See also
lerp

◆ normalizeAngle() [1/2]

double Infinity::Types::Math::normalizeAngle ( double  angle)
inline

Normalizes an angle in radians to the range [-PI, PI] (double precision).

Parameters
angleAngle in radians.
Returns
Normalized angle in the range [-PI, PI].

◆ normalizeAngle() [2/2]

float Infinity::Types::Math::normalizeAngle ( float  angle)
inline

Normalizes an angle in radians to the range [-PI, PI].

Parameters
angleAngle in radians.
Returns
Normalized angle in the range [-PI, PI].

◆ normalizeAngleDegrees() [1/2]

double Infinity::Types::Math::normalizeAngleDegrees ( double  angle)
inline

Normalizes an angle in degrees to the range [-180, 180] (double precision).

Parameters
angleAngle in degrees.
Returns
Normalized angle in the range [-180, 180].

◆ normalizeAngleDegrees() [2/2]

float Infinity::Types::Math::normalizeAngleDegrees ( float  angle)
inline

Normalizes an angle in degrees to the range [-180, 180].

Parameters
angleAngle in degrees.
Returns
Normalized angle in the range [-180, 180].

◆ operator!=() [1/4]

constexpr bool Infinity::Types::Math::operator!= ( const Rect lhs,
const Rect rhs 
)
constexpr

Inequality comparison operator.

Parameters
lhsLeft rectangle.
rhsRight rectangle.
Returns
true if any edge differs.

◆ operator!=() [2/4]

template<typename T >
constexpr bool Infinity::Types::Math::operator!= ( const t_Vector2< T > &  lhs,
const t_Vector2< T > &  rhs 
)
constexpr

Inequality comparison operator.

Template Parameters
TComponent type.
Parameters
lhsLeft vector.
rhsRight vector.
Returns
true if any component differs.

◆ operator!=() [3/4]

template<typename T >
constexpr bool Infinity::Types::Math::operator!= ( const t_Vector3< T > &  lhs,
const t_Vector3< T > &  rhs 
)
constexpr

Inequality comparison operator.

Template Parameters
TComponent type.
Parameters
lhsLeft vector.
rhsRight vector.
Returns
true if any component differs.

◆ operator!=() [4/4]

template<typename T >
constexpr bool Infinity::Types::Math::operator!= ( const t_Vector4< T > &  lhs,
const t_Vector4< T > &  rhs 
)
constexpr

Inequality comparison operator.

Template Parameters
TComponent type.
Parameters
lhsLeft vector.
rhsRight vector.
Returns
true if any component differs.

◆ operator*() [1/6]

template<typename T >
constexpr t_Vector2< T > Infinity::Types::Math::operator* ( const t_Vector2< T > &  lhs,
const t_Vector2< T > &  rhs 
)
constexpr

Component-wise vector multiplication.

Template Parameters
TComponent type.
Parameters
lhsLeft vector.
rhsRight vector.
Returns
New vector with components (lhs * rhs).

◆ operator*() [2/6]

template<typename T >
constexpr t_Vector2< T > Infinity::Types::Math::operator* ( const t_Vector2< T > &  lhs,
rhs 
)
constexpr

Scalar multiplication.

Template Parameters
TComponent type.
Parameters
lhsVector.
rhsScalar.
Returns
New vector with each component multiplied by scalar.

◆ operator*() [3/6]

template<typename T >
constexpr t_Vector3< T > Infinity::Types::Math::operator* ( const t_Vector3< T > &  lhs,
const t_Vector3< T > &  rhs 
)
constexpr

Component-wise vector multiplication.

Template Parameters
TComponent type.
Parameters
lhsLeft vector.
rhsRight vector.
Returns
New vector with components (lhs * rhs).

◆ operator*() [4/6]

template<typename T >
constexpr t_Vector3< T > Infinity::Types::Math::operator* ( const t_Vector3< T > &  lhs,
rhs 
)
constexpr

Scalar multiplication.

Template Parameters
TComponent type.
Parameters
lhsVector.
rhsScalar.
Returns
New vector with each component multiplied by scalar.

◆ operator*() [5/6]

template<typename T >
constexpr t_Vector4< T > Infinity::Types::Math::operator* ( const t_Vector4< T > &  lhs,
const t_Vector4< T > &  rhs 
)
constexpr

Component-wise vector multiplication.

Template Parameters
TComponent type.
Parameters
lhsLeft vector.
rhsRight vector.
Returns
New vector with components (lhs * rhs).

◆ operator*() [6/6]

template<typename T >
constexpr t_Vector4< T > Infinity::Types::Math::operator* ( const t_Vector4< T > &  lhs,
rhs 
)
constexpr

Scalar multiplication.

Template Parameters
TComponent type.
Parameters
lhsVector.
rhsScalar.
Returns
New vector with each component multiplied by scalar.

◆ operator+() [1/4]

constexpr Rect Infinity::Types::Math::operator+ ( const Rect lhs,
const Rect rhs 
)
constexpr

Rectangle addition operator.

Adds edges element-wise.

Parameters
lhsLeft rectangle.
rhsRight rectangle.
Returns
New rectangle with (lhs edges + rhs edges).

◆ operator+() [2/4]

template<typename T >
constexpr t_Vector2< T > Infinity::Types::Math::operator+ ( const t_Vector2< T > &  lhs,
const t_Vector2< T > &  rhs 
)
constexpr

Component-wise vector addition.

Template Parameters
TComponent type.
Parameters
lhsLeft vector.
rhsRight vector.
Returns
New vector with components (lhs + rhs).

◆ operator+() [3/4]

template<typename T >
constexpr t_Vector3< T > Infinity::Types::Math::operator+ ( const t_Vector3< T > &  lhs,
const t_Vector3< T > &  rhs 
)
constexpr

Component-wise vector addition.

Template Parameters
TComponent type.
Parameters
lhsLeft vector.
rhsRight vector.
Returns
New vector with components (lhs + rhs).

◆ operator+() [4/4]

template<typename T >
constexpr t_Vector4< T > Infinity::Types::Math::operator+ ( const t_Vector4< T > &  lhs,
const t_Vector4< T > &  rhs 
)
constexpr

Component-wise vector addition.

Template Parameters
TComponent type.
Parameters
lhsLeft vector.
rhsRight vector.
Returns
New vector with components (lhs + rhs).

◆ operator-() [1/8]

constexpr Rect Infinity::Types::Math::operator- ( const Rect lhs,
const Rect rhs 
)
constexpr

Rectangle subtraction operator.

Subtracts edges element-wise.

Parameters
lhsLeft rectangle.
rhsRight rectangle.
Returns
New rectangle with (lhs edges - rhs edges).

◆ operator-() [2/8]

constexpr Rect Infinity::Types::Math::operator- ( const Rect v)
constexpr

Unary negation operator.

Returns a rectangle with all edges negated.

Parameters
vRectangle to negate.
Returns
New rectangle with negated edges.

◆ operator-() [3/8]

template<typename T >
constexpr t_Vector2< T > Infinity::Types::Math::operator- ( const t_Vector2< T > &  lhs,
const t_Vector2< T > &  rhs 
)
constexpr

Component-wise vector subtraction.

Template Parameters
TComponent type.
Parameters
lhsLeft vector.
rhsRight vector.
Returns
New vector with components (lhs - rhs).

◆ operator-() [4/8]

template<typename T >
constexpr t_Vector2< T > Infinity::Types::Math::operator- ( const t_Vector2< T > &  v)
constexpr

Unary negation operator.

Template Parameters
TComponent type.
Parameters
vVector to negate.
Returns
New vector with negated components.

◆ operator-() [5/8]

template<typename T >
constexpr t_Vector3< T > Infinity::Types::Math::operator- ( const t_Vector3< T > &  lhs,
const t_Vector3< T > &  rhs 
)
constexpr

Component-wise vector subtraction.

Template Parameters
TComponent type.
Parameters
lhsLeft vector.
rhsRight vector.
Returns
New vector with components (lhs - rhs).

◆ operator-() [6/8]

template<typename T >
constexpr t_Vector3< T > Infinity::Types::Math::operator- ( const t_Vector3< T > &  v)
constexpr

Unary negation operator.

Template Parameters
TComponent type.
Parameters
vVector to negate.
Returns
New vector with negated components.

◆ operator-() [7/8]

template<typename T >
constexpr t_Vector4< T > Infinity::Types::Math::operator- ( const t_Vector4< T > &  lhs,
const t_Vector4< T > &  rhs 
)
constexpr

Component-wise vector subtraction.

Template Parameters
TComponent type.
Parameters
lhsLeft vector.
rhsRight vector.
Returns
New vector with components (lhs - rhs).

◆ operator-() [8/8]

template<typename T >
constexpr t_Vector4< T > Infinity::Types::Math::operator- ( const t_Vector4< T > &  v)
constexpr

Unary negation operator.

Template Parameters
TComponent type.
Parameters
vVector to negate.
Returns
New vector with negated components.

◆ operator/() [1/3]

template<typename T >
constexpr t_Vector2< T > Infinity::Types::Math::operator/ ( const t_Vector2< T > &  lhs,
rhs 
)
constexpr

Scalar division.

For floating-point types, multiplies by reciprocal for better performance.

Template Parameters
TComponent type.
Parameters
lhsVector.
rhsScalar divisor.
Returns
New vector with each component divided by scalar.
Warning
Division by zero is undefined behavior.

◆ operator/() [2/3]

template<typename T >
constexpr t_Vector3< T > Infinity::Types::Math::operator/ ( const t_Vector3< T > &  lhs,
rhs 
)
constexpr

Scalar division.

For floating-point types, multiplies by reciprocal for better performance.

Template Parameters
TComponent type.
Parameters
lhsVector.
rhsScalar divisor.
Returns
New vector with each component divided by scalar.
Warning
Division by zero is undefined behavior.

◆ operator/() [3/3]

template<typename T >
constexpr t_Vector4< T > Infinity::Types::Math::operator/ ( const t_Vector4< T > &  lhs,
rhs 
)
constexpr

Scalar division.

For floating-point types, multiplies by reciprocal for better performance.

Template Parameters
TComponent type.
Parameters
lhsVector.
rhsScalar divisor.
Returns
New vector with each component divided by scalar.
Warning
Division by zero is undefined behavior.

◆ operator<() [1/3]

template<typename T >
constexpr bool Infinity::Types::Math::operator< ( const t_Vector2< T > &  lhs,
const t_Vector2< T > &  rhs 
)
constexpr

Less-than comparison operator for ordering.

Performs lexicographic comparison (compares x first, then y if x is equal). Useful for using vectors as keys in ordered containers like std::map.

Template Parameters
TComponent type.
Parameters
lhsLeft vector.
rhsRight vector.
Returns
true if lhs is lexicographically less than rhs.

◆ operator<() [2/3]

template<typename T >
constexpr bool Infinity::Types::Math::operator< ( const t_Vector3< T > &  lhs,
const t_Vector3< T > &  rhs 
)
constexpr

Less-than comparison operator for ordering.

Performs lexicographic comparison (compares x first, then y, then z if previous are equal). Useful for using vectors as keys in ordered containers like std::map.

Template Parameters
TComponent type.
Parameters
lhsLeft vector.
rhsRight vector.
Returns
true if lhs is lexicographically less than rhs.

◆ operator<() [3/3]

template<typename T >
constexpr bool Infinity::Types::Math::operator< ( const t_Vector4< T > &  lhs,
const t_Vector4< T > &  rhs 
)
constexpr

Less-than comparison operator for ordering.

Performs lexicographic comparison (compares x, then y, then z, then w if previous are equal). Useful for using vectors as keys in ordered containers like std::map.

Template Parameters
TComponent type.
Parameters
lhsLeft vector.
rhsRight vector.
Returns
true if lhs is lexicographically less than rhs.

◆ operator<<() [1/7]

std::ostream & Infinity::Types::Math::operator<< ( std::ostream &  out,
const Rect r 
)
inline

Stream insertion operator for single-line text output.

Outputs rectangle in format "l r t b" (space-separated edges).

Parameters
outOutput stream.
rRectangle to output.
Returns
Reference to output stream.

◆ operator<<() [2/7]

template<typename T >
std::ostream & Infinity::Types::Math::operator<< ( std::ostream &  out,
const Stop< T > &  s 
)
inline

Stream insertion operator for single-line text output.

Outputs stop in format "position value" where value uses its own stream insertion operator.

Template Parameters
TThe value type stored in the stop.
Parameters
outOutput stream.
sThe stop to output.
Returns
Reference to output stream.
ValueStop stop(0.5f, 1.0f);
std::cout << stop << std::endl; // Outputs: "0.5 1.0"
Value3Stop colorStop(0.25f, Vector3(1, 0, 0));
std::cout << colorStop << std::endl; // Outputs: "0.25 1 0 0"
t_Vector3< float > Vector3
Alias for t_Vector3<float>, the default 3D vector type.
Definition Vector3.hpp:580
Represents a control point in a gradient or interpolation ramp.
Definition Stop.hpp:64

◆ operator<<() [3/7]

template<typename T >
std::ostream & Infinity::Types::Math::operator<< ( std::ostream &  out,
const t_Matrix3< T > &  m 
)
inline

Stream insertion operator for single-line text output.

Outputs matrix as three space-separated column vectors.

Template Parameters
TElement type.
Parameters
outOutput stream.
mMatrix to output.
Returns
Reference to output stream.

◆ operator<<() [4/7]

template<typename T >
std::ostream & Infinity::Types::Math::operator<< ( std::ostream &  out,
const t_Matrix4< T > &  m 
)
inline

Stream insertion operator for single-line text output.

Outputs matrix as four space-separated column vectors.

Template Parameters
TElement type.
Parameters
outOutput stream.
mMatrix to output.
Returns
Reference to output stream.

◆ operator<<() [5/7]

template<typename T >
std::ostream & Infinity::Types::Math::operator<< ( std::ostream &  out,
const t_Vector2< T > &  v 
)
inline

Stream insertion operator for single-line text output.

Outputs vector in format "x y" (space-separated components).

Template Parameters
TComponent type.
Parameters
outOutput stream.
vVector to output.
Returns
Reference to output stream.

◆ operator<<() [6/7]

template<typename T >
std::ostream & Infinity::Types::Math::operator<< ( std::ostream &  out,
const t_Vector3< T > &  v 
)
inline

Stream insertion operator for single-line text output.

Outputs vector in format "x y z" (space-separated components).

Template Parameters
TComponent type.
Parameters
outOutput stream.
vVector to output.
Returns
Reference to output stream.

◆ operator<<() [7/7]

template<typename T >
std::ostream & Infinity::Types::Math::operator<< ( std::ostream &  out,
const t_Vector4< T > &  v 
)
inline

Stream insertion operator for single-line text output.

Outputs vector in format "x y z w" (space-separated components).

Template Parameters
TComponent type.
Parameters
outOutput stream.
vVector to output.
Returns
Reference to output stream.

◆ operator==() [1/4]

constexpr bool Infinity::Types::Math::operator== ( const Rect lhs,
const Rect rhs 
)
constexpr

Equality comparison operator.

Parameters
lhsLeft rectangle.
rhsRight rectangle.
Returns
true if all edges are equal.

◆ operator==() [2/4]

template<typename T >
constexpr bool Infinity::Types::Math::operator== ( const t_Vector2< T > &  lhs,
const t_Vector2< T > &  rhs 
)
constexpr

Equality comparison operator.

Template Parameters
TComponent type.
Parameters
lhsLeft vector.
rhsRight vector.
Returns
true if all components are equal.

◆ operator==() [3/4]

template<typename T >
constexpr bool Infinity::Types::Math::operator== ( const t_Vector3< T > &  lhs,
const t_Vector3< T > &  rhs 
)
constexpr

Equality comparison operator.

Template Parameters
TComponent type.
Parameters
lhsLeft vector.
rhsRight vector.
Returns
true if all components are equal.

◆ operator==() [4/4]

template<typename T >
constexpr bool Infinity::Types::Math::operator== ( const t_Vector4< T > &  lhs,
const t_Vector4< T > &  rhs 
)
constexpr

Equality comparison operator.

Template Parameters
TComponent type.
Parameters
lhsLeft vector.
rhsRight vector.
Returns
true if all components are equal.

◆ operator>>() [1/10]

std::istream & Infinity::Types::Math::operator>> ( std::istream &  in,
Rect r 
)
inline

Stream extraction operator for single-line text input.

Reads rectangle in format "l r t b" (space-separated edges).

Parameters
inInput stream.
rRectangle to read into.
Returns
Reference to input stream.

◆ operator>>() [2/10]

template<typename T >
std::istream & Infinity::Types::Math::operator>> ( std::istream &  in,
Stop< T > &  s 
)
inline

Stream extraction operator for single-line text input.

Reads stop in format "position value" where value uses its own stream extraction operator.

Template Parameters
TThe value type stored in the stop.
Parameters
inInput stream.
sThe stop to read into.
Returns
Reference to input stream.
ValueStop stop;
std::istringstream input("0.5 1.0");
input >> stop; // stop now has position=0.5, value=1.0

◆ operator>>() [3/10]

template<typename T >
std::istream & Infinity::Types::Math::operator>> ( std::istream &  in,
t_Matrix3< T > &  m 
)
inline

Stream extraction operator for single-line text input.

Reads matrix as three space-separated column vectors.

Template Parameters
TElement type.
Parameters
inInput stream.
mMatrix to read into.
Returns
Reference to input stream.

◆ operator>>() [4/10]

template<typename T >
std::istream & Infinity::Types::Math::operator>> ( std::istream &  in,
t_Matrix4< T > &  m 
)
inline

Stream extraction operator for single-line text input.

Reads matrix as four space-separated column vectors.

Template Parameters
TElement type.
Parameters
inInput stream.
mMatrix to read into.
Returns
Reference to input stream.

◆ operator>>() [5/10]

template<typename T >
std::istream & Infinity::Types::Math::operator>> ( std::istream &  in,
t_Vector2< T > &  v 
)
inline

Stream extraction operator for single-line text input.

Reads vector in format "x y" (space-separated components).

Template Parameters
TComponent type.
Parameters
inInput stream.
vVector to read into.
Returns
Reference to input stream.

◆ operator>>() [6/10]

template<>
std::istream & Infinity::Types::Math::operator>> ( std::istream &  in,
t_Vector2< uint8_t > &  v 
)
inline

Stream extraction specialization for uint8_t vectors.

Reads components as integers first to avoid stream treating them as characters, then converts to uint8_t.

Parameters
inInput stream.
vVector to read into.
Returns
Reference to input stream.

◆ operator>>() [7/10]

template<typename T >
std::istream & Infinity::Types::Math::operator>> ( std::istream &  in,
t_Vector3< T > &  v 
)
inline

Stream extraction operator for single-line text input.

Reads vector in format "x y z" (space-separated components).

Template Parameters
TComponent type.
Parameters
inInput stream.
vVector to read into.
Returns
Reference to input stream.

◆ operator>>() [8/10]

template<>
std::istream & Infinity::Types::Math::operator>> ( std::istream &  in,
t_Vector3< uint8_t > &  v 
)
inline

Stream extraction specialization for uint8_t vectors.

Reads components as integers first to avoid stream treating them as characters, then converts to uint8_t.

Parameters
inInput stream.
vVector to read into.
Returns
Reference to input stream.

◆ operator>>() [9/10]

template<typename T >
std::istream & Infinity::Types::Math::operator>> ( std::istream &  in,
t_Vector4< T > &  v 
)
inline

Stream extraction operator for single-line text input.

Reads vector in format "x y z w" (space-separated components).

Template Parameters
TComponent type.
Parameters
inInput stream.
vVector to read into.
Returns
Reference to input stream.

◆ operator>>() [10/10]

template<>
std::istream & Infinity::Types::Math::operator>> ( std::istream &  in,
t_Vector4< uint8_t > &  v 
)
inline

Stream extraction specialization for uint8_t vectors.

Reads components as integers first to avoid stream treating them as characters, then converts to uint8_t. This is particularly useful when reading RGBA color values in the range 0-255.

Parameters
inInput stream.
vVector to read into.
Returns
Reference to input stream.

◆ quatToEuler()

Vector3 INFINITY_API_PUBLIC Infinity::Types::Math::quatToEuler ( Quaternion  quat)

Converts a quaternion to Euler angles.

Extracts the rotation represented by a quaternion and converts it to Euler angles (pitch, yaw, roll). The returned vector contains rotations in radians around the X, Y, and Z axes respectively.

Parameters
quatQuaternion to convert (should be normalized).
Returns
Vector3 containing Euler angles in radians (x=pitch, y=yaw, z=roll).
Note
Euler angles suffer from gimbal lock at certain orientations (when pitch is ±90 degrees). For general rotation manipulation, quaternions are preferred.
The returned angles follow a specific rotation order convention (typically XYZ or ZYX depending on implementation).
Quaternion rotation(0, 0, 0, 1); // Identity rotation
Vector3 euler = quatToEuler(rotation); // (0, 0, 0)
Vector3 INFINITY_API_PUBLIC quatToEuler(Quaternion quat)
Converts a quaternion to Euler angles.

◆ radians() [1/2]

constexpr double Infinity::Types::Math::radians ( double  degrees)
inlineconstexpr

Converts degrees to radians (double).

Parameters
degreesAngle in degrees.
Returns
Angle in radians.

◆ radians() [2/2]

constexpr float Infinity::Types::Math::radians ( float  degrees)
inlineconstexpr

Converts degrees to radians (float).

Parameters
degreesAngle in degrees.
Returns
Angle in radians.

◆ smoothstep()

float INFINITY_API_PUBLIC Infinity::Types::Math::smoothstep ( float  s1,
float  s2,
float  val 
)

Smooth Hermite interpolation between two values.

Provides smooth easing between s1 and s2 based on val, using the Hermite polynomial (3t² - 2t³). This creates smooth transitions with zero velocity at the endpoints, useful for creating natural-looking curves and gradients.

When val ≤ s1, returns 0.0. When val ≥ s2, returns 1.0. Between s1 and s2, returns a smoothly interpolated value.

Common uses:

  • Smooth terrain transitions
  • Edge blending and falloffs
  • Easing functions for animation
  • Procedural noise smoothing
Parameters
s1Start threshold (returns 0 when val ≤ s1).
s2End threshold (returns 1 when val ≥ s2).
valInput value to remap.
Returns
Smoothly interpolated value in range [0, 1].
float transition = smoothstep(0.0f, 1.0f, 0.5f); // Returns ~0.5 (smooth)
float edge = smoothstep(0.4f, 0.6f, distance); // Smooth falloff
float INFINITY_API_PUBLIC smoothstep(float s1, float s2, float val)
Smooth Hermite interpolation between two values.

Variable Documentation

◆ HALF_PI

constexpr float Infinity::Types::Math::HALF_PI = 1.57079632679489661923f
constexpr

◆ HALF_PI_D

constexpr double Infinity::Types::Math::HALF_PI_D = 1.57079632679489661923
constexpr

◆ INV_PI

constexpr float Infinity::Types::Math::INV_PI = 0.31830988618379067154f
constexpr

◆ INV_PI_D

constexpr double Infinity::Types::Math::INV_PI_D = 0.31830988618379067154
constexpr

◆ PI

constexpr float Infinity::Types::Math::PI = 3.14159265358979323846f
constexpr

Mathematical constants.

◆ PI_D

constexpr double Infinity::Types::Math::PI_D = 3.14159265358979323846
constexpr

◆ TWO_PI

constexpr float Infinity::Types::Math::TWO_PI = 6.28318530717958647692f
constexpr

◆ TWO_PI_D

constexpr double Infinity::Types::Math::TWO_PI_D = 6.28318530717958647692
constexpr