CPLconvexseg

by Tim C. Lueth, SG-Lib Toolbox: SolidGeometry 5.6 - CPL/Closed Polygon Lists
Introduced first in SolidGeometry 3.9, Creation date: 2017-06-01, Last change: 2025-09-14

returns the segments of convex and concave contours a CPL.

Description

ATTENTION. Convex and concave are related to ccw orientation
+1 = convex (for ccw) [= concave for cw]
-1 = concave (for ccw) [= convex for cw]
Same function as PLconvexseg for NAN separated CPLs

See Also: , PLconvexseg , CPLdecompose , PLdecompose

Example Illustration

 missing image of CPLconvexseg(CPL)

Syntax

con=CPLconvexseg(CPL)

Input Parameter

CPL: Single Point List

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

Output

Algorithm Steps

  1. Initialize the output array con with the first column of CPL.
  2. Determine the number of separate NaN-separated segments in CPL using separateNaN.
  3. Iterate over each segment:
    • For each segment, replace NaN values in con with the result of PLconvexseg applied to the segment.
  4. 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