[vtkusers] Distance between points
Matias Montroull
matimontg at gmail.com
Tue Jan 14 18:18:49 EST 2014
Hi,
I'm running this code and I get distance "infinity"... If I change to lower
values (1 digit) then it gives a distance..
Why?
double[] p0 = new double[] { 10.2, 20.7, 10.4 };
double[] p1 = new double[] { 10.5, 20.5, 10.8};
IntPtr pP0 = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(double)) * 3);
IntPtr pP1 = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(double)) * 3);
Marshal.Copy(p0, 0, pP0, 3);
Marshal.Copy(p1, 0, pP1, 3);
// Find the squared distance between the points.
double squaredDistance = vtkMath.Distance2BetweenPoints(pP0, pP1);
// Take the square root to get the Euclidean distance between the points.
double distance = Math.Sqrt(squaredDistance);
// Output the results.
Console.WriteLine("SquaredDistance = " + squaredDistance);
Console.WriteLine("Distance = " + distance);
Marshal.FreeHGlobal(pP0);
Marshal.FreeHGlobal(pP1);
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20140114/39ea884f/attachment.html>
More information about the vtkusers
mailing list