Implementations of computational geometry algorithms from scratch in Rust.
🚧👷♂️ Work In Progress: This repos is under heavy development right now and just in its nascent stages.
Currently the algorithms are implemented following Joseph O'Rourke's Computational Geometry in C.
This is very much a work in progress, I'm just stepping through the text and implementing things as I go. I'm also a Rust newb so I'm frequently stumbling through the implementations, finding I made a terrible design decision, and going back to reimplement things. As such the API is in constant flux.
My goal for this repo is to eventually have a complete implementation of the algorithms described in the text, which will serve as the basis of a computational geometry library in Rust. I will then build from there, exploring more modern concepts and algorithms. My priorities are to have relatively easy-to-read code, a great test suite, and nice visualizations. I will have these three objectives in mind as I build out this repo.
- Area
- Triangulation -
$O(n^2)$ - Rotation and translation
- Bounding box computation
- Determination of extreme and interior points -
$O(n^3)$ and$O(n^4)$ (for benchmarking)
- Convex Hull (2D and 3D)
- Voronoi Diagram
- Benchmarking of different algorithms
- Animated visualizations of algorithms
A visualizer is provided using rerun.io. You must have the rerun
viewer installed for this to work, you can follow their instructions here. This method worked well for me:
cargo install rerun-cli --locked
Here are some example visualizations (add the -h
option for further CLI documentation):
cargo run --features visualizer -- -v triangulation -f interesting_polygon_archive -p skimage_horse
cargo run --features visualizer -- -v extreme-points -f interesting_polygon_archive -p skimage_horse
Some simple benchmarking capabilities are provided using Criterion.rs. These are mostly to provide empirical intuition on the runtime of algorithms. Currently only a couple benchmarks are setup, more will be added as more algorithms are implemented.
You can run the benchmarks yourself with
cargo bench --bench extreme_points --bench interior_points
Here is a visualization of one of the benchmarks to compute extreme points, comparing computing them from extreme edges
These are both obviously bad algorithms, but they are what is implemented at the moment and provide some basis for comparison.