[vtk-developers] Possible mistake in vtkRenderLargeImage

Michael Scarpa M.Scarpa at uva.nl
Tue Nov 15 14:09:53 EST 2005


Dear VTK developer community,

I have come across what I believe to be a mistake in the  
implementation of the class vtkRenderLargeImage in the Hybrid  
package.  To illustrate the case, please consider the simple VTK  
script found at http://www.science.uva.nl/~mscarpa/vtk/TestImage.py.   
This script generates an image as http://www.science.uva.nl/~mscarpa/ 
vtk/Image.png.

Now, consider a modified version of the above script as found at  
http://www.science.uva.nl/~mscarpa/vtk/TestRenderLargeImage.py.  The  
only
differences with the first script are that the render window has  
smaller dimensions (a quarter width and a quarter height), and that  
it uses the vtkRenderLargeImage class to generate an image of the  
same size as the first script (500 by 500 pixels).  This script is  
based on the example found with the VTK source code.  On my VTK  
installation, the latter script generates an image as http:// 
www.science.uva.nl/~mscarpa/vtk/RenderLargeImageOriginal.png.  This  
is considerably different from the expected result, which (in this  
simple case) should be identical to the first image.  I have looked  
into the code of vtkRenderLargeImage (as can be found in CVS as of  
this writing), and I think I
found a mistake.  In the method vtkRenderLargeImage::RequestData(),  
the following statement calculates the view angle incorrectly:

   cam->SetViewAngle(asin(sin(viewAngle*3.1415926/360.0)/this- 
 >Magnification)
                     * 360.0 / 3.1415926);

I believe that the correct statement should be as follows:

   cam->SetViewAngle(atan(tan(viewAngle*3.1415926/360.0)/this- 
 >Magnification)
                     * 360.0 / 3.1415926);

The only difference consists in replacing the sine and arcsine  
functions with tangent and arctangent functions.  If the class is  
recompiled with these changes, the two scripts above produce  
identical images (see the image produced by the second script on my  
VTK installation after applying the above changes at http:// 
www.science.uva.nl/~mscarpa/vtk/RenderLargeImageModified.png).

Please note that more complex scenes will not produce absolutely  
identical images, but at least the images will be almost identical  
and not differ so much due to different view angles.

For convenience, this text can be found as HTML page at the following  
location: http://www.science.uva.nl/~mscarpa/vtk/index.html

Could someone please verify these findings and, if confirmed, could  
these changes be taken over in the CVS repository?  Any comment is  
obviously most welcome.

Kind regards,

Michael Scarpa
Section Computational Science
Universiteit van Amsterdam
Kruislaan 403
1098 SJ Amsterdam, The Netherlands
Room F2.15
Tel: +31 20 525 7574
Fax: +31 20 525 7419
Web: http://www.science.uva.nl/~mscarpa/




More information about the vtk-developers mailing list