Set or query the camera position
Syntax
Description
with no arguments returns the camera position in the current axes. campos
sets the position of the camera in the current axes to the specified value. Specify the position as a three-element vector containing the x-, y-, and z-coordinates of the desired location in the data units of the axes. campos([camera_position])
campos('mode')
returns the value of the camera position mode, which can be either auto
(the default) or manual
.
campos('auto')
sets the camera position mode to auto
.
campos('manual')
sets the camera position mode to manual
.
campos(axes_handle,...)
performs the set or query on the axes identified by the first argument, axes_handle
. When you do not specify an axes handle, campos
operates on the current axes.
Remarks
campos
sets or queries values of the axes CameraPosition
and CameraPositionMode
properties. The camera position is the point in the Cartesian coordinate system of the axes from which you view the scene.
Examples
This example moves the camera along the x-axis in a series of steps:
camproj
Set or query the projection type
Syntax
Description
The projection type determines whether MATLAB uses a perspective or orthographic projection for 3-D views.
with no arguments returns the projection type setting in the current axes. camproj
sets the projection type in the current axes to the specified value. Possible values for camproj('
projection_type
')
projection_type
are: orthographic
and perspective
.
camproj(axes_handle,...)
performs the set or query on the axes identified by the first argument, axes_handle
. When you do not specify an axes handle, camproj
operates on the current axes.
Set or query the projection type
Syntax
Description
The projection type determines whether MATLAB uses a perspective or orthographic projection for 3-D views.
with no arguments returns the projection type setting in the current axes. camproj
sets the projection type in the current axes to the specified value. Possible values for camproj('
projection_type
')
projection_type
are: orthographic
and perspective
.
camproj(axes_handle,...)
performs the set or query on the axes identified by the first argument, axes_handle
. When you do not specify an axes handle, camproj
operates on the current axes.
Set or query the location of the camera target
Syntax
camtarget
camtarget([camera_target])
camtarget('mode')
camtarget('auto')
camtarget('manual')
camtarget(axes_handle,...)
Description
The camera target is the location in the axes that the camera points to. The camera remains oriented toward this point regardless of its position.
with no arguments returns the location of the camera target in the current axes. camtarget
sets the camera target in the current axes to the specified value. Specify the target as a three-element vector containing the x-, y-, and z-coordinates of the desired location in the data units of the axes. camtarget([camera_target])
camtarget('mode')
returns the value of the camera target mode, which can be either auto
(the default) or manual
.
camtarget('auto')
sets the camera target mode to auto
.
camtarget('manual')
sets the camera target mode to manual
.
camtarget(axes_handle,...)
performs the set or query on the axes identified by the first argument, axes_handle
. When you do not specify an axes handle, camtarget
operates on the current axes.
Remarks
camtarget
sets or queries values of the axes object Cameratarget
and CameraTargetMode
properties.
When the camera target mode is auto
, MATLAB positions the camera target at the center of the axes plot box.
Examples
This example moves the camera position and the camera target along the x-axis in a series of steps:
surf(peaks);
axis vis3d
xp = linspace(-150,40,50);
xt = linspace(25,50,50);
for i=1:50
campos([xp(i),25,5]);
camtarget([xt(i),30,0])
drawnow
end
Set or query the camera up vector
Syntax
Description
The camera up vector specifies the direction that is oriented up in the scene.
with no arguments returns the camera up vector setting in the current axes. camup
sets the up vector in the current axes to the specified value. Specify the up vector as x-, y-, and z-components. See Remarks.camup([up_vector])
camup('mode')
returns the current value of the camera up vector mode, which can be either auto
(the default) or manual
.
camup('auto')
sets the camera up vector mode to auto
. In auto
mode, MATLAB uses a value for the up vector of [0 1 0]
for 2-D views. This means the z-axis points up.
camup('manual')
sets the camera up vector mode to manual
. In manual
mode, MATLAB does not change the value of the camera up vector.
camup(axes_handle,...)
performs the set or query on the axes identified by the first argument, axes_handle
. When you do not specify an axes handle, camup
operates on the current axes.
Remarks
camup
sets or queries values of the axes object CameraUpVector
and CameraUpVectorMode
properties.
Specify the camera up vector as the x-, y-, and z-coordinates of a point in the axes coordinate system that forms the directed line segment PQ, where P is the point (0,0,0) and Q is the specified x-, y-, and z-coordinates. This line always points up. The length of the line PQ has no effect on the orientation of the scene. This means a value of [0 0 1]
produces the same results as [0 0 25]
.
Set or query the camera view angle
Syntax
Description
The camera view angle determines the field of view of the camera. Larger angles produce a smaller view of the scene. You can implement zooming by changing the camera view angle.
with no arguments returns the camera view angle setting in the current axes. camva
sets the view angle in the current axes to the specified value. Specify the view angle in degrees.camva(view_angle)
camva('mode')
returns the current value of the camera view angle mode, which can be either auto
(the default) or manual
. See Remarks.
camva('auto')
sets the camera view angle mode to auto
.
camva('manual')
sets the camera view angle mode to manual
. See Remarks.
camva(axes_handle,...)
performs the set or query on the axes identified by the first argument, axes_handle
. When you do not specify an axes handle, camva
operates on the current axes.
Remarks
camva
sets or queries values of the axes object CameraViewAngle
and CameraViewAngleMode
properties.
When the camera view angle mode is auto
, MATLAB adjusts the camera view angle so that the scene fills the available space in the window. If you move the camera to a different position, MATLAB changes the camera view angle to maintain a view of the scene that fills the available area in the window.
Setting a camera view angle or setting the camera view angle to manual
disables the MATLAB stretch-to-fill feature (stretching of the axes to fit the window). This means setting the camera view angle to its current value,
can cause a change in the way the graph looks. See the Remarks section of the axes
reference page for more information.
Examples
This example creates two pushbuttons, one that zooms in and another that zooms out.
uicontrol('Style','pushbutton',...
'String','Zoom In',...
'Position',[20 20 60 20],...
'Callback','if camva <= 1;return;else;camva(camva-1);end');
uicontrol('Style','pushbutton',...
'String','Zoom Out',...
'Position',[100 20 60 20],...
'Callback','if camva >= 179;return;else;camva(camva+1);end');
Now create a graph to zoom in and out on:
Note the range checking in the callback statements. This keeps the values for the camera view angle in the range, greater than zero and less than 180.
Syntax
Description
zooms in or out on the scene depending on the value specified by camzoom(zoom_factor)
zoom_factor
. If zoom_factor
is greater than 1, the scene appears larger; if zoom_factor
is greater than zero and less than 1, the scene appears smaller.
camzoom(axes_handle,...)
operates on the axes identified by the first argument, axes_handle
. When you do not specify an axes handle, camzoom
operates on the current axes.
Remarks
camzoom
sets the axes CameraViewAngle
property, which in turn causes the CameraViewAngleMode
property to be set to manual
. Note that setting the CameraViewAngle
property disables the MATLAB stretch-to-fill feature (stretching of the axes to fit the window). This may result in a change to the aspect ratio of your graph. See the axes
function for more information on this behavior.
No comments:
Post a Comment