Main Content

Control View Using Camera Tools

You can use camera tools to interactively set the camera motion mode, principal axis, projection type, and playback settings for a set of 3-D axes. To display the camera tools, click Camera Tools on the Tools tab in a figure. Alternatively, use the cameratoolbar function.

Camera tools for camera motion, principal axis, projection type, and resetting and stopping

Note

By default, MATLAB® displays a plot with an aspect ratio that fits the figure window. This behavior can lead to distortion for 3-D graphics as you move the camera around the scene. To avoid possible distortion, when you click the axes, the camera tools automatically switch the axes to the 3-D visualization mode. Alternatively, you can enable the 3-D visualization mode using the command axis vis3d.

Camera Motion Controls

Camera motion modes allow you to manipulate the camera axes interactively. Set the camera motion mode by selecting buttons on the Camera tab. Alternatively, specify the mode using the command cameratoolbar("SetMode",mode).

In the motions illustrated in the diagrams in this table, the camera remains pointed at the camera target. For an illustration of the graphics properties involved in camera motion, see Camera Graphics Terminology.

Camera Motion ModeDiagram
  • Name: Orbit

  • cameratoolbar Mode: "orbit"

  • Description: Rotate the camera about an axis. By default, rotate about the z-axis, or select x-, y-, z-, or free-axis rotation using the principal axis selectors.

  • Graphics Properties: This mode changes the Axes CameraPosition property while keeping the Axes CameraTarget fixed.

Graphics object response to camera orbit

  • Name: Tilt

  • cameratoolbar Mode: "pan"

  • Description: Move the point in the scene that the camera points to while keeping the camera fixed. By default, move the target in an arc about the z-axis, or select x-, y-, z-, or free-axis rotation using the principal axis selectors.

  • Graphics Properties: This mode changes the Axes CameraTarget property.

Graphics object response to camera pan and tilt

  • Name: Pan

  • cameratoolbar Mode: "dollyhv"

  • Description: Move the scene in the same horizontal and vertical directions as the cursor.

  • Graphics Properties: This mode moves the points defined by the Axes CameraPosition and CameraTarget properties simultaneously along parallel lines.

Graphics object response to camera horizontal and vertical motion

  • Name: Dolly

  • cameratoolbar Mode: "dollyfb"

  • Description: This move moves the camera towards the scene by moving the cursor up or right, or move the camera away from the scene by moving the cursor down or left. You can move the camera through objects in the scene and to the other side of the camera target.

  • Graphics Properties: This mode moves the point defined by the Axes CameraPosition property along the line connecting the camera position and the camera target.

Graphics object response to camera forward and backward motion

  • Name: Zoom

  • cameratoolbar Mode: "zoom"

  • Description: Make the scene larger by moving the cursor up or right, or make the scene smaller by moving the cursor down or left. Zooming does not move the camera and therefore cannot move the viewpoint through objects in the scene.

  • Graphics Properties: This mode changes the Axes CameraViewAngle property. The larger the angle, the smaller the scene appears.

Graphics object response to camera zoom

  • Name: Roll

  • cameratoolbar Mode: "roll"

  • Description: Rotate the view on the screen by rotating the camera about the viewing axis.

  • Graphics Properties: This mode changes the Axes CameraUpVector property.

Graphics object response to camera roll

Principal Axis Selectors

The principal axis of a scene defines the direction that is oriented upward on the screen and constrains camera motion along axes that are parallel and perpendicular to the principal axis. Specifying a principal axis is useful if your data is defined with respect to a specific axis.

The Orbit Camera and Pan/Tilt Camera modes operate with respect to a particular axis. On the Camera tab, for constrained motion, select a principal axis (Principal Axis X , Principal Axis Y , or Principal Axis Z ) or no axis (No Principal Axis ).

For the z-axis, which is the default principal axis for a 3-D view:

  • Horizontal cursor motion results in camera rotation about a vertical axis that passes through the point defined by the CameraTarget property and is parallel to the z-axis.

  • Vertical cursor motion results in camera rotation about a horizontal axis that is perpendicular to the plane defined by the z-axis and the line through the points defined by the CameraTarget and CameraPosition properties.

3-D axes, using Principal Axis Z, with vertical and horizontal axes for rotation

Scene Light

A scene light casts light on any patch and surface objects in axes. Axes can only have one scene light. This mode changes the Light Position property.

To create and toggle a light source, select Labels and Annotations > Light on the Figure tab in a figure.

To orbit the scene light, display the camera tools by clicking Camera Tools on the Tools tab. Then, right-click the axes and select Camera Motion > Orbit Scene Light in the context menu. Alternatively, specify the "orbitscenelight" mode using the cameratoolbar function.

Projection Type

MATLAB uses graphical projection to display 3-D objects on a 2-D screen. Toggle the projection type by selecting Orthographic Projection or Perspective Projection on the Camera tab. By default, the projection type is orthographic.

  • Orthographic projection projects the viewing volume as a rectangular parallelepiped (a box with six rectangular faces). Relative distance from the camera does not affect the size of objects. This projection type is useful when you want to maintain the actual size of objects and the angles between objects.

  • Perspective projection 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 farther from the camera appear smaller. This projection type is useful when you want to display realistic views of real objects.

For more information, see Understanding View Projections.

Reset and Stop

Reset or stop the camera and scene light by selecting Reset Scene or Stop Motion on the Camera tab.

  • Resetting returns the camera and light to the state they were in when the interactions began.

  • Stopping causes the camera and light to stop moving, which can be useful if you apply too much cursor movement.

See Also

Functions

Properties

Topics