Accelerating the pace of engineering and science

# Documentation Center

• Trial Software

# plot::Camera

### Use only in the MuPAD Notebook Interface.

This functionality does not run in MATLAB.

## Syntax

```plot::Camera([px, py, pz], [fx, fy, fz], angle, <a = amin .. amax>, options)
```

## Description

plot::Camera([px, py, pz], [fx, fy, fz], angle) creates a camera at the position [px, py, pz] pointing towards the focal point [fx, fy, fz]. The opening angle of its lense is given by angle.

When creating a 3D scene, an "automatic camera" is used. Its location can be controlled by the attribute CameraDirection, but there are now further means of manipulating its parameters.

If the automatic camera does not suffice for your purposes, you may define your own camera by plot::Camera. Inserting such a camera object in your scene (for example, just by passing the camera as an argument to the plot command), the automatic camera is switched off and the new camera determines the view.

A camera of type plot::Camera allows to set all parameters determining the view and its perspective. Further, all parameters can be animated such that an animated "flight" through a 3D scene can be realized.

The first argument [px, py, pz] in the call generating a camera is the Position of the camera in 3-space. The second argument [fx, fy, fz] is the point the camera is aimed at (FocalPoint).

The optical axis is given by the vector FocalPoint - Position.

Together with the opening angle of the zoom lense (ViewingAngle), these parameters determine the view of the scene.

The FocalPoint vector can be replaced by any other point on the optical axes without changing the view. (FocalPoint and Position should not coincide, though.)

By default, the z-direction in 3-space corresponds to the vertical direction of the final picture. If this is not desired, the camera can be rotated around its optical axes using the attribute UpVector.

Depending on the distance of the camera to the graphical scene and the opening angle of the lense, the scene may fill only a small portion of the viewing area if the camera is too far away. If the camera is too close, only some parts of the scene may be visible

Just as for a real camera, you will have to move closer to or farther away from the scene to make it fill the drawing area as desired. Alternatively, you may keep the camera position fixed and use the zoom lense by choosing an appropriate ViewingAngle.

As in real life, you have to find appropriate parameters experimentally by looking at the picture and changing the parameters interactively.

Alternatively, you may define the camera with the attribute OrthogonalProjection = TRUE. This has the same effect as positioning the camera at a large distance from the scene using a powerful tele lense.

In this case, the camera ignores the ViewingAngle and the Position in 3-space. It is moved along the optical axis FocalPoint - Position to infinity and chooses an infinitesimal small viewing angle such that the scene fills the drawing area optimally.

Several cameras can be present simultaneously in a graphical scene. The first camera specified in the plot command determines the views.

One may switch between the cameras by clicking on the corresponding camera in the interactive "object browser" of the MuPAD® graphics tool (see section Viewer, Browser, and Inspector: Interactive Manipulation of this document).

You may place your own light sources in the scene. When specifying the attribute CameraCoordinates = TRUE in the definition of the lights, they are attached to the camera and move automatically, when the camera is moved.

## Attributes

AttributePurposeDefault Value
FocalPointthe focal point of a camera
FocalPointXthe focal point of a camera, x-coordinate
FocalPointYthe focal point of a camera, y-coordinate
FocalPointZthe focal point of a camera, z-coordinate
Framesthe number of frames in an animation50
KeepUpVectorkeep the UpVector constant when moving the camera?TRUE
Namethe name of a plot object (for browser and legend)
OrthogonalProjectionparallel projection without perspective distortionFALSE
ParameterEndend value of the animation parameter
ParameterNamename of the animation parameter
ParameterBegininitial value of the animation parameter
ParameterRangerange of the animation parameter
Positionpositions of cameras, lights, and text objects
PositionXx-positions of cameras, lights, and text objects
PositionYy-positions of cameras, lights, and text objects
PositionZz-positions of cameras, lights, and text objects
TimeEndend time of the animation10.0
TimeBeginstart time of the animation0.0
TimeRangethe real time span of an animation0.0 .. 10.0
UpVector"up direction" of a camera[0.0, 0.0, 1.0]
UpVectorXx-component of the "up vector" of the camera0.0
UpVectorYy-component of the "up vector" of the camera0.0
UpVectorZz-component of the "up vector" of the camera1.0
ViewingAngleopening angle of the camera lense
VisiblevisibilityTRUE

## Examples

### Example 1

We use our own camera to view the 3D graph of a function:

```f := plot::Function3d(sin(x) + y^3 + 2*exp(-3*x^2 - 20*y^2),
x = -PI..PI, y = -1 .. 1,
Submesh = [2, 2]):
camera := plot::Camera([-12, -4, 14], [0, 0, 0], PI/7):
plot(f, camera):```

We move the camera to another position:

```camera::Position := [7, -5, 6]:
plot(f, camera):```

We turn the camera towards the central peak and zoom in by decreasing the openening angle of the zoom lense:

```camera::FocalPoint := [0, 0, 1]:
camera::ViewingAngle := PI/20:
plot(f, camera):```

We create an animated camera and fly through the scene:

```camera := plot::Camera([-15 + 3*a, 4 - a, 3 +  (a - 4)^2],
[0, 0, 1.5], PI/6, a = 0..8,
Frames = 100, TimeRange = 0..20):
plot(f, camera):```

`delete f, camera:`

## Parameters

 px, py, pz Coordinates of the camera position: numerical real values or arithmetical expressions of the animation parameter a. px, py, pz are equivalent to the attributes PositionX, PositionY, PositionZ. fx, fy, fz Coordinates of the the focal point: numerical real values or arithmetical expressions of the animation parameter a. fx, fy, fz are equivalent to the attributes FocalPointX, FocalPointY, FocalPointZ. angle The opening angle of the lense in radians: a numerical real value or an arithmetical expression of the animation parameter a representing a value between 0 and π. angle is equivalent to the attribute ViewingAngle. a Animation parameter, specified as a = amin..amax, where amin is the initial parameter value, and amax is the final parameter value.