Skip to main content

Crate voronoid

Crate voronoid 

Source
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-bindgen for 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§

wall_2d
wall_3d
wasm

Structs§

Algorithm2DGrid
A spatial index based on a uniform grid for 2D space.
Algorithm3DGrid
A spatial index based on a uniform grid.
Algorithm3DOctree
A spatial partitioning structure based on an Octree.
BoundingBox
Generic bounding box for D-dimensional space.
Cell2D
A 2D Voronoi cell represented as a polygon.
Cell3DFaces
A Voronoi cell containing vertices and face information.
Tessellation
A geometry-based Voronoi tessellation that unifies the Cell, SpatialAlgorithm, and Wall traits.
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).
SpatialAlgorithm
Trait defining a spatial acceleration structure. This allows swapping between Grid, Octree, or Linear Octree algorithms.
WallGeometry
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.