Expand description
Provides foundational mathematics primitives for 2D and 3D.
This module contains a comprehensive set of types and functions for linear algebra and geometry, forming the mathematical backbone of the Khora Engine. It includes vectors, matrices, quaternions, and various utility functions designed for performance and ease of use.
All angular functions in this module operate in radians by default, unless
explicitly specified otherwise (e.g., degrees_to_radians
).
Re-exports§
pub use self::color::LinearRgba;
pub use self::dimension::Extent1D;
pub use self::dimension::Extent2D;
pub use self::dimension::Extent3D;
pub use self::dimension::Origin2D;
pub use self::dimension::Origin3D;
pub use self::geometry::Aabb;
pub use self::matrix::Mat3;
pub use self::matrix::Mat4;
pub use self::quaternion::Quaternion;
pub use self::vector::Vec2;
pub use self::vector::Vec3;
pub use self::vector::Vec4;
Modules§
- 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
andMat4
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.
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.