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
- p: The target point for the camera. If not specified, the user is prompted to select a point using a crosshair. Default is an empty array.
- d: The diameter of the axis around the target point. Default is 1/10 of the current view's largest dimension.
- ez: The direction vector from the camera to the target point. Default is the vector from the current camera position to the target point.
Algorithm Steps
- Initialize
p
to an empty array. If the first argument is provided and not empty, set p
to this value.
- If
p
is empty, prompt the user to select a point using ginput
and select3d
. If still empty, exit the function.
- Retrieve the current axis limits. If the axis is 2D, extend it to 3D by adding zeros.
- Calculate the default diameter
d
as 1/10 of the largest dimension of the current view.
- 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.
- Get the current camera position and calculate the distance
r
to the target point p
.
- 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
.
- Set the camera target to
p
.
- Adjust the axis limits to center around
p
with the specified diameter d
.
- Set the camera position to
p + r * ez
.
- 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].
- 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