3-D Visualization Previous page   Next Page

Rotation About the Viewing Axis

You can change the orientation of the scene by specifying the direction defined as up. By default, MATLAB defines up as the y-axis in 2-D views (the CameraUpVector is [0 1 0]) and the z-axis for 3-D views (the CameraUpVector is [0 0 1]). However, you can specify up as any arbitrary direction.

The vector defined by the CameraUpVector property forms one axis of the camera's coordinate system. Internally, MATLAB determines the actual orientation of the camera up vector by projecting the specified vector onto the plane that is normal to the camera direction (i.e., the viewing axis). This simplifies the specification of the CameraUpVector property, because it need not lie in this plane.

In many cases, you might find it convenient to visualize the desired up vector in terms of angles with respect to the axes x-, y-, and z-axis. You can then use direction cosines to convert from angles to vector components. For a unit vector, the expression simplifies to

where the angles alpha, beta, and gamma are specified in degrees.

(Consult a mathematics book on vector analysis for a more detailed explanation of direction cosines.)

Example -- Calculating a Camera Up Vector

To specify an up vector that makes an angle of 30° with the z-axis and lies in the y-z plane, use the expression

upvec = [cos(90*(pi/180)),cos(60*(pi/180)),cos(30*(pi/180))];

and then set the CameraUpVector property.

Drawing a sphere with this orientation produces


Previous page  Rotation Without Resizing of Graphics Objects View Projection Types Next page

© 1994-2005 The MathWorks, Inc.