我正在尝试使用 cKDTree query
找到最接近某个点的三角形平面。
我已经知道要找到离该点最近的邻居。示例:
from scipy.spatial import cKDTree
import numpy as np
p1 = np.array([0, 0, 0])
p2 = np.array([[100, 100, 100],
[670, 500, 890],
[666, 456, 765]])
tuple_dist_neighbor = cKDTree(p2).query(p1)
print(tuple_dist_neighbor) # prints (173.20508075688772, 0)
所以 return
值是到最近邻居的距离和最近邻居的索引的元组。
现在假设我有两个三角形,每个三角形由 3 个点组成。示例:
triangle1 = np.array([[0, 0, 0],
[0, 4, 0],
[4, 0, 4]])
triangle2 = np.array([[100, 100, 100],
[100, 140, 100],
[140, 100, 140]])
triangle_set = np.array([triangle1, triangle2])
point = np.array([10, 11, 12])
所以我想知道是否可以像上面一样使用 cKDTree 找到最接近该点的三角形。
我正在处理的三角形正在形成一个网格。
Picture 1: Mesh formed of triangles
真正的问题是在这个网格中找到最接近一个点的三角形。