| Crates.io | geospec |
| lib.rs | geospec |
| version | 0.1.0 |
| created_at | 2025-09-21 16:51:52.688036+00 |
| updated_at | 2025-09-21 16:51:52.688036+00 |
| description | A geometry specification library for ECS-style simulations. Provides shape definitions (sphere, box, cylinder, etc.), dimension inference, and JSON serialization for physical objects. |
| homepage | |
| repository | https://github.com/JDPlumbing/geospec-rs |
| max_upload_size | |
| id | 1848950 |
| size | 31,125 |
geospec is a geometry specification library designed for ECS-style simulations.
It provides shape definitions, dimension inference, and JSON-friendly representations for physical objects.
Define common geometric shapes:
Infer missing properties:
Serialize/deserialize to JSON using serde_json.
Optimized for speed: most computations run in nanoseconds.
use geospec::shapes::Sphere;
use geospec::traits::ShapeSpec;
fn main() {
let sphere = Sphere { radius: 2.0 };
let json = sphere.as_json();
println!("Sphere as JSON: {}", json);
println!("Volume: {}", sphere.volume());
println!("Surface area: {}", sphere.surface_area());
}
Output:
Sphere as JSON: {"radius":2.0,"volume":33.510,"surface_area":50.265}
Volume: 33.510
Surface area: 50.265
Run with:
cargo bench
Typical performance (on a mid-range CPU):
Dual-licensed under either: