Python convex hull with scipy.spatial.Delaunay, how to count points inside a hull?

I have a list of 3D points in np.array named pointsList , float values:

 [[1., 2., 10.], [2., 0., 1.], [3., 6., 9.], [1., 1., 1.], [2., 2., 2.], [10., 0., 10.], [0., 10., 5.], ... etc. 

This code makes Delaney's triangulation a point cloud:

 import numpy as np import scipy.spatial tri = scipy.spatial.Delaunay(pointsList) # Delaunay triangulation indices = tri.simplices # indices of vertices vertices = points[indices] # the vertices for each tetrahedron 

However, before this step of triangulation, I would like to remove from my list all the points that are inside the convex hull

The solution would be to create a new np.array named shortlist and save them there.

But what function in scipy (or any other solution) will do this?

How can I program this operation?

thanks

+6
source share
1 answer

The convex hull is a subgraph of the Delaunay triangulation.

So you can just use scipy.spatial.ConvexHull() , e. g.

 from scipy.spatial import ConvexHull cv = ConvexHull(pointList) hull_points = cv.vertices # the vertices of the convex hull set(range(len(pointList))).difference(ch.vertices) # the vertices inside the convex hull 

Comparison of scipy.spatial.Delaunay and scipy.spatial.ConvexHull (2D)

enter image description here

+14
source

All Articles