| Crates.io | gravita-math |
| lib.rs | gravita-math |
| version | 0.1.0 |
| created_at | 2025-12-25 22:14:02.999737+00 |
| updated_at | 2025-12-25 22:14:02.999737+00 |
| description | Minimal 2D math primitives for game development and physics simulation |
| homepage | |
| repository | https://github.com/cantoramann/gravita |
| max_upload_size | |
| id | 2005000 |
| size | 97,474 |
Minimal 2D math primitives for game development and physics simulation.
Vec2 — 2D vector with full operator supportAABB — Axis-aligned bounding boxCircle — Circle primitiveRay2D — Ray for intersection testsTransform2D — Position + rotationuse gravita_math::{Vec2, AABB, Circle, lerp, clamp};
// Vector operations
let v = Vec2::new(3.0, 4.0);
assert_eq!(v.length(), 5.0);
assert_eq!(v.normalize().length(), 1.0);
// AABB operations
let box1 = AABB::from_center_size(Vec2::ZERO, Vec2::new(10.0, 10.0));
let box2 = AABB::from_center_size(Vec2::new(5.0, 0.0), Vec2::new(10.0, 10.0));
assert!(box1.intersects(&box2));
// Utility functions
let clamped = clamp(150.0, 0.0, 100.0); // 100.0
let interpolated = lerp(0.0, 100.0, 0.5); // 50.0
MIT OR Apache-2.0