gemath
gemath is a math crate for game/engine code that cares about making invalid math hard to write.
Instead of “just vectors and matrices”, gemath leans into type-level correctness:
- Type-level units (e.g.
Meters,Pixels) and type-level coordinate spaces (e.g.World,Local,Screen) are carried by core types:Vec*<Unit, Space>,Mat*<Unit, Space>,Quat<Unit, Space>, and friends. - Typed angles (
Radians/Degrees) are the default posture: rotation APIs take angle types, not “mysteryf32”. - Fallible operations are explicit: “can this fail?” shows up in the type (
Option) and in naming (try_*,checked_*), with a crate-wide policy.
If you like glam’s ergonomics but want the compiler to help you keep your spaces/units/angles straight, gemath is built for that.
The killer feature: Unit + Space tags that don’t get in your way
Use ()/() when you don’t care — or opt into safety by tagging your math:
use ;
let p_world: = new;
let p_screen: = new;
// let _oops = p_world + p_screen;
// ^ does not compile: different Unit and Space tags
Typed angles (Degrees/Radians) by default
use ;
let v: = new;
let v90 = v.rotate_deg;
assert!;
Geometry + collision helpers with structured “hit” results
use ;
let circle: = new;
let ray: = new;
let hit = ray2_circle_cast.unwrap;
assert!;
assert!;
assert!;
Docs for contributors (start here)
The developer docs live in docs/:
- Docs index:
docs/README.md - Feature flags / minimal builds:
docs/FEATURES.md - Build + test matrix:
docs/DEVELOPMENT.md - Copy/paste cookbook:
docs/COOKBOOK.md - API conventions:
docs/API_CONVENTIONS.md - Design notes (fallible ops, scalar policy, spatial prototypes):
docs/
no_std posture (real, tested)
gemath is designed so you can keep the “core math” tiny:
# minimal no_std build (no allocation)
For the full supported/tested matrix (including alloc, geometry, collision, spatial, serde, mint), see docs/DEVELOPMENT.md.