Expand description
§voronoid
voronoid is a Rust library for D-dimensional Voronoi tessellations, designed to be used in Rust
as well as compiled to WebAssembly (WASM). It provides efficient management of 3D generator
points and spatial partitioning to facilitate fast cellular computations.
§Features
- WASM-first: Built with
wasm-bindgenfor seamless integration with JavaScript and TypeScript. - Spatial Partitioning: Implements a configurable grid-based binning strategy for spatial lookups.
- Dynamic Updates: Supports updating individual generators or bulk setting of points with automatic grid re-binning.
- Custom Walls: Support for clipping cells against various geometries (Plane, Sphere, Cylinder, Torus, Custom).
§Example
See the examples/ directory for usage with SVG plotting and GLTF export.
§Main Interface
The primary entry point is the Tessellation struct, which manages the grid and generators.
Modules§
Structs§
- Algorithm2D
Grid - A spatial index based on a uniform grid for 2D space.
- Algorithm3D
Grid - A spatial index based on a uniform grid.
- Algorithm3D
Octree - A spatial partitioning structure based on an Octree.
- Bounding
Box - Generic bounding box for D-dimensional space.
- Cell2D
- A 2D Voronoi cell represented as a polygon.
- Cell3D
Faces - A Voronoi cell containing vertices and face information.
- Tessellation
- A geometry-based Voronoi tessellation that unifies the
Cell,SpatialAlgorithm, andWalltraits. - Wall
- A clipping boundary for the Voronoi tessellation.
Constants§
- WALL_
ID_ MAX - The maximum ID for walls. Wall IDs must be less than or equal to this value to avoid conflicts with non-negative generator IDs and the bounding box IDs. The number of D-1 dimensional faces of a hypercube is 2*D so with walls starting at -1000 we allow for D < 500, which should be plenty.
Traits§
- Cell
- Trait defining the behavior of a Voronoi cell.
This allows swapping between simple Polygon cells (
Cell) and Graph-based cells (CellEdges). - Spatial
Algorithm - Trait defining a spatial acceleration structure. This allows swapping between Grid, Octree, or Linear Octree algorithms.
- Wall
Geometry - Trait defining the geometry and logic of a wall. Must be Send + Sync to support parallel execution in Tessellation.
Functions§
- box_
side - Calculates the ID for a bounding box wall based on the axis and direction.