[vtkusers] Issues with coordinate conversion, possible VTK bugs?

Bill Q bill.q.hdp at gmail.com
Fri May 19 11:20:45 EDT 2017


Hello Everyone,
I encountered a weird problem in coordinate conversion.

In order to check the accuracy, I converted from display to world, and from
world back to display. Using the following ways:


*self.world_picker = vtk.vtkWorldPointPicker()*

*def *display_to_world(self, pt):
    self.world_picker.Pick(pt[0], pt[1], 0, self.ren)
    picker_pt = self.world_picker.GetPickPosition()
    picker_pt = (picker_pt[0], picker_pt[1], 0)
    *return *picker_pt

*def *world_to_display(self, pt):
    *if *len(pt) == 3:
        pt = pt + (1.0,)
    *elif *len(pt) == 2:
        pt = pt + (0.0, 1.0)
    self.ren.SetWorldPoint(pt)
    self.ren.WorldToDisplay()
    pt = self.ren.GetDisplayPoint()
    pt = (pt[0], pt[1])
    *return *pt

pt = [5, 5]

world_pt = self. world_to_display(pt)

display_pt = self. world_to_display(world_pt)
In some cases, it's quite accurate, which means pt equals display_pt. But,
in some cases, the result is simply wrong. For example, for (5, 5), after
conversions back to display, the coordinate becomes (20.89, 20.89).

Any ideas?


Many thanks.


Bill
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20170519/1343e14f/attachment.html>


More information about the vtkusers mailing list