Syntax
[P,pin,AL,DL,C]=PLminangle(PL,[in0,C,at])
Input Parameter
PL : | | Point Liste |
in0 : | | false=[-pi..+pi]; true=[0..2*pi]; default is false |
C : | | optional center point |
at : | | angle threshold; default is pi/100 |
Output Parameter
P : | | Point with minimal y and minimal x |
pin : | | find index in PL |
AL : | | Angle list |
DL : | | Distance from Center List |
C : | | Center Point |
Examples
PLminangle(CPLspiral(10,20,8*pi))
PLminabgle(CPLspiral(10,20,8*pi),true)
PLminangle(CPLspiral(10,20,8*pi),true,[0 0])
[~,ci]=PLminyx(CPLB); CPLB=circshift(CPLB,-(ci-1));
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 PLminangle
is designed to find the point in a list of points (PL) that has the minimal angle with respect to a specified center point. It also returns the index of this point, a list of angles, distances from the center, and the center point itself.
Input Parameters
- PL: A list of points (Point List).
- in0: A boolean indicating the angle range. If false, angles are in the range [-pi, +pi]. If true, angles are in the range [0, 2*pi]. The default is false.
- C: An optional center point. If not provided, the center is calculated from the point list.
- at: An angle threshold, with a default value of pi/100.
Output Results
- P: The point with the minimal angle value.
- pin: The index of the point in the point list.
- AL: A list of angles for each point in the list.
- DL: A list of distances from the center for each point.
- C: The center point used for calculations.
Algorithm Steps
- Check if the point list
PL
contains more than one contour using separateNaN
. If it does, an error is raised.
- Set default values for
in0
, C
, and at
if they are not provided in the input.
- Calculate the difference
DL
between each point in PL
and the center C
.
- Compute the angle list
AL
using the atan2
function and round it by the angle threshold at
.
- If
in0
is true, adjust negative angles by adding 2*pi.
- Normalize the distances
DL
using PLnorm
.
- Sort the points by angle and distance, and find the index
pin
of the point with the minimal angle.
- Return the point
P
at index pin
from the point list PL
.
- If no output is requested, plot the points, highlighting the point with the minimal angle.
Algorithm explaination created using ChatGPT on 2025-08-19 08:20. (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