Theon is a Rust library that abstracts Euclidean spaces.
Geometric Traits
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 |
Spatial Queries
Geometric queries can be performed using any types that implement that appropriate geometric traits.
use Point2;
use crate;
use crate;
use crateConverged;
type E2 = ;
let aabb = ;
let ray = ;
assert_eq!;
assert_eq!;
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.