camset

by Tim C. Lueth, SG-Lib Toolbox: SolidGeometry 5.6 - User interface
Introduced first in SolidGeometry 3.4, Creation date: 2017-02-21, Last change: 2025-09-14

sets the camera target to inspect a specific target point

Description

if no position is specified, the user will be requested to select a point by a cross hair

See Also: zoompatch , camplot , tcamera

Example Illustration

 missing image of camset (p,d,ez)

Syntax

camset([p,d,ez])

Input Parameter

p: point; default is '';
d: diameter of axis; default is 1/10 of the current view
ez: direction to camera position;

Examples


camset ('',100); camplot;




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 function, camset, is designed to set the camera target in a 3D plot to inspect a specific target point. It is part of the SolidGeometry library and was introduced in version 3.4.

Input Parameters

Algorithm Steps

  1. Initialize p to an empty array. If the first argument is provided and not empty, set p to this value.
  2. If p is empty, prompt the user to select a point using ginput and select3d. If still empty, exit the function.
  3. Retrieve the current axis limits. If the axis is 2D, extend it to 3D by adding zeros.
  4. Calculate the default diameter d as 1/10 of the largest dimension of the current view.
  5. If the second argument is provided and not empty, set d to this value. If d is a scalar, convert it to a 3-element vector.
  6. Get the current camera position and calculate the distance r to the target point p.
  7. Calculate the default direction vector ez from the camera to the target point. If the third argument is provided and not empty, set ez to this value. Normalize ez.
  8. Set the camera target to p.
  9. Adjust the axis limits to center around p with the specified diameter d.
  10. Set the camera position to p + r * ez.
  11. Determine the camera up vector based on the current view angle. If the angle is greater than 85 degrees, set the up vector to [0 1 0], otherwise [0 0 1].
  12. Refresh the figure window with shg.
Algorithm explaination created using ChatGPT on 2025-08-19 07:01. (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