[vtkusers] What is the difference between ProjectionTransformMatrix of VTK and GL_PROJECTION of OpenGL?

technOslerphile dennis.juve at gmail.com
Thu Oct 9 05:34:09 EDT 2014


Hi,

I am having profound issues regarding understanding the transformations
involved in VTK. OpenGL has fairly good documentation and I was of the
impression that VTK is verym similar to OpenGL (it is, in many ways). But
when it comes to transformations, it seems to be an entirely different
story.

This is a good OpenGL documentation about transforms involved:
</a> <http://www.songho.ca/opengl/gl_transform.html> 

The perspective projection matrix in OpenGL is:

<http://vtk.1045678.n5.nabble.com/file/n5729072/OpenGLProjectionMatrix.jpg> 

I wanted to see if this formula applied in VTK will give me the projection
matrix of VTK (by cross-checking with VTK projection matrix).

*Relevant Camera and Renderer Parameters:*
camera->SetPosition(0,0,20);
camera->SetFocalPoint(0,0,0);
double crSet[2] = {10, 1000};
renderer->GetActiveCamera()->SetClippingRange(crSet);
double windowSize[2];
renderWindow->SetSize(1280,720);
renderWindowInteractor->GetSize(windowSize);
proj =
renderer->GetActiveCamera()->GetProjectionTransformMatrix(windowSize[0]/windowSize[1],
crSet[0], crSet[1]);


The projection transform matrix I got for this configuration is:

<http://vtk.1045678.n5.nabble.com/file/n5729072/VTKProjectionMatrix.jpg> 


The (3,3) and (3,4) values of the projection matrix (lets say it is indexed
1 to 4 for rows and columns) should be - (f+n)/(f-n) and -2*f*n/(f-n)
respectively. In my VTK camera settings, the nearz is 10 and farz is 1000
and hence I should get -1.020 and -20.20 respectively in the (3,3) and (3,4)
locations of the matrix. But it is -1010 and -10000. 

I have changed my clipping range values to see the changes and the (3,3)
position is always nearz+farz which makes no sense to me. Also, it would be
great if someone can explain why it is 3.7320 in the (1,1) and (2,2)
positions. And this value DOES NOT change when I change the window size of
the renderer window. Quite perplexing to me.

I see in VTKCamera class reference that GetProjectionTransformMatrix()
returns the transformation matrix that maps from camera coordinates to
viewport coordinates.
http://www.vtk.org/doc/nightly/html/classvtkCamera.html
<http://www.vtk.org/doc/nightly/html/classvtkCamera.html>  

OpenGL Projection Matrix is the matrix that maps from eye coordinates to
clip coordinates. It is beyond doubt that eye coordinates in OpenGL is the
same as camera coordinates in VTK. But is the clip coordinates in OpenGL
same as viewport coordinates of VTK? 



--
View this message in context: http://vtk.1045678.n5.nabble.com/What-is-the-difference-between-ProjectionTransformMatrix-of-VTK-and-GL-PROJECTION-of-OpenGL-tp5729072.html
Sent from the VTK - Users mailing list archive at Nabble.com.


More information about the vtkusers mailing list