I am not sure if this is a bug, by design, or just an intricacy of Python wrappers, but I have found a difference between VTK points depending on if they are created by passing in x, y, z coordinates, or by passing a 3 element array [x, y, z]. The first method gives a true double precision point as requested by SetDataTypeToDouble, where as the second method still results in a single precision point. I have fixed our code to ensure double precision, but I thought I would post it here for future reference.<div>
<br></div><div>Brett<br><div><br></div><div><div style><div style="font-family:arial,sans-serif"><font face="&#39;courier new&#39;, monospace">import vtk</font></div><div style="font-family:arial,sans-serif"><font face="&#39;courier new&#39;, monospace">vtk_points = vtk.vtkPoints()</font></div>
<div><font face="&#39;courier new&#39;, monospace">vtk_points.SetDataTypeToDouble()</font></div><div style="font-family:arial,sans-serif"><font face="&#39;courier new&#39;, monospace">e = [0.0, 0.0065, 0.0]</font></div><div style="font-family:arial,sans-serif">
<font face="&#39;courier new&#39;, monospace"><br></font></div><div style="font-family:arial,sans-serif"><font face="&#39;courier new&#39;, monospace"># pass in the point using its individual components</font></div><div style="font-family:arial,sans-serif">
<font face="&#39;courier new&#39;, monospace">e1_id = vtk_points.</font><span style="font-family:&#39;courier new&#39;,monospace">InsertNextPoint(e[0], e[1], e[2])</span></div><div style="font-family:arial,sans-serif"><font face="&#39;courier new&#39;, monospace">p_e1 = vtk_points.GetPoint(e1_id)</font></div>
</div><div style><div><font face="&#39;courier new&#39;, monospace"><br class="Apple-interchange-newline"># pass in the point as an array</font></div><div><font face="&#39;courier new&#39;, monospace">e2_id = vtk_points.InsertNextPoint(e)</font></div>
<div><font face="&#39;courier new&#39;, monospace">p_e2 = vtk_points.GetPoint(e2_id)</font></div></div><div style><font face="&#39;courier new&#39;, monospace"><br></font></div><div style><font face="&#39;courier new&#39;, monospace"># check the difference between the two methods<br>
</font></div><div style><font face="&#39;courier new&#39;, monospace">print p_e1, p_e2</font></div><div style><font face="&#39;courier new&#39;, monospace">print (</font><span style="font-family:&#39;courier new&#39;,monospace">p_</span><font face="&#39;courier new&#39;, monospace">e1[0] - p_e2[0]), (</font><span style="font-family:&#39;courier new&#39;,monospace">p_</span><font face="&#39;courier new&#39;, monospace">e1[1] - p_e2[1]), (</font><span style="font-family:&#39;courier new&#39;,monospace">p_</span><span style="font-family:&#39;courier new&#39;,monospace">e1[2] - p_e2[2])</span></div>
<div style><font face="&#39;courier new&#39;, monospace"><br></font></div><div style><font face="&#39;courier new&#39;, monospace"># gives</font></div><div style><font face="&#39;courier new&#39;, monospace" style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px"># </font><span style="background-color:transparent"><font color="#222222" face="&#39;courier new&#39;, monospace">(0.0, 0.0065, 0.0) (0.0, 0.006500000134110451, 0.0)</font></span></div>
<div style><font face="&#39;courier new&#39;, monospace" style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px"># </font><span style="background-color:transparent"><font color="#222222" face="&#39;courier new&#39;, monospace">0.0 -1.34110451043e-10 0.0</font></span></div>
<br><div class="gmail_quote">On Tue, Apr 3, 2012 at 1:43 PM, David Gobbi <span dir="ltr">&lt;<a href="mailto:david.gobbi@gmail.com" target="_blank">david.gobbi@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi Brett,<br>
<br>
The default type of vtkPoints is &quot;float&quot;.  If you need more precision,<br>
then you can change the precision to &quot;double&quot;:<br>
<br>
vtk_points = vtk.vtkPoints()<br>
vtk_points.SetDataTypeToDouble()<br>
<br>
This is true in both C++ and Python.<br>
<span class="HOEnZb"><font color="#888888"><br>
 - David<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
<br>
On Tue, Apr 3, 2012 at 6:22 AM, Brett Tully &lt;<a href="mailto:brett.tully@oxyntix.com">brett.tully@oxyntix.com</a>&gt; wrote:<br>
&gt; Dear all,<br>
&gt;<br>
&gt; I am finding that vtkPoints.InsertNextPoint when called from python does not<br>
&gt; return a point where I want it -- it seems to be out by ~1e-10 -- is there a<br>
&gt; way to set the tolerance of this function or improve its location to be more<br>
&gt; precise than 1e-10? Or is this due to python floats?<br>
&gt;<br>
&gt; Thanks,<br>
&gt; Brett.<br>
&gt;<br>
&gt; I.e. the following python:<br>
&gt;<br>
&gt; import vtk<br>
&gt; vtk_points = vtk.vtkPoints()<br>
&gt; e = [0.0, 0.0065, 0.0]<br>
&gt; e_id = vtk_points.InsertNextPoint(*e)<br>
&gt; p_e = vtk_points.GetPoint(e_id)<br>
&gt; print p_e, e<br>
&gt; print (e[0] - p_e[0]), (e[1] - p_e[1]), (e[2] - p_e[2])<br>
&gt;<br>
&gt; # gives<br>
&gt; # (0.0, 0.006500000134110451, 0.0) [0.0, 0.0065, 0.0]<br>
&gt; # 0.0 -1.34110451043e-10 0.0<br>
</div></div></blockquote></div><br></div></div>