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.

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)
camproj perspective
camlookat(gca) % Compose the scene around the current axes
pause(2)
camlookat(s1)  % Compose the scene around sphere s1
pause(2)
camlookat(s2)  % Compose the scene around sphere s2
pause(2)
camlookat(s3)  % Compose the scene around sphere s3
pause(2)
camlookat(gca)

See Also

campos, camtarget

Controlling the Camera Viewpoint for related functions

Defining Scenes with Camera Graphics for more information

  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS