CPLplotcwccw

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

plots a CPL in different colors depending on the orientation



See Also: CPLisccw , CPLplotinout , CPLisccwinout , CPLsortinout , CPLisccw , CPLisccwcorrected , CPLsetallcw

Example Illustration

 missing image of CPLplotcwccw(CPL,anno,wdth)

Syntax

h=CPLplotcwccw(CPL,[anno,wdth])

Input Parameter

CPL: Closed Polygon Line
anno: if true; there is a plotannotation
wdth: line width

Output Parameter

h: handle to drawing and annotation

Examples


CPL=CPLsample(13);
SGfigure; CPLplotcwccw(CPL); textCVL(CPL);
SGfigure; CPLplotcwccw(CPLflipud(CPL)); textCVL(CPL);




Copyright 2019-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, CPLplotcwccw, is designed to plot a Closed Polygon Line (CPL) in different colors based on its orientation, either clockwise (cw) or counterclockwise (ccw).

Input Parameters

Output

Algorithm Steps

  1. Retrieve the optional parameters anno and wdth using the getfuncparams function, with default values of true and 2, respectively.
  2. Check if the CPL has three columns. If so, calculate the mean of the third column to determine the z-coordinate, and reduce CPL to its first two columns.
  3. If CPL is empty, return an empty handle h.
  4. Determine the orientation of the polygon using ispolycw. This function checks if the polygon is clockwise.
  5. If anno is true, add a plot annotation indicating the color coding: red for counterclockwise (ccw) and green for clockwise (cw).
  6. Use separateNaN to handle multiple polygons separated by NaN values in the CPL.
  7. Iterate over each separated polygon:
Algorithm explaination created using ChatGPT on 2025-08-19 06:53. (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