[vtkusers] VtkCamera -- Zoom method

Chris Volpe ARA/SED cvolpe at ara.com
Wed Sep 24 14:16:18 EDT 2008


I read this post mainly because I thought it might have something to do
with my Dolly question from a couple weeks ago. I'm not sure why you're
questioning this implementation, or what you mean by "translation",
since there's no translation going on here. "Zooming" doesn't mean
moving the camera closer to what it's looking at (that's called
"dollying"). Zooming is what happens when you put a zoom-lens (or
"telephoto" lens) on your camera, which basically has the effect of
reducing the camera's view angle so that objects that subtend a smaller
view angle fill the image. This is basically synonymous with
"magnification". 

 

Chris

--
Christopher R. Volpe, Ph.D.
Email: cvolpe at ara.com <mailto:cvolpe at ara.com>  

Senior Scientist, Information Exploitation Systems             Main
Desk: 919-582-3300

Applied Research Associates, Inc <http://www.ara.com/>
Direct: 919-582-3380

8537 Six Forks Rd., Suite 6000
Fax : 919-582-3301

Raleigh, NC 27615                                         Web:
http://www.ara.com/offices/NC.htm <http://www.ara.com/offices/NC.htm> 

 

 

From: vtkusers-bounces at vtk.org [mailto:vtkusers-bounces at vtk.org] On
Behalf Of Gerrick Bivins
Sent: Monday, September 15, 2008 6:26 PM
To: VTK-users
Subject: [vtkusers] VtkCamera -- Zoom method

 

Hi All, Long email but please bear with me.
;)
I have had this problem of zooming in with
vtkInteractorStyleRubberBandZoom.
Today was the day to tackle is and eventually I realized that zoom works
fine when I use parallel projection but not perspective. 
When I switch to perspective projection and zoom in, at some point the
view angle gets set to 0 (1e-8). 

I've dug down into the code and ran across this implementation for Zoom
in vtkCamera which is being called by vtkInteractorStyleRubberBandZoom:

//----------------------------------------------------------------------
------
// Change the ViewAngle (for perspective) or the ParallelScale (for
parallel)
// so that more or less of a scene occupies the viewport.  A value > 1
is a
// zoom-in. A value < 1 is a zoom-out.
void vtkCamera::Zoom(double amount)
{
  if (amount <= 0.0)
    {
    return;
    }

  if (this->ParallelProjection)
    {
    this->SetParallelScale(this->ParallelScale/amount);
    }
  else
    {
    this->SetViewAngle(this->ViewAngle/amount);//<==Why is zoom
implemented like this? Why isn't it a function of translation?
    }
}

Which is defined here:
void vtkCamera::SetViewAngle(double angle)
{
  double min = 0.00000001;
  double max = 179.0;

  if ( this->ViewAngle != angle )
    {
    this->ViewAngle = (angle<min?min:(angle>max?max:angle));
    this->Modified();
    this->ViewingRaysModified();
    }
}

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.
This 0 can be seen as problematic in functions like

 vktRenderer::ResetCamera(double bounds[6])
{
...
  //around line 990
  distance =
radius/sine(this->ActiveCamera()->GetViewAngle()*vtkMath::Pi()/360.0);//
<== (radius/some really small number if view angle is small) == some
really big number(e12)!!!!!
...
//around line 1004
  this->ActiveCamera->SetPosition(center[0]+distance*vn[0],
center[1]+distance*vn[1], center[2]+distance*vn[2]); //<==Uh Oh distance
is a really big number(e12)!!
}
So finally, my question deals with trying to get a better understanding
of the "Zoom" method in vtkCamera.
I don't understand why zoom is implemented by changing the view angle. 
Why isn't it a function of translating the camera along it's view vector
toward or away from it's lookAt point?

Hopefully someone made it this far and can shed some light here.
;)
Gerrick






-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20080924/218168da/attachment.htm>


More information about the vtkusers mailing list