Skip to content

Jondolf/quickhull-rs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Quickhull

A Rust implementation of the Quickhull algorithm for computing convex hulls for 2D and 3D point sets.

The Utah teapot and its convex hull

The Utah teapot and its convex hull

Implementation

The 2D implementation is based on geo, and uses the robust crate for robust geometric predicates. It should handle arbitrary point clouds without failure.

The 3D implementation is largely adapted from parry3d. It is designed to be very fast, while handling degenerate cases such as coplanar inputs reliably. Note that in some rare edge cases, it can still fail and return an error.

Only f32 vector types from glam are currently supported.

3D Example

use glam::Vec3A;
use quickhull::ConvexHull3d;

// Define a set of 3D points.
let points = vec![
    Vec3A::new(0.0, 0.0, 0.0),
    Vec3A::new(1.0, 0.0, 0.0),
    Vec3A::new(0.0, 1.0, 0.0),
    Vec3A::new(0.0, 0.0, 1.0),
];

// No limit on the number of iterations.
let max_iter = None;

// Compute the convex hull.
let hull = ConvexHull3d::try_from_points(&points, max_iter).unwrap();

// Get the vertices and indices of the convex hull.
let (vertices, indices) = hull.vertices_indices();

// The hull should be a tetrahedron with 4 vertices and 4 triangular faces.
assert_eq!(vertices.len(), 4);
assert_eq!(indices.len(), 4);

References

License

This Quickhull crate is free and open source. All code in this repository is dual-licensed under either:

at your option.

About

Convex hulls for 2D and 3D in Rust

Topics

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Releases

No releases published

Contributors 2

  •  
  •  

Languages