CPLisccw
by Tim C. Lueth, SG-Lib Toolbox: SolidGeometry 5.6 - Analytical Geometry
Introduced first in SolidGeometry 2.0, Creation date: 2014-12-05, Last change: 2025-09-14
returns index list for CPL direction
Description
the same as ~ispolycw
This function is unchanged and valid even with the new polyshape concept
See Also: CPLisccwinout
, CPLsortinout
, CPLisccwcorrected
, CPLsetallcw
Example Illustration
Syntax
[cwi,nani]=CPLisccw(CPL)
Input Parameter
Output Parameter
cwi: | | counter-clockwise index |
nani: | | NAN-indices |
Examples
CPLisccw(CPLsample(11))
Copyright 2014-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, CPLisccw, determines the counter-clockwise orientation of a closed polygonal line (CPL) and identifies any NaN indices within the input data.
Input Parameters
- CPL: A matrix representing the closed polygonal line, where each row corresponds to a vertex with x and y coordinates.
Output Results
- cwi: A logical index indicating whether the polygon is counter-clockwise.
- nani: An array of indices where NaN values are found in the CPL, marking the separation between different polygonal segments.
Algorithm Steps
- Check if the input
CPL is empty. If it is, set cwi to false and nani to an empty array, then return.
- Determine the orientation of the polygon using the
ispolycw function from the Mapping Toolbox. The result is negated to get the counter-clockwise index cwi.
- Identify NaN indices in the first column of
CPL to separate different polygonal segments. Store these indices in nani, including the start (0) and end (size of CPL + 1) indices.
- If no output arguments are specified, visualize the polygon:
- Open a new figure using
SGfigure.
- Annotate the plot with a legend indicating red for counter-clockwise and green for clockwise.
- Separate the
CPL into segments using separateNaN.
- For each segment, plot it in red if counter-clockwise or green if clockwise using
CPLplot.
- Mark the first two vertices with magenta and blue stars using
VLplot.
- Label the first two vertices with
textVL.
Algorithm explaination created using ChatGPT on 2025-08-19 07: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