camlookat

Position camera to view object or group of objects

Syntax

camlookat(object_handles)
camlookat(axes_handle)
camlookat

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 by moving the camera position and camera target while preserving the relative view direction and camera view angle. The viewed object (or objects) roughly fill the axes position rectangle. To change the view, camlookat sets the axes CameraPosition and CameraTarget properties.

Examples

Create three spheres at different locations and then progressively position the camera so that the scene composes around each sphere individually:

% Create three spheres using the sphere function:
[x y z] = sphere;
s1 = surf(x,y,z);
hold on
s2 = surf(x+3,y,z+3);
s3 = surf(x,y,z+6);
% Set the data aspect ratio using daspect:
daspect([1 1 1])
% Set the view:
view(30,10)
% Set the projection type using camproj:
camproj perspective
% Compose the scene around the current axes
camlookat(gca)
pause(2)
% Compose the scene around sphere s1
camlookat(s1)
pause(2)
% Compose the scene around sphere s2
camlookat(s2)
pause(2)
% Compose the scene around sphere s3
camlookat(s3)
pause(2)
camlookat(gca)

See Also

|

Was this topic helpful?