Theon is a Rust library that abstracts Euclidean spaces.
Theon provides geometric traits that abstract group theory, category theory, and linear algebra to model Euclidean spaces. These traits are not always mathematically rigorous, but this allows them to be implemented for many types.
Most features are limited to two- and three-dimensional Euclidean spaces, though traits tend to be generic with respect to dimensionality.
Theon uses a bring-your-own-types model, wherein a crate owner can use features of Theon by implementing certain traits for their types. Theon also provides optional implementations for commonly used crates in the Rust ecosystem, including cgmath, mint, and nalgebra. These implementations can be enabled using Cargo features.
| Feature | Default | Crate | Support |
|---------------------|---------|----------|----------|
| geometry-cgmath
| No | cgmath | Complete |
| geometry-mint
| No | mint | Partial |
| geometry-nalgebra
| Yes | nalgebra | Complete |
Geometric queries can be performed using any types that implement that appropriate geometric traits.
```rust use nalgebra::Point2;
use crate::query::{Aabb, Intersection, Ray, Unit}; use crate::space::{Basis, EuclideanSpace}; use crate::Converged;
type E2 = Point2
let aabb = Aabb::
In the above example, it is possible to replace the E2
type definition with
types from cgmath or any other type that
implements EuclideanSpace
and the necessary operational traits.