Syntax
NCPL=CPLinvert(CPL,[add])
Input Parameter
CPL : | | Closed Polygon List separated by NaN |
add : | | frame around with distance add; default=0; no frame |
Output Parameter
NCPL : | | Closed Polygon List reversed direction |
Examples
SGfigure; CPLplotcwccw(CPLsample(38))
SGfigure; CPLplotcwccw(CPL2cw(CPLsample(38)))
SGfigure; CPLplotcwccw(CPLCPL2ccwinvert(CPLsample(38)))
SGfigure; CPLplotcwccw(CPLinvert(CPLsample(38)))
Copyright 2015-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 algorithm is designed to invert the direction of all contours in a Closed Polygon List (CPL). It is part of the SolidGeometry library and was developed by Tim Lueth.
Input Parameters
- CPL: A Closed Polygon List where individual polygons are separated by NaN values.
- add: An optional parameter that specifies a frame around the polygons with a distance of 'add'. The default value is 0, meaning no frame is added.
Output
- NCPL: The Closed Polygon List with reversed direction for each contour.
Algorithm Steps
- Initialize the 'add' parameter to 0. If a second argument is provided and is not empty, set 'add' to this value.
- Determine the number of contours in the CPL using the 'separateNaN' function.
- Initialize NCPL as a copy of CPL.
- For each contour in the CPL:
- Extract the contour using 'separateNaN'.
- Reverse the order of the points in the contour using 'flipud'.
- Replace the original contour in NCPL with the reversed contour.
- If 'add' is greater than 0:
- Calculate the bounding box of the CPL with an additional margin defined by 'add'.
- Prepend this bounding box as a new contour to NCPL.
- If no output argument is specified:
- Create a new figure using 'SGfigure'.
- Plot the original CPL in green and the inverted NCPL in red using 'CPLplot'.
- Set the view to a top-down perspective.
- Display the original CPL in the command window.
Algorithm explaination created using ChatGPT on 2025-08-19 07:00. (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