Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In scipy's ConvexHull, what does "area" measure?

The value of the "area" attribute in scipy ConvexHull (see http://docs.scipy.org/doc/scipy/reference/generated/scipy.spatial.ConvexHull.html) object does not seem to be (what I understand to be) the area of the convex hull. On the other hand, the value of "volume" does seem to be the area of the convex hull.

from scipy.spatial import ConvexHull
import numpy

points = numpy.array([[-1,-1], [1,1], [-1, 1], [1,-1]])
hull = ConvexHull(points)

print("Volume is %2.2f" % hull.volume) # Prints 4.00
print("Area is %2.2f" % hull.area) # Prints 8.00

In the above example, I expect the area of the convex hull of the 4 points to be 4.0. That's what the "volume" is. What then does "area" give us?

like image 583
mjandrews Avatar asked Feb 27 '16 01:02

mjandrews


People also ask

What is convex hull area?

The area enclosed by the rubber band is called the convex hull of P P P. This leads to an alternative definition of the convex hull of a finite set P P P of points in the plane: it is the unique convex polygon whose vertices are points from P P P and which contains all points of P P P.

How do you find the area of a convex hull in Python?

You could just use the ConvexHull class from scipy. spatial . It will not only give you the hull's area, but it will compute the hull for you as well.

What is convex hull in Python?

Hull means the exterior or the shape of the object. Therefore, the Convex Hull of a shape or a group of points is a tight fitting convex boundary around the points or the shape. The Convex Hull of the two shapes in Figure 1 is shown in Figure 2. The Convex Hull of a convex object is simply its boundary.

What Scipy spatial?

scipy. spatial can compute triangulations, Voronoi diagrams, and convex hulls of a set of points, by leveraging the Qhull library. Moreover, it contains KDTree implementations for nearest-neighbor point queries, and utilities for distance computations in various metrics.


1 Answers

Volume and area are 3d concepts, but your data is 2d - a 2x2 square. Its area is 4, and perimeter is 8 (the 2d counterparts).

like image 96
hpaulj Avatar answered Oct 06 '22 00:10

hpaulj