Where is the math behind world to display coordinates and vice versa, implemented in vtk?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Where is the math behind world to display coordinates and vice versa, implemented in vtk?

vinmean
I want to recreate the transformation from display to world and world to
display coordinate system.  Where is the math behind coordinate conversion
implemented? I am unable to trace it from the viewport class that provides
the member function WorldToDisplay and DisplayToWorld.

        renderer->SetWorldPoint(wrld_cord);
        renderer->WorldToDisplay();
        renderer->GetDisplayPoint(scr_cord);

Please point me to the math either in the code or in some tutorials.



--
Sent from: http://vtk.1045678.n5.nabble.com/VTK-Users-f1224199.html
_______________________________________________
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:
https://vtk.org/mailman/listinfo/vtkusers
Reply | Threaded
Open this post in threaded view
|

Re: Where is the math behind world to display coordinates and vice versa, implemented in vtk?

Allie Vacanti
VTK uses the standard transformation process used in OpenGL. There are a few tutorials online that give an overview of this, one that I've found useful in the past is here:

http://www.songho.ca/opengl/gl_transform.html

As for the VTK-specific implementation, the code that implements this process is spread out across several locations in vtkOpenGLCamera, vtkRenderer, and vtkViewport. The class vtkCoordinate provides a convenient API to convert coordinates between display/world or to any intermediate coordinate system.

If you're only concerned with world <-> display and are interested in seeing the math used, a more compact replication of this transformation logic can be found in the (internal) FastDepthAwareCoordinateConverter class here:

https://github.com/Kitware/VTK/blob/master/Rendering/Core/vtkBillboardTextActor3D.cxx#L62-L193

HTH,
Allie

On Wed, Jan 31, 2018 at 2:08 AM, vinmean <[hidden email]> wrote:
I want to recreate the transformation from display to world and world to
display coordinate system.  Where is the math behind coordinate conversion
implemented? I am unable to trace it from the viewport class that provides
the member function WorldToDisplay and DisplayToWorld.

        renderer->SetWorldPoint(wrld_cord);
        renderer->WorldToDisplay();
        renderer->GetDisplayPoint(scr_cord);

Please point me to the math either in the code or in some tutorials.



--
Sent from: http://vtk.1045678.n5.nabble.com/VTK-Users-f1224199.html
_______________________________________________
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:
https://vtk.org/mailman/listinfo/vtkusers


_______________________________________________
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:
https://vtk.org/mailman/listinfo/vtkusers