Skip to content

Computational geometry algorithms from scratch in Rust.

License

Notifications You must be signed in to change notification settings

adamconkey/geometer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Geometer

Implementations of computational geometry algorithms from scratch in Rust.

BUILD TEST CLIPPY

🚧👷‍♂️ 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.


Features

Currently Supported for 2D Polygons

  • 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)

On the Roadmap

  • Convex Hull (2D and 3D)
  • Voronoi Diagram
  • Benchmarking of different algorithms
  • Animated visualizations of algorithms

Visualizer

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

Screen Shot 2025-02-15 at 3 31 57 PM

cargo run --features visualizer -- -v extreme-points -f interesting_polygon_archive -p skimage_horse

Screen Shot 2025-02-15 at 3 32 58 PM


Benchmarks

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 $O(n^3)$ versus computing them from interior points with triangle checks $O(n^4)$:

Screen Shot 2025-02-02 at 11 51 21 AM

These are both obviously bad algorithms, but they are what is implemented at the moment and provide some basis for comparison.


About

Computational geometry algorithms from scratch in Rust.

Resources

License

Stars

Watchers

Forks

Languages