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

Dan Lipsa dan.lipsa at kitware.com
Mon May 22 10:04:35 EDT 2017


Bill,
For display_to_world, the picker picks up only what is visible (closes to
the camera). You might have several objects (several values in world
coordinates) that end up over the same display coordinate. This might
explain why adding those text actors changes what you pick.

Dan



On Sun, May 21, 2017 at 5:25 AM, Bill Q <bill.q.hdp at gmail.com> wrote:

> Can anybody help? Many thanks.
>
> Many thanks.
>
>
> Bill
>
> On Fri, May 19, 2017 at 11:20 PM, Bill Q <bill.q.hdp at gmail.com> wrote:
>
>> 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
>>
>
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/
> opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Search the list archives at: http://markmail.org/search/?q=vtkusers
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/vtkusers
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20170522/305403ff/attachment.html>


More information about the vtkusers mailing list