使用 vtkKdTree 搜索最近邻(最近点)

问题描述 投票:0回答:0

我正在使用 vtk 的 kdtree 来搜索最近点,这是一个简单的例子,令我惊讶的是,返回的值不是我所期望的

import vtk

points = vtk.vtkPoints()
points.InsertNextPoint(1, 0, 0)
points.InsertNextPoint(0, 1, 0)
points.InsertNextPoint(0, 0, 1)

kdtree = vtk.vtkKdTree()
kdtree.BuildLocatorFromPoints(points)

dist=vtk.reference(0.0)
p = kdtree.FindClosestPoint(0,0,10,dist)

print(p,dist)

打印出来的结果是

0 4.0
,我期望的值是
2 81
(返回的dist是实际距离的平方)

python algorithm vtk kdtree
© www.soinside.com 2019 - 2024. All rights reserved.