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