[vtk-developers] new test case for coordinate conversions
David Gobbi
dgobbi at atamai.com
Wed Nov 23 14:50:23 EST 2005
Hi All,
I have attached a diagram I sent to Steve that summarizes the
definitions of the various
coordinate systems, as far as I understand them. It's simplified in
that it shows a
window with a single viewport, not multiple viewports.
The issue seems to be that some VTK code assumes that Viewport coords
extend across
the entire viewport, but they actually start a half-pixel width into the
viewport, and end
a half-pixel width from the far edge of the viewport.
I started working through some of the code but was pre-empted by a
project deadline :-P
- David
Steve M. Robbins wrote:
>Howdy,
>
>I've been trying to understand/debug coordinate conversion code in
>VTK. In particular, I need to understand the world<-->screen mapping
>under a parallel-projection camera. After a few rounds on this list (see
>http://public.kitware.com/pipermail/vtk-developers/2005-November/003823.html),
>David Gobbi and I continued in private mail and he convinced me that I
>should set the parallel scale to "height/2" rather than "(height-1)/2"
>as I was proposing.
>
>Along the way, I converted my test code from Java to C++ and switched
>to using vtkRenderer directly, rather than using vtkCoordinate.
>Examining the methods provided by the two classes shows that there are
>multiple ways to do conversion; e.g. there are two ways to convert
>from world->view, two to convert from world->display, *three* to
>convert from view->world, etc.
>
>Ultimately I discovered that the conversions are not all consistent.
>
>Working from the tip of CVS branch VTK-5-0, I wrote a test case
>Rendering/Testing/Cxx/coordinateConversion.cxx (attached) that
>compares the results of all equivalent conversions.
>
>It turns out that
>
> vtkRenderer::WorldToDisplay()
> vtkRenderer::DisplayToWorld()
> vtkRenderer::ViewToDisplay()
>
>disagree with their vtkCoordinate counterparts.
>
>David Gobbi feels that the view<-->normalized viewport conversion
>is incorrect. Indeed, looking at the code in vtkViewport, it
>appears to me that it doesn't take into account the change from
>pixel-edge convention of the screen and view coordinates to the
>pixel-centre convention of the viewport and world coordinates.
>
>
>I hope one of the developers has time to check my test case.
>Feel free to incorporate it into VTK. I've had one go at fixing
>vtkViewport::ViewToNormalizedViewport(), but didn't succeed.
>
>
>Cheers,
>-Steve
>
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: VTKCoords.png
Type: image/png
Size: 18151 bytes
Desc: not available
URL: <http://www.vtk.org/pipermail/vtk-developers/attachments/20051123/6041bab6/attachment.png>
More information about the vtk-developers
mailing list