Crate math

Source
Expand description

Original, dependency-free scalar game mathematics.

Vectors use f32; angles are radians. Matrices are column-major and multiply column vectors. a * b applies b before a. Rotation is right-handed. Explicit try_* operations report degenerate inputs; unchecked normalization and inversion return NaNs instead of silently substituting another transform.

Modules§

affine
Checked, reusable affine point, vector and normal transformation.
curves
Checked cubic Bezier authoring with allocation-free, bounded tessellation.
deterministic
Explicit arithmetic for simulation that must avoid platform libm variation. These helpers do not make an entire game deterministic by themselves.
prelude
Frequently used types and constructor functions.
projection
Prepared, viewport-aware 3D projection and finite picking rays.
segments
Checked closest witnesses for finite 2D and 3D segments.

Structs§

BVec2
BVec3
BVec4
Color
Unpremultiplied RGBA floating-point channels. No implicit gamma conversion.
Mat4
Column-major 4x4 matrix acting on column vectors: translation * rotation * scale.
Quat
Quaternion stored as vector part (x,y,z) followed by scalar part w.
Rect
Axis-aligned 2D rectangle. Width and height should be nonnegative.
SwingTwist
Checked factorization of a rotation into swing * twist (twist acts first).
Vec2
Vec3
Vec4

Enums§

ColorError
Failure from checked color authoring or transfer conversion.
EulerRot
Intrinsic Euler rotations: XYZ(a,b,c) composes Rx(a) * Ry(b) * Rz(c).
MatrixError
Failure from a checked matrix operation. No fallback transform is substituted.

Traits§

Vec2Swizzles
Compatibility imports: common swizzles are inherent methods.
Vec3Swizzles
Vec4Swizzles

Functions§

vec2
vec3
vec4