3-D Visualization Previous page   Next Page

Moving In and Out on the Scene

You can move the camera anywhere in the 3-D space defined by the axes. The camera continues to point towards the target regardless of its position. When the camera moves, MATLAB varies the camera view angle to ensure the scene fills the position rectangle.

Moving Through a Scene

You can create a fly-by effect by moving the camera through the scene. To do this, continually change CameraPosition property, moving it toward the target. Because the camera is moving through space, it turns as it moves past the camera target. Override the MATLAB automatic resizing of the scene each time you move the camera by setting the CameraViewAngleMode to manual.

If you update the CameraPosition and the CameraTarget, the effect is to pass through the scene while continually facing the direction of movement.

If the Projection is set to perspective, the amount of perspective distortion increases as the camera gets closer to the target and decreases as it gets farther away.

Example -- Moving Toward or Away from the Target

To move the camera along the viewing axis, you need to calculate new coordinates for the CameraPosition property. This is accomplished by subtracting (to move closer to the target) or adding (to move away from the target) some fraction of the total distance between the camera position and the camera target.

The function movecamera calculates a new CameraPosition that moves in on the scene if the argument dist is positive and moves out if dist is negative.

Note that setting the CameraViewAngleMode to manual overrides MATLAB stretch-to-fill behavior and can cause an abrupt change in the aspect ratio. See Understanding Axes Aspect Ratio for more information on stretch-to-fill.


Previous page  Default Viewpoint Selection Making the Scene Larger or Smaller Next page

© 1994-2005 The MathWorks, Inc.