setcamdirection

by Tim C. Lueth, SG-Lib Toolbox: SolidGeometry 5.6 - Visualization
Introduced first in SolidGeometry 5.2, Creation date: 2022-12-13, Last change: 2025-09-15

sets the camera position without changing the camera target



See Also: setcamdistance , setcamtarget , setcamzoom

Example Illustration

 missing image of setcamdirection(T)

Syntax

setcamdirection(T)

Input Parameter

T: ez or HT matrix; only ez is used

Examples


SGbox; pause(1); setcamdirection([1 1 1]); shg




Copyright 2022-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 function, setcamdirection(T), is designed to set the camera position in a 3D plot without altering the camera target. It is part of the SolidGeometry library and was introduced in version 5.2.

Input Parameters

Algorithm Steps

  1. Check the size of the input T:
    • If T is a 4x4 matrix, extract the third column's first three elements as ez.
    • If T is a character string, convert it to ez using the ezofchar function.
    • Otherwise, assume T is already the ez vector.
  2. Retrieve the current camera position (cp) and camera target (ct) from the current axes using get(gca, ...).
  3. Calculate the distance (dd) between the camera position and the camera target using the Euclidean norm.
  4. Compute the new camera position (ncp) by adding the product of dd and ez to the camera target.
  5. Set the camera position to ncp using set(gca, 'CameraPosition', ncp).

This function allows for the adjustment of the camera's direction in a 3D plot, providing flexibility in visualization without altering the focus point.

Algorithm explaination created using ChatGPT on 2025-08-18 22:53. (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