Ask Your Question

Revision history [back]

I'll expand on tmonteil's last comment: there is an interface to qhull included on scipy!

For example, this code computes the hull of a random set of 2D points:

import numpy as np
from scipy.spatial import ConvexHull
points = np.random.rand(30, 2)   # 30 random points in 2-D
hull = ConvexHull(points)

and this code plots it:

my_plot = point2d(points)
for simplex in hull.simplices:
    my_plot += line2d([points[v,:] for v in simplex])
my_plot

While this code computes the hull of a random set of 3D points:

import numpy as np
from scipy.spatial import ConvexHull
points = np.random.rand(30, 3)   # 30 random points in 3-D
hull = ConvexHull(points)

and this code plots it:

my_plot = point3d(points)
for simplex in hull.simplices:
    my_plot += line3d([points[simplex[-1],:]]+[points[v,:] for v in simplex])
my_plot