Syntax
con=CPLconvexseg(CPL)
Input Parameter
Output Parameter
con : | | array of convex and concave |
Examples
CPLconvexseg(PLcircle(10,6))
CPLconvexseg(flipud(PLcircle(10,6)))
CPLconvexseg(PLsample(9))
CPLconvexseg(CPLsample(3))
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, CPLconvexseg
, is designed to analyze a Closed Point List (CPL) and determine the segments that are convex or concave. The function is part of the SolidGeometry library and was introduced in version 3.9.
Input Parameters
- CPL: A single point list representing a closed polygonal line.
Output
- con: An array indicating the convexity or concavity of each segment in the CPL. Values are +1 for convex (in counter-clockwise orientation) and -1 for concave.
Algorithm Steps
- Initialize the output array
con
with the first column of CPL
.
- Determine the number of separate NaN-separated segments in
CPL
using separateNaN
.
- Iterate over each segment:
- For each segment, replace NaN values in
con
with the result of PLconvexseg
applied to the segment.
- If no output argument is specified, plot the CPL:
- Use
SGfigure
to create a new figure and set the view to 2D.
- Plot the original CPL in red.
- Plot concave segments in green and convex segments in blue.
- Add annotations to the plot to indicate the meaning of the colors.
Additional Notes
The function assumes a counter-clockwise (ccw) orientation for determining convexity and concavity. The same function can be used for NaN-separated CPLs, similar to PLconvexseg
.
Algorithm explaination created using ChatGPT on 2025-08-19 01:18. (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