symtropy-physics
N-dimensional rigid body physics with GJK+EPA collision detection. Zero heap allocation in the hot path.
use PhysicsWorld;
use ;
use SVector;
// Create a 3D world with gravity
let mut world = new;
// Add spheres
let a = world.add_sphere;
let b = world.add_sphere;
// Step the simulation
for _ in 0..100
// Spheres collided and bounced
Features
- GJK intersection test — 102ns for sphere×sphere (benchmarked)
- EPA penetration depth — accurate contact normals for 2D and 3D
- Coulomb friction — tangential impulse clamped by μ×j_n
- Body sleeping — deactivate near-stationary bodies, wake on collision
- Collision events —
CollisionEvent<D>for game logic callbacks - PhysicsCallback trait — inject consciousness or custom force modulation into the physics step
- Constraints — distance constraints (more coming)
- Const-generic dimensions —
PhysicsWorld<2>,PhysicsWorld<3>,PhysicsWorld<4> - Zero heap — GJK simplex uses
ArrayVec, bivectors use[f64; 6] - WASM compatible
Benchmarks
| Operation | Time |
|---|---|
| GJK sphere×sphere 3D | 102 ns |
| GJK box×box 3D | 193 ns |
| GJK tesseract 4D | 231 ns |
| Physics step (100 bodies) | 193 µs |
PhysicsCallback — Custom Force Modulation
use ;
;
world.step_with_callback;
Part of the Symtropy consciousness-physics engine.