Syntax
CPLN=CPLremconvexcorner(CPL)
Input Parameter
Output Parameter
CPLN : | | contour with removed corners |
Examples
CPLremconvexcorner(PLstar(10))
Copyright 2022-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, CPLremconvexcorner
, is designed to remove single convex corners from a contour represented as a Closed Polygon List (CPL). The function is part of the SolidGeometry library and was introduced to handle issues arising from corners created when cutting squares on a circular path.
Input Parameters
- CPL: The input contour, represented as a Closed Polygon List.
Output Results
- CPLN: The modified contour with convex corners removed.
Algorithm Steps
- Initialize
CPLN
as a copy of the input CPL
.
- Determine the number of separate contours in
CPL
using separateNaN
.
- Iterate over each contour segment:
- Select the
i
-th contour using selectNaN
.
- Correct the contour's orientation to counter-clockwise using
CPLisccwcorrected
.
- Identify convex segments using
CPLconvexseg
.
- Check for patterns of convexity using a sliding window approach:
- For each segment, check if it matches the pattern
[-1 1 -1]
, indicating a convex corner.
- Use
circshift
to adjust the logical array, marking segments to be retained.
- Update the contour by removing marked convex corners.
- Replace the original contour segment in
CPLN
with the updated one using replaceNaN
.
- If no output is requested, plot the original and modified contours for visual comparison.
Example Usage
The function can be called with a contour generated by PLstar(10)
to demonstrate its effect on a star-shaped polygon.
Algorithm explaination created using ChatGPT on 2025-08-19 06: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