<div dir="ltr"><div>Hello Everyone,</div><div>I encountered a weird problem in coordinate conversion.</div><div><br></div><div>In order to check the accuracy, I converted from display to world, and from world back to display. Using the following ways:</div><div>
<p class="gmail-p1"><span class="gmail-s1"><b>self.world_picker = vtk.vtkWorldPointPicker()<br></b></span></p><p class="gmail-p1"><span class="gmail-s1"><b>def </b></span>display_to_world(<span class="gmail-s2">self</span>, pt):<br>
<span class="gmail-s2">self</span>.world_picker.Pick(pt[<span class="gmail-s3">0</span>], pt[<span class="gmail-s3">1</span>], <span class="gmail-s3">0</span>, <span class="gmail-s2">self</span>.ren)<br>
picker_pt = <span class="gmail-s2">self</span>.world_picker.GetPickPosition()<br>
picker_pt = (picker_pt[<span class="gmail-s3">0</span>], picker_pt[<span class="gmail-s3">1</span>], <span class="gmail-s3">0</span>)<br>
<span class="gmail-s1"><b>return </b></span>picker_pt</p><p class="gmail-p1">
</p><p class="gmail-p1"><span class="gmail-s1"><b>def </b></span>world_to_display(<span class="gmail-s2">self</span>, pt):<br>
<span class="gmail-s1"><b>if </b>len</span>(pt) == <span class="gmail-s3">3</span>:<br>
pt = pt + (<span class="gmail-s3">1.0</span>,)<br>
<span class="gmail-s1"><b>elif </b>len</span>(pt) == <span class="gmail-s3">2</span>:<br>
pt = pt + (<span class="gmail-s3">0.0</span>, <span class="gmail-s3">1.0</span>)<br>
<span class="gmail-s2">self</span>.ren.SetWorldPoint(pt)<br>
<span class="gmail-s2">self</span>.ren.WorldToDisplay()<br>
pt = <span class="gmail-s2">self</span>.ren.GetDisplayPoint()<br>
<span class="gmail-s4">pt </span>= (pt[<span class="gmail-s3">0</span>], pt[<span class="gmail-s3">1</span>])<br>
<span class="gmail-s1"><b>return </b></span>pt</p><p class="gmail-p1">pt = [5, 5]</p><p class="gmail-p1">world_pt = self. world_to_display(pt)</p><p class="gmail-p1">display_pt = self. world_to_display(world_pt)</p></div><div>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).</div><div><br></div><div>Any ideas?</div><div><br></div><div><br></div><div><div class="gmail_signature"><div dir="ltr"><div>Many thanks.<br><br><br></div>Bill<br></div></div></div>
</div>