Example 
CalculateRadiusToFit Method (Camera3D)
Calculates a Camera target and radius that will fit the bounding box completely inside the viewport. Uses a simple bounding-sphere algorithm
Syntax
public void CalculateRadiusToFit( 
   BoundingBox bounds,
   out Vector3 newTarget,
   out float newRadius
)

Parameters

bounds
newTarget
newRadius
Example
// Given a current position, target (which gives camera direction)
camera.Target = new Vector3(0,0,0);
camera.Position = new Vector3(100,100,100);
// Calculate optimum radius to fit the bounding box
Vector3 newTarget;
float newRadius;
camera.CalculateRadiusToFit(new BoundingBox(/* ... */), out newTarget, out newRadius);
// Update camera target and radius
camera.Target = newTarget;
camear.Radius = newRadius;
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also