<HTML>
<HEAD>
<TITLE>Re: [vtkusers] VtkCamera -- Zoom method</TITLE>
</HEAD>
<BODY>
<FONT FACE="Calibri, Verdana, Helvetica, Arial"><SPAN STYLE='font-size:11pt'>Hi Chris,<BR>
I actually figured out that my understanding of the &#8220;zoom&#8221; operation was incorrect after querying on another list.<BR>
;)<BR>
I can&#8217;t use this functionality because I have large models (spatially) with small details and after a couple of &#8220;zooms&#8221; the view angle is really small which causes problems later in the render pipeline.<BR>
Gerrick<BR>
On 9/24/08 1:16 PM, &quot;Chris Volpe ARA/SED&quot; &lt;<a href="cvolpe@ara.com">cvolpe@ara.com</a>&gt; wrote:<BR>
<BR>
</SPAN></FONT><BLOCKQUOTE><FONT FACE="Calibri, Verdana, Helvetica, Arial"><SPAN STYLE='font-size:11pt'><FONT COLOR="#1F497D">I read this post mainly because I thought it might have something to do with my Dolly question from a couple weeks ago. I&#8217;m not sure why you&#8217;re questioning this implementation, or what you mean by &#8220;translation&#8221;, since there&#8217;s no translation going on here. &#8220;Zooming&#8221; doesn&#8217;t mean moving the camera closer to what it&#8217;s looking at (that&#8217;s called &#8220;dollying&#8221;). Zooming is what happens when you put a zoom-lens (or &#8220;telephoto&#8221; lens) on your camera, which basically has the effect of reducing the camera&#8217;s view angle so that objects that subtend a smaller view angle fill the image. This is basically synonymous with &#8220;magnification&#8221;. <BR>
&nbsp;<BR>
</FONT><BR>
</SPAN></FONT><FONT COLOR="#1F497D"><FONT SIZE="6"><FONT FACE="Monotype Corsiva"><SPAN STYLE='font-size:24pt'>Chris<BR>
</SPAN></FONT></FONT><FONT SIZE="2"><FONT FACE="Times New Roman"><SPAN STYLE='font-size:10pt'>--<BR>
Christopher R. Volpe, Ph.D. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Email: </SPAN></FONT></FONT></FONT><FONT SIZE="2"><FONT FACE="Times New Roman"><SPAN STYLE='font-size:10pt'><FONT COLOR="#0000FF"><a href="cvolpe@ara.com">cvolpe@ara.com</a></FONT><FONT COLOR="#1F497D"> &lt;<a href="mailto:cvolpe@ara.com">mailto:cvolpe@ara.com</a>&gt; <BR>
Senior Scientist, Information Exploitation Systems &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Main Desk: 919-582-3300<BR>
</FONT><FONT COLOR="#0000FF">Applied Research Associates, Inc</FONT><FONT COLOR="#1F497D"> &lt;<a href="http://www.ara.com/">http://www.ara.com/</a>&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Direct: 919-582-3380<BR>
8537 Six Forks Rd., Suite 6000 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Fax : 919-582-3301<BR>
Raleigh, NC 27615 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Web: </FONT><FONT COLOR="#0000FF"><a href="http://www.ara.com/offices/NC.htm">http://www.ara.com/offices/NC.htm</a></FONT><FONT COLOR="#1F497D"> &lt;<a href="http://www.ara.com/offices/NC.htm">http://www.ara.com/offices/NC.htm</a>&gt; <BR>
</FONT></SPAN></FONT></FONT><FONT COLOR="#1F497D"><FONT FACE="Calibri, Verdana, Helvetica, Arial"><SPAN STYLE='font-size:11pt'> <BR>
&nbsp;<BR>
</SPAN></FONT></FONT><FONT FACE="Calibri, Verdana, Helvetica, Arial"><SPAN STYLE='font-size:11pt'><BR>
</SPAN></FONT><FONT SIZE="2"><FONT FACE="Tahoma, Verdana, Helvetica, Arial"><SPAN STYLE='font-size:10pt'><B>From:</B> <a href="vtkusers-bounces@vtk.org">vtkusers-bounces@vtk.org</a> [<a href="mailto:vtkusers-bounces@vtk.org">mailto:vtkusers-bounces@vtk.org</a>] <B>On Behalf Of </B>Gerrick Bivins<BR>
<B>Sent:</B> Monday, September 15, 2008 6:26 PM<BR>
<B>To:</B> VTK-users<BR>
<B>Subject:</B> [vtkusers] VtkCamera -- Zoom method<BR>
</SPAN></FONT></FONT><FONT FACE="Times New Roman"><SPAN STYLE='font-size:12pt'> <BR>
</SPAN></FONT><FONT FACE="Calibri, Verdana, Helvetica, Arial"><SPAN STYLE='font-size:11pt'>Hi All, Long email but please bear with me.<BR>
;)<BR>
I have had this problem of zooming in with vtkInteractorStyleRubberBandZoom.<BR>
Today was the day to tackle is and eventually I realized that zoom works fine when I use parallel projection but not perspective. <BR>
When I switch to perspective projection and zoom in, at some point the view angle gets set to 0 (1e-8). <BR>
<BR>
I&#8217;ve dug down into the code and ran across this implementation for Zoom in vtkCamera which is being called by vtkInteractorStyleRubberBandZoom:<BR>
<BR>
//----------------------------------------------------------------------------<BR>
// Change the ViewAngle (for perspective) or the ParallelScale (for parallel)<BR>
// so that more or less of a scene occupies the viewport. &nbsp;A value &gt; 1 is a<BR>
// zoom-in. A value &lt; 1 is a zoom-out.<BR>
void vtkCamera::Zoom(double amount)<BR>
{<BR>
&nbsp;&nbsp;if (amount &lt;= 0.0)<BR>
&nbsp;&nbsp;&nbsp;&nbsp;{<BR>
&nbsp;&nbsp;&nbsp;&nbsp;return;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;}<BR>
<BR>
&nbsp;&nbsp;if (this-&gt;ParallelProjection)<BR>
&nbsp;&nbsp;&nbsp;&nbsp;{<BR>
&nbsp;&nbsp;&nbsp;&nbsp;this-&gt;SetParallelScale(this-&gt;ParallelScale/amount);<BR>
&nbsp;&nbsp;&nbsp;&nbsp;}<BR>
&nbsp;&nbsp;else<BR>
&nbsp;&nbsp;&nbsp;&nbsp;{<BR>
&nbsp;&nbsp;&nbsp;&nbsp;this-&gt;SetViewAngle(this-&gt;ViewAngle/amount);//&lt;==Why is zoom implemented like this? Why isn&#8217;t it a function of translation?<BR>
&nbsp;&nbsp;&nbsp;&nbsp;}<BR>
}<BR>
<BR>
Which is defined here:<BR>
</SPAN></FONT><FONT SIZE="1"><FONT FACE="Courier New"><SPAN STYLE='font-size:7pt'>void vtkCamera::SetViewAngle(double angle)<BR>
{<BR>
&nbsp;&nbsp;double min = 0.00000001;<BR>
&nbsp;&nbsp;double max = 179.0;<BR>
<BR>
&nbsp;&nbsp;if ( this-&gt;ViewAngle != angle )<BR>
&nbsp;&nbsp;&nbsp;&nbsp;{<BR>
&nbsp;&nbsp;&nbsp;&nbsp;this-&gt;ViewAngle = (angle&lt;min?min:(angle&gt;max?max:angle));<BR>
&nbsp;&nbsp;&nbsp;&nbsp;this-&gt;Modified();<BR>
&nbsp;&nbsp;&nbsp;&nbsp;this-&gt;ViewingRaysModified();<BR>
&nbsp;&nbsp;&nbsp;&nbsp;}<BR>
}<BR>
</SPAN></FONT></FONT><FONT FACE="Calibri, Verdana, Helvetica, Arial"><SPAN STYLE='font-size:11pt'><BR>
At this point(when min is set ), rendering becomes messed up (backfaces and bad z-fighting) and the only way to fix things is to restart the application.<BR>
This 0 can be seen as problematic in functions like<BR>
<BR>
&nbsp;vktRenderer::ResetCamera(double bounds[6])<BR>
{<BR>
...<BR>
&nbsp;&nbsp;//around line 990<BR>
&nbsp;&nbsp;distance = radius/sine(this-&gt;ActiveCamera()-&gt;GetViewAngle()*vtkMath::Pi()/360.0);//&lt;== (radius/some really small number if view angle is small) == some really big number(e12)!!!!!<BR>
...<BR>
//around line 1004<BR>
&nbsp;&nbsp;this-&gt;ActiveCamera-&gt;SetPosition(center[0]+distance*vn[0], center[1]+distance*vn[1], center[2]+distance*vn[2]); //&lt;==Uh Oh distance is a really big number(e12)!!<BR>
}<BR>
So finally, my question deals with trying to get a better understanding of the &#8220;Zoom&#8221; method in vtkCamera.<BR>
I don&#8217;t understand why zoom is implemented by changing the view angle. <BR>
Why isn&#8217;t it a function of translating the camera along it&#8217;s view vector toward or away from it&#8217;s lookAt point?<BR>
<BR>
Hopefully someone made it this far and can shed some light here.<BR>
;)<BR>
Gerrick<BR>
<BR>
<BR>
<BR>
<BR>
<BR>
</SPAN></FONT></BLOCKQUOTE>
</BODY>
</HTML>