[vtkusers] Distance between 2 points in millimeters (mm)
dominique at toepfer-web.de
Thu Aug 9 12:47:08 EDT 2012
I think these lines in the for-loop are wrong:
You seem to calculate the distance between the same two points in every
iteration. You need to use i instead of num here.
On 09.08.2012 18:34, Concetta Piazzese wrote:
> Hy everyone. I hope somebody can help me!
> I need to find the distance between 2 points in millimeters like the
> vtkDistanceWidget does. An user places 10 points and then the program
> compute the distances. The problem is that I have an array of
> vtkPoints and I can't use vtkDistanceWidget to find the distances. How
> I can find the distance? The points positions are inglobal coordinate
> values. The distance I got are totally wrong. Here is my code:
> int main(int argc, char *argv)
> //Points Placement with vtkSeedWidget. Poins are stored in a
> vtkPoints called "points"
> double punto;
> double punto2;
> int num=points->GetNumberOfPoints();
> for (int i=0; i<num; i++)
> double squaredDistance;
> double dist;
> // Distance
> squaredDistance = vtkMath::Distance2BetweenPoints(punto, punto2);
> std::cout << "Distance " << dist << std::endl;
> return EXIT_SUCCESS;
> What's the problem? vtkDistanceWidget computes distances using
> vtkMath::Distance2BetweenPoints. So what am I doing wrong?
> Thank you!
> Powered by www.kitware.com
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
> Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
> Follow this link to subscribe/unsubscribe:
Dominique Töpfer, Dipl.-Inform.
Institute of Medical Physics
University of Erlangen
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the vtkusers