Calculating field of view


#1

Hi

In RhinoCommon there is a nice function to calculate the fov for a perspective view (GetCameraAngle()). It is possible to use this function to determine the fov for a parallel view? As you zoom in/out of a parallel view, the GetCameraAngle fov changes, but not as the perspective window does - looks like I need to adjust it by another factor.

EDIT: The is a description of doing this (with Rhino4?) here…http://news2.mcneel.com/scripts/dnewsweb.exe?cmd=article&group=rhino.plug-ins&item=39453&utag= however there appears to be no ViewRadius method in RhinoCommon.

Thanks in advance.

Paul


(Steve Baer) #2

Hi Paul,
Here’s the ViewRadius function implemented in python
https://github.com/mcneel/rhinopython/blob/master/scripts/rhinoscript/view.py#L833

In C# / RhinoCommon, this would be

RhinoViewport viewport = ...
if (viewport.IsParallelProjection)
{
  double left, right, bottom, top, near, far;
  if( viewport.GetFrustum(out left, out right, out bottom, out top, out near, out far) )
  {
    double viewradius = top<right ? top : right;
  }
}