Main Content

Control View Using Camera Toolbar

You can use the camera toolbar to perform a number of viewing operations interactively. Display the toolbar and interactively set the camera motion mode, principal axis, scene light, projection type, and playback settings by selecting Camera Toolbar from the View menu in a figure. Alternatively, use the cameratoolbar function.

Camera toolbar controls for camera motion, principal axis, scene light, 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, the camera toolbar automatically switches 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 axes camera interactively. Set the camera motion mode by selecting buttons in the camera toolbar. 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 Camera Orbit Camera button in the camera toolbar

  • 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: Orbit Scene Light Orbit Scene Light button in the camera toolbar

  • cameratoolbar Mode: "orbitscenelight"

  • Description: Create a light, and change its position with respect to the camera. By default, the light is right and up from the camera. Turn the light on and off by clicking the Toggle Scene Light button.

  • Graphics Properties: This mode changes the Light Position property.

Not applicable
  • Name: Pan/Tilt Camera Pan/Tilt Camera button in the camera toolbar

  • 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: Move Camera Horizontally/Vertically Move Camera Horizontally/Vertically button in the camera toolbar

  • 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: Move Camera Forward/Back Move Camera Forward/Back button in the camera toolbar

  • 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 Camera Zoom Camera button in the camera toolbar

  • 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 Camera Roll Camera button in the camera toolbar

  • 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. Select a principal axis (Principal Axis X , Principal Axis Y , or Principal Axis Z ) or no axis (No Principal Axis ) for constrained motion in the camera toolbar.

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. Create and toggle a light source by selecting Toggle Scene Light in the camera toolbar. Move the scene light by selecting Orbit Scene Light in the camera toolbar. Axes can have only one scene light.

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 in the camera toolbar. 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 Camera and Scene Light or Stop Camera/Light Motion in the camera toolbar.

  • 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

Related Topics