<div dir="ltr">Hi,<div><br></div><div>I'm running this code and I get distance "infinity"... If I change to lower values (1 digit) then it gives a distance..</div><div>Why?</div><div><br></div><div><div> double[] p0 = new double[] { 10.2, 20.7, 10.4 };</div>
<div> double[] p1 = new double[] { 10.5, 20.5, 10.8};</div><div> </div><div> IntPtr pP0 = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(double)) * 3);</div><div> IntPtr pP1 = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(double)) * 3);</div>
<div> Marshal.Copy(p0, 0, pP0, 3);</div><div> Marshal.Copy(p1, 0, pP1, 3);</div><div> </div><div> // Find the squared distance between the points.</div><div> double squaredDistance = vtkMath.Distance2BetweenPoints(pP0, pP1);</div>
<div> </div><div> // Take the square root to get the Euclidean distance between the points.</div><div> double distance = Math.Sqrt(squaredDistance);</div><div> </div><div> // Output the results.</div><div> Console.WriteLine("SquaredDistance = " + squaredDistance);</div>
<div> Console.WriteLine("Distance = " + distance);</div><div> Marshal.FreeHGlobal(pP0);</div><div> Marshal.FreeHGlobal(pP1);</div></div></div>