jw3126 / ConvexHulls2d.jl

Simple and lightweight convex hull in 2d
MIT License
2 stars 0 forks source link
2d convex convex-hull julia

ConvexHulls2d

Stable Dev Build Status Coverage

Zero dependency convex hulls in 2d.

Usage

using ConvexHulls2d
pts = [randn(2) for _ in 1:50]
h = CH.ConvexHull(pts)
CH.area(h)
CH.circumference(h)
CH.vertices(h) # corner points that span the convex hull
CH.indices(h)  # indices of the corner points as elements of pts

using GLMakie # requires >= julia 1.9

fap = scatter(first.(pts), last.(pts), label="points", color=:blue)
lines!(h, label="ConvexHull", color=:red)
scatter!(h, label="vertices", color=:red)
axislegend()
fap

image

Alternatives

There are many packages in julia capapable of computing convex hulls. Some examples are:

All of these packages offer much more than this package, however they are more heavy depependencies. Also this package is faster then most of them for small to medium numbers of points.