Module math

Module math 

Source
Expand description

Math types and utilities.

Modules§

affine_transform
Affine transformations for 2D and 3D space.
color
Defines the LinearRgba color type and associated operations.
dimension
Provides structs for representing extents (sizes) and origins (offsets) in 1D, 2D, and 3D.
geometry
Provides geometric primitive shapes for spatial calculations.
matrix
Defines the Mat3 and Mat4 types and associated operations.
quaternion
Provides a Quaternion type for representing 3D rotations.
vector
Provides 2D, 3D, and 4D vector types and their associated operations.

Structs§

Aabb
Represents an Axis-Aligned Bounding Box (AABB).
AffineTransform
Represents a 3D affine transformation (translation, rotation, scale).
Extent1D
A one-dimensional extent, typically representing a width.
Extent2D
A two-dimensional extent, typically representing width and height.
Extent3D
A three-dimensional extent, representing width, height, and depth.
LinearRgba
Represents a color in a linear RGBA color space using f32 components.
Mat3
A 3x3 column-major matrix, typically used for 2D affine transformations (scale, rotation).
Mat4
A 4x4 column-major matrix, used for 3D affine transformations.
Origin2D
A two-dimensional origin, typically representing an (x, y) offset.
Origin3D
A three-dimensional origin, representing an (x, y, z) offset.
Quaternion
Represents a quaternion for efficient 3D rotations.
Vec2
A 2-dimensional vector with f32 components.
Vec3
A 3-dimensional vector with f32 components.
Vec4
A 4-dimensional vector with f32 components, often used for homogeneous coordinates.

Constants§

DEG_TO_RAD
The factor to convert degrees to radians (PI / 180.0).
E
Euler’s number (e)
EPSILON
A small constant for floating-point comparisons.
FRAC_PI_2
π/2
FRAC_PI_3
π/3
FRAC_PI_4
π/4
FRAC_PI_6
π/6
FRAC_PI_8
π/8
LN_2
ln(2)
LN_10
ln(10)
LOG2_E
log2(e)
LOG10_E
log10(e)
PI
Archimedes’ constant (π)
RAD_TO_DEG
The factor to convert radians to degrees (180.0 / PI).
SQRT_2
sqrt(2)
TAU
The full circle constant (τ)

Functions§

approx_eq
Performs an approximate equality comparison using the module’s default EPSILON.
approx_eq_eps
Performs an approximate equality comparison between two floats with a custom tolerance.
clamp
Clamps a value to a specified minimum and maximum range.
degrees_to_radians
Converts an angle from degrees to radians.
radians_to_degrees
Converts an angle from radians to degrees.
saturate
Clamps a floating-point value to the [0.0, 1.0] range.

Type Aliases§

Quat
Alias for Quaternion for brevity.