Plexus uses the [
theon] crate to abstract Euclidean spaces and support various types in the Rust ecosystem. [
theon] provides types and traits used to implement linear algebra and computational geometry without forcing dependent crates to use specific crates and types.
Mesh data structures like buffers and graphs can contain arbitrary data, including non-geometric data and no data at all. Geometric traits are not required, but it is recommended to use supported types when representing geometric data. For example, computing the normals of faces in a graph or subdividing polygons in an iterator expression can be done easily if these traits are implemented.
Enabling geometry Cargo features provides implementations of these traits for types from commonly used crates like [
cgmath] and [
nalgebra]. It is highly recommended to enable these features when using these crates.
Plexus provides conversions for geometric types to enable more ergonomic and flexible APIs. The
IntoGeometry traits are analogous to the standard
Into traits and perform a similar function, but are used for geometric types and allow Plexus to provide implementations for conversions that would violate coherence rules using
Conversions are optionally implemented via geometry Cargo features and include support for implicit scalar conversions of types from the [
AsPosition trait is re-exported from [
theon] in the
geometry module and allows types to expose positional data. When this positional data implements the appropriate traits, geometric APIs can be used. For example, this allows graphs to support splitting edges at midpoints, extruding faces along translation vectors, and flattening faces into a best-fit plane regardless of the choice of mathematics crate ([