rustsim_geometry/lib.rs
1//! Geometric primitives and queries for rustsim.
2//!
3//! This crate is intentionally tiny and dependency-free. It provides:
4//!
5//! - [`Vec2`] and [`Vec3`] type aliases over `[f64; 2]` and `[f64; 3]` with
6//! free-function arithmetic in the [`vec2`] and [`vec3`] modules.
7//! - Axis-aligned bounding boxes [`Aabb2`], [`Aabb3`].
8//! - Segments [`Segment2`], [`Segment3`] with closest-point queries.
9//! - Rays [`Ray3`] and planes [`Plane3`] with ray-plane intersection.
10//! - Triangles [`Triangle3`] with closest-point and ray-triangle
11//! intersection (Möller–Trumbore).
12//! - Spheres [`Sphere3`] with sphere-vs-AABB / sphere-vs-triangle tests.
13//!
14//! All functions are `f64`. No `unsafe`. No external crates. No allocation
15//! in hot paths.
16
17#![deny(missing_docs)]
18
19pub mod aabb;
20pub mod ray;
21pub mod segment;
22pub mod sphere;
23pub mod triangle;
24pub mod vec2;
25pub mod vec3;
26
27pub use aabb::{Aabb2, Aabb3};
28pub use ray::{Plane3, Ray3};
29pub use segment::{Segment2, Segment3};
30pub use sphere::Sphere3;
31pub use triangle::Triangle3;
32pub use vec2::Vec2;
33pub use vec3::Vec3;
34
35/// Convenience re-exports.
36pub mod prelude {
37 pub use crate::aabb::{Aabb2, Aabb3};
38 pub use crate::ray::{Plane3, Ray3};
39 pub use crate::segment::{Segment2, Segment3};
40 pub use crate::sphere::Sphere3;
41 pub use crate::triangle::Triangle3;
42 pub use crate::vec2::Vec2;
43 pub use crate::vec3::Vec3;
44}