Main Content

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

collapse all

Create three spheres. Then set the data aspect ratio, the view, and the projection type.

[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)
camproj perspective

Figure contains an axes object. The axes object contains 3 objects of type surface.

Compose the scene around sphere s1.

camlookat(s1)

Figure contains an axes object. The axes object contains 3 objects of type surface.

Compose the scene around sphere s2.

camlookat(s2)

Figure contains an axes object. The axes object contains 3 objects of type surface.

Compose the scene around sphere s3.

camlookat(s3)

Figure contains an axes object. The axes object contains 3 objects of type surface.

Version History

Introduced before R2006a