Tofgca

by Tim C. Lueth, SG-Lib Toolbox: SolidGeometry 5.6 - Analytical Geometry
Introduced first in SolidGeometry 3.8, Creation date: 2017-05-02, Last change: 2025-08-19

returns the HT matrix of the current camera position

Description

Tofgca returns the current axis's camera values as HT Matrix
Tofcam returns either for given or the current axis's camera values as HT Matrix

See Also: , Tofcam , camplot , camset , Tofcam , tcamera

Example Illustration

 missing image of Tofgca

Syntax

[T,Tt,va,ax]=Tofgca

Output Parameter

T: HT matrix of camera coordinate system
Tt: HT of target coordinate system
va: current camera angle
ax: current camera axis

Examples

Just try
SGfigure; SGplot(SGsample(1)); pause (1); Tofgca; pause(1); axis tight; view(-30,30)




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)

The function Tofgca is designed to return the homogeneous transformation (HT) matrix of the current camera position in a MATLAB figure. It is part of the SolidGeometry library and provides information about the camera's orientation and position in the 3D space.

Input Parameters

The function does not take any input parameters. It operates on the current axis of the active figure in MATLAB.

Output Parameters

Algorithm Steps

  1. Retrieve the current camera position, target, up vector, and view angle using get(gca,...).
  2. Calculate the camera's direction vector ez by subtracting the camera position from the target and normalizing it.
  3. Compute the right vector ex as the cross product of the up vector and ez, then normalize it.
  4. Determine the up vector ey as the cross product of ez and ex, then normalize it.
  5. Construct the HT matrix T using ex, ey, ez, and the camera position.
  6. Adjust the camera up vector to ey.
  7. Set Tt to T and modify it to represent the target coordinate system by adjusting the translation and rotation components.
  8. Retrieve the current axis limits and store them in ax.
  9. If no output is requested, visualize the camera and target using helper functions like tplot and SGplot.

Visualization

If the function is called without output arguments, it visualizes the camera and target in the current figure. It uses the camera's position and target to plot a cone representing the camera's field of view and updates the axis limits accordingly.

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