Documentation Center

  • Trial Software
  • Product Updates

Understanding View Projections

Two Types of Projections

MATLAB® Graphics supports both orthographic and perspective projection types for displaying 3-D graphics. The one you select depends on the type of graphics you are displaying:

  • orthographic projects the viewing volume as a rectangular parallelepiped (i.e., a box whose opposite sides are parallel). Relative distance from the camera does not affect the size of objects. This projection type is useful when it is important to maintain the actual size of objects and the angles between objects.

  • perspective projects the viewing volume as the frustum of a pyramid (a pyramid whose apex has been cut off parallel to the base). Distance causes foreshortening; objects further from the camera appear smaller. This projection type is useful when you want to display realistic views of real objects.

By default, MATLAB displays objects using orthographic projection. You can set the projection type using the camproj command.

These pictures show a drawing of a dump truck (created with patch) and a surface plot of a mathematical function, both using orthographic projection.

If you measure the width of the front and rear faces of the box enclosing the dump truck, you'll see they are the same size. This picture looks unnatural because it lacks the apparent perspective you see when looking at real objects with depth. On the other hand, the surface plot accurately indicates the values of the function within rectangular space.

Now look at the same graphics objects with perspective added. The dump truck looks more natural because portions of the truck that are farther from the viewer appear smaller. This projection mimics the way human vision works. The surface plot, on the other hand, looks distorted.

Projection Types and Camera Location

By default, MATLAB adjusts the CameraPosition, CameraTarget, and CameraViewAngle properties to point the camera at the center of the scene and to include all graphics objects in the axes. If you position the camera so that there are graphics objects behind the camera, the scene displayed can be affected by both the axes Projection property and the figure Renderer property. The following summarizes the interactions between projection type and rendering method.

 

Orthographic

Perspective

Z-buffer

CameraViewAngle determines extent of scene at CameraTarget.

CameraViewAngle determines extent of scene from CameraPosition to infinity.

Painters

All objects are displayed regardless of CameraPosition.

Not recommended if graphics objects are behind the CameraPosition.

This diagram illustrates what you see (gray area) when using orthographic projection and Z-buffer. Anything in front of the camera is visible.

In perspective projection, you see only what is visible in the cone of the camera view angle.

Painters rendering method is less suited to moving the camera in 3-D space because MATLAB does not clip along the viewing axis. Orthographic projection in painters method results in all objects contained in the scene being visible regardless of the camera position.

Printing 3-D Scenes

The same effects described in the previous section occur in hardcopy output. However, because of the differences in the process of rendering to the screen and to a printing format, MATLAB might render using Z-buffer and generate printed output using painters. You might need to specify Z-buffer printing explicitly to obtain the results displayed on the screen (use the -zbuffer option with the print command).

Additional Information

See Basic Printing and Exporting and Selecting a Renderer in Figure Properties in the Using MATLAB Graphics documentation for information on printing and rendering methods.

Was this topic helpful?