Syntax
AL=angleshift(AL,[ival])
Input Parameter
AL : | | List of angle values |
ival : | | [-pi..+pi] or [0 2*pi]; or [ival ival+2*pi]; default is [0 2*pi] |
Output Parameter
AL : | | Alle values inside the allowed interval |
Examples
AL=rand(10,2)*3*pi,
angleshift(AL)
angleshift(AL,[pi +pi) % [-pi ... pi]
angleshift(AL,[0 2*pi]) % [0 ...2*pi]
angleshift(AL,2) % [2 ... 2+2*pi]
Copyright 2021-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, angleshift
, is designed to shift angle values into a specified interval. It is part of the SolidGeometry library and was introduced in version 5.1.
Input Parameters
- AL: A list of angle values that need to be shifted.
- ival: An optional parameter specifying the interval. It can be:
- [-pi..+pi]
- [0 2*pi]
- [ival ival+2*pi]
The default interval is [0 2*pi].
Output Results
- AL: All angle values are adjusted to fit within the specified interval.
Algorithm Steps
- Store the original angle list
AL
in ALorg
.
- Determine the interval
ival
using the function getfuncparams
. If ival
is a single value, extend it to a full interval by adding 2*pi
.
- Iterate over each angle in
AL
:
- If an angle is less than the lower bound of
ival
, add 2*pi
until it falls within the interval.
- If an angle is greater than the upper bound of
ival
, subtract 2*pi
until it falls within the interval.
- If no output is requested (
nargout==0
), print a debug message showing the interval and display a table comparing original and new angle values.
Example Usage
AL = rand(10,2) * 3 * pi;
angleshift(AL);
angleshift(AL, [-pi +pi]); % Shifts angles to [-pi ... pi]
angleshift(AL, [0 2*pi]); % Shifts angles to [0 ... 2*pi]
angleshift(AL, 2); % Shifts angles to [2 ... 2+2*pi]
Algorithm explaination created using ChatGPT on 2025-08-19 01:17. (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