我使用scipy的ConvexHull类为一组点构造一个凸壳。我感兴趣的是一种计算新点到凸壳的最小距离的方法。在
在互联网的帮助下,我自己稍作调整,就想出了一个公式来计算一个点p或一组点点到凸包面的距离:
np.max(np.dot(self.equations[:, :-1], points.T).T + self.equations[:, -1], axis=-1)
对于2D中的凸面外壳,上述方程将得出以下曲线图:
如您所见,对于凸壳内的点,结果非常好且正确(此处的距离为负值,需要乘以-1)。对于离壳最近的点是不正确的,但对于离壳最近的点也是正确的。(我用虚线标记了这些区域)对于这些点,正确的最小距离是到凸壳顶点的最小距离。在
如何区分最接近面或最接近顶点的点,以正确计算n维空间(至少3D)中点p或一组点点到凸包的最小距离?在
如果凸包的点被指定为NX2数组,并且该点被给定为p=[x,y]
相关问题 更多 >
编程相关推荐