voronoid
Rust library for D-dimensional Voronoi tessellations, designed to be used in Rust as well as compiled to WebAssembly (with a TypeScript interface). It provides a flexible and feature-rich implementation to calculate the individual cells by a clipping procedure based on the generating points, the bounding box and possible walls. The tessellation struct takes a spatial algorithm to calculate the nearest neighbours efficiently and a cell struct which manages cell data and the clipping algorithm. The combination of spatial algorithm and cell can then be matched to the specific application and distribution of generators. A few interactive examples are shown below.
WebAssembly and TypeScript API
This library is designed to directly compile to WASM, using wasm-pack, and is compatible with TypeScript. The package is published on npm and can be installed with:
Consult the www folder for interactive examples and more details on how to use with TypeScript and in a web environment.
To build the project for web usage:
which can then be added as a local dependency. To prepare the generated package for publication on npm run the patch_npm_pkg script.
Usage & Documentation
The library, with documentation, can also be direclty used in Rust by installing it with:
For a small usage example we generate a Voronoi tessellation for a 3D box with randomly positioned generators and calculate the total volume.
use ;
Development
More information on the tests, benchmarks and examples is in their respective directories. They can be run by:
Contributing is highly appreciated via issues and pull requests.
License
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.