Varlor
Varlor

Reputation: 1471

Python: VTK Distance from points to vtkLineSource

I have the following problem. I create Tubes around vtkLineSource. Now i want to calculate the shortest distance of points or one point(point1) to the original line created by the different points. Is it possible to do that?

import vtk
point1=[10,10,10]
arr=[[1,2,3],[2,4,6],[4,8,12]]
linePoints = vtk.vtkPoints()
for i in arr:
    linePoints.InsertNextPoint(i)

line = vtk.vtkLineSource()
line.SetPoints(linePoints)
line.Update() 

Upvotes: 0

Views: 414

Answers (1)

tomj
tomj

Reputation: 1109

You know all the line segments (arr[0]-arr[1], arr[1]-arr[2] etc.), so you can compute the distance to each of them (there is a static method for it in vtkLine) and look which of those is the shortest.

Upvotes: 1

Related Questions