Site Tools

Zooming to the extends of 3-D points

Developer: C++
Summary: Demonstrates how to zoom to the extends of an array of 3-D points using the Rhino C++ SDK.


I have an array of 3-D points that I would like to “Zoom Extents” do. How is this done in the SDK?


The RhinoDollyExtents SDK function will dolly the camera location of a viewport so that the view frustum contains a bounding box specified on camera coordinates. Below is an example of how you can use this function to zoom to the extends of an array of 3-D points:

static void ZoomExtents( CRhinoView* view, const ON_3dPointArray& point_array )
  if( 0 == view )
  const ON_Viewport& current_vp = view->ActiveViewport().VP();
  ON_Viewport zoomed_vp;
  ON_Xform w2c;
  current_vp.GetXform( ON::world_cs, ON::camera_cs, w2c );
  ON_BoundingBox bbox = point_array.BoundingBox();
  if( bbox.IsValid() )
    double border = 1.1;
    double dx = bbox.m_max.x - bbox.m_min.x;
    dx *= 0.5 * (border - 1.0);
    bbox.m_max.x += dx;
    bbox.m_min.x -= dx;
    double dy = bbox.m_max.y - bbox.m_min.y;
    dy *= 0.5 * (border - 1.0);
    bbox.m_max.y += dy;
    bbox.m_min.y -= dy;
    if( RhinoDollyExtents(current_vp, bbox, zoomed_vp) )
      view->ActiveViewport().SetVP( zoomed_vp, true );
developer/sdksamples/zoompoints.txt · Last modified: 2014/01/23 (external edit)