camangle

by Tim C. Lueth, SG-Lib Toolbox: SolidGeometry 5.6 - Visualization
Introduced first in SolidGeometry 3.8, Creation date: 2017-05-05, Last change: 2025-09-14

sets the camera angle and edjust the distance so that there is almost no change in the image

Description

The default camera angle of matlab in figure is about 9 degrees. in rotate3D mode the DISTANCE between the camera and the target is set so that the axes fill the figure. If the camerawinkel is set manually larger and the distance smaller then with the next rotation the camera is set again so far away that with 9 degrees the picture would be filled. It therefore makes more sense to leave the camera opening angle at 9 degrees and to reduce the distance for zooming.

See Also: camset

Example Illustration

 missing image of camangle(a)

Syntax

a=camangle([a])

Input Parameter

a: Camera angle

Output Parameter

a: Camera angle

Examples


SGbox; camangle (45); rotate3d on
SGbox; camangle (9); rotate3d on
get(gca,'CameraViewAngle')




Copyright 2017-2025 Tim C. Lueth. All rights reserved. The code is the property of Tim C. Lueth and may not be redistributed or modified without explicit written permission. This software may be used free of charge for academic research and teaching purposes only. Commercial use, redistribution, modification, or reverse engineering is strictly prohibited. Access to source code is restricted and granted only under specific agreements. For licensing inquiries or commercial use, please contact: Tim C. Lueth

Algorithm (Workflow)

This algorithm is designed to set the camera angle in a MATLAB figure and adjust the camera distance to maintain a consistent image view. The function is part of the SolidGeometry library and is used for visualization purposes.

Input Parameters

Output Results

Algorithm Steps

  1. Retrieve the camera angle parameter using the getfuncparams function. If no angle is provided, default to 9 degrees.
  2. Set the camera position, target, and view angle modes to "manual" to prevent automatic adjustments by MATLAB.
  3. Get the current camera view angle, position, and target from the current axes using get(gca,...).
  4. Calculate the scaling factor k as the ratio of the desired angle a to the current angle ca.
  5. Compute the new camera position cpn by adjusting the current position cp relative to the target ct using the scaling factor k.
  6. Set the new camera position and view angle using set(gca,...) to apply the changes.

Example Usage

To use this function, you can execute the following commands in MATLAB:

SGbox; camangle(45); rotate3d on
SGbox; camangle(9); rotate3d on
get(gca,'CameraViewAngle')

This example demonstrates setting the camera angle to 45 degrees and then back to 9 degrees, with 3D rotation enabled.

Algorithm explaination created using ChatGPT on 2025-08-19 07:21. (Please note: No guarantee for the correctness of this explanation)

Last html export of this page out of FM database by TL: 2025-09-21