Syntax
h=camlightTL
Output Parameter
h : | | handle to three camlights |
Examples
SGfigure; SGplot(SGbox(4)); view(-30,30);
camlightTL
Copyright 2018-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 camlightTL
is designed to manage lighting in a 3D plot in MATLAB. It deletes existing camlights and sets up new ones based on the specified mode.
Input Parameters
- varargin: A variable input argument that can specify the mode of operation. If provided, it should be a string indicating the mode, such as 'on'.
Algorithm Steps
- Initialize the mode to 'on'. If an argument is provided, use it to set the mode. Convert the mode to lowercase for consistency.
- Retrieve all children of the current axes using
get(gca,'Children')
.
- Find all objects of type 'Light' among the children and delete them using
findobj
and delete
.
- Initialize an empty array
h
to store handles to the new camlights.
- If the mode is 'on', proceed to set up new camlights:
- Calculate the current azimuth and elevation using
view
.
- Define a variable
dw
with a value of 60, which is used to adjust the azimuth and elevation for the new lights.
- Create four camlights at different azimuth and elevation angles using
camlight
with the 'infinite' style:
h1
: Azimuth - az-dw
, Elevation - ez-dw
h2
: Azimuth - az-dw
, Elevation - ez+dw
h3
: Azimuth - az+dw
, Elevation - ez+dw
h4
: Azimuth - az+dw
, Elevation - ez-dw
- Store the handles of these camlights in the array
h
.
Output
- h: A handle to the newly created camlights.
Example Usage
To use this function, you can create a figure and plot a 3D object, then call camlightTL
to set up the lighting:
SGfigure;
SGplot(SGbox(4));
view(-30,30);
camlightTL;
Algorithm explaination created using ChatGPT on 2025-08-19 07:52. (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