This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

CameraDirection, CameraDirectionX, CameraDirectionY, CameraDirectionZ

Direction of the automatic camera

MuPAD® notebooks are not recommended. Use MATLAB® live scripts instead.

MATLAB live scripts support most MuPAD functionality, though there are some differences. For more information, see Convert MuPAD Notebooks to MATLAB Live Scripts.

Value Summary

CameraDirectionLibrary wrapper for “[CameraDirectionX, CameraDirectionY, CameraDirectionZ]” (3D)See below
CameraDirectionX, CameraDirectionY, CameraDirectionZ See below

Graphics Primitives

ObjectsDefault Values


CameraDirection controls the direction where the automatically set camera is positioned.

CameraDirectionX etc. refer to the single coordinates of this direction.

When creating a 3D scene, an “automatic camera” is used. It is placed somewhere along the ray starting at the center of the scene (or the center of an explicitly requested ViewingBox, respectively) with the direction given by CameraDirection.

The distance to the scene is chosen automatically such that the graphical scene or ViewingBox fills the drawing area optimally.

The CameraDirection value is a list or vector of numbers.


This vector represents a direction, where the camera is found when starting at the center of the scene or viewing box. It is not the position of the camera!

The length of the CameraDirection does not matter, only its direction. The length should not be zero, though.

CameraDirection = [0, 0, 1] (looking straight down onto the x-y plane along the z-axis) does not yield a well defined camera view. This direction is automatically replaced by a direction that is close to, but not exactly equal to the z direction and orients the scene similiar to a 2D plot.

The CameraDirection attributes cannot be animated.

The automatic camera is designed to produce a picture of the entire scene or viewing box, filling the drawing area optimally. CameraDirection is the only means to control it.

If only parts of a scene shall be visible, or if the camera is not to aim at the center of the scene, or if large perspective distortions are desired, or if the camera position is to be animated, one has to define one's own camera of type plot::Camera. It can be placed at an arbitrary Position with an arbitrary FocalPoint and can have an arbitrary ViewingAngle. Further, it can be animated (allowing to realize a flight through a 3D scene).

When such a camera object is inserted in a graphical scene, the automatic camera is switched off and the user defined camera takes over, automatically. It uses its own perspective parameters and ignores the attribute CameraDirection.


Example 1

We look at a function with the default direction of the automatic camera:

f := plot::Function3d(x^2 + y^3, x = 0..1, y = -1 ..1):

We look from different directions:

S1 := plot::Scene3d(f, CameraDirection = [-3,-4, 5]):
S2 := plot::Scene3d(f, CameraDirection = [ 3,-4, 5]):
S3 := plot::Scene3d(f, CameraDirection = [ 3, 4, 5]):
S4 := plot::Scene3d(f, CameraDirection = [-3, 4, 5]):
plot(S1, S2, S3, S4)

We look straight down onto the x-y plane along the z-axis:

plot(f, CameraDirection = [0, 0, 1])

delete f, S1, S2, S3:
Was this topic helpful?