[vtkusers] Distance between 2 points in millimeters (mm)
Concetta Piazzese
aliens30586 at hotmail.it
Thu Aug 9 12:34:42 EDT 2012
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[])
{
reader->SetFileName("C:/Tesi/DistanceBetween2Points_build/Debug/Data/Plaque_08.mhd");
reader->Update();
imgconn=reader->GetOutput();
//Points Placement with vtkSeedWidget. Poins are stored in a vtkPoints called "points"
Seed();
double punto[3];
double punto2[3];
int num=points->GetNumberOfPoints();
for (int i=0; i<num; i++)
{
points->GetPoint(num-1,punto);
points->GetPoint(num,punto2);
double squaredDistance;
double dist;
// Distance
squaredDistance = vtkMath::Distance2BetweenPoints(punto, punto2);
dist=sqrt(squaredDistance);
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!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20120809/2ba07993/attachment.htm>
More information about the vtkusers
mailing list