Position the camera to view an object or group of objects
Syntax
Description
camlookat(object_handles) views the objects identified in the vector object_handles. The vector can contain the handles of axes children.
camlookat(axes_handle) views the objects that are children of the axes identified by axes_handle.
camlookat views the objects that are in the current axes.
Remarks
camlookat moves the camera position and camera target while preserving the relative view direction and camera view angle. The object (or objects) being viewed roughly fill the axes position rectangle.
camlookat sets the axes CameraPosition and CameraTarget properties.
Examples
This example creates three spheres at different locations and then progressively positions the camera so that each sphere is the object around which the scene is composed:
[x y z] =
sphere;
s1 = surf(x,y,z);
hold on
s2 = surf(x+3,y,z+3);
s3 = surf(x,y,z+6);daspect([1 1 1])view(30,10)camprojperspective
camlookat(gca) % Compose the scene around the current axes
pause(2)
camlookat(s1) % Compose the scene around spheres1pause(2)
camlookat(s2) % Compose the scene around spheres2pause(2)
camlookat(s3) % Compose the scene around spheres3pause(2)
camlookat(gca)
Rotate the camera position around the camera target
Syntax
camorbit(dtheta,dphi)
camorbit(dtheta,dphi,'coordsys')
camorbit(dtheta,dphi,'coordsys','direction')
camorbit(axes_handle,...)
Description
rotates the camera position around the camera target by the amounts specified in camorbit(dtheta,dphi) dtheta and dphi (both in degrees). dtheta is the horizontal rotation and dphi is the vertical rotation.
camorbit(dtheta,dphi,' The coordsys') coordsys argument determines the center of rotation. It can take on two values:
data(default) - rotate the camera around an axis defined by the camera target and thedirection(default is the positive z direction).camera- rotate the camera about the point defined by the camera target.
camorbit(dtheta,dphi,' The coordsys','direction') direction argument, in conjunction with the camera target, defines the axis of rotation for the data coordinate system. Specify direction as a three-element vector containing the x, y, and z-components of the direction or one of the characters, x, y, or z, to indicate [1 0 0], [0 1 0], or [0 0 1] respectively.
camorbit(axes_handle,...) operates on the axes identified by the first argument, axes_handle. When you do not specify an axes handle, camorbit operates on the current axes.
Examples
Compare rotation in the two coordinate systems with these for loops. The first rotates the camera horizontally about a line defined by the camera target point and a direction that is parallel to the y-axis. Visualize this rotation as a cone formed with the camera target at the apex and the camera position forming the base:
Rotation in the camera coordinate system orbits the camera around the axes along a circle while keeping the center of a circle at the camera target.
| MATLAB Function Reference | ![]() |
Rotate the camera target around the camera position
Syntax
campan(dtheta,dphi)
campan(dtheta,dphi,'coordsys')
campan(dtheta,dphi,'coordsys','direction')
campan(axes_handle,...)
Description
rotates the camera target around the camera position by the amounts specified in campan(dtheta,dphi) dtheta and dphi (both in degrees). dtheta is the horizontal rotation and dphi is the vertical rotation.
campan(dtheta,dphi,' The coordsys') coordsys argument determines the center of rotation. It can take on two values:
data(default) - rotate the camera target around an axis defined by the camera position and thedirection(default is the positive z direction)camera- rotate the camera about the point defined by the camera target.
campan(dtheta,dphi,' The coordsys','direction') direction argument, in conjunction with the camera position, defines the axis of rotation for the data coordinate system. Specify direction as a three-element vector containing the x, y, and z-components of the direction or one of the characters, x, y, or z, to indicate [1 0 0], [0 1 0], or [0 0 1] respectively.
campan(axes_handle,...) operates on the axes identified by the first argument, axes_handle. When you do not specify an axes handle, campan operates on the current axes.


No comments:
Post a Comment