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
- CPL: A matrix representing the Closed Polygon Line. It can have either 2 or 3 columns, where the third column, if present, represents the z-coordinate.
- anno: A boolean parameter that determines if plot annotations should be included. Default is true.
- wdth: A numeric value specifying the line width for plotting. Default is 2.
Output
- h: A handle to the drawing and annotation, which can be used for further manipulation or querying of the plot.
Algorithm Steps
- Retrieve the optional parameters
anno
and wdth
using the getfuncparams
function, with default values of true and 2, respectively.
- 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.
- If CPL is empty, return an empty handle
h
.
- Determine the orientation of the polygon using
ispolycw
. This function checks if the polygon is clockwise.
- If
anno
is true, add a plot annotation indicating the color coding: red for counterclockwise (ccw) and green for clockwise (cw).
- Use
separateNaN
to handle multiple polygons separated by NaN values in the CPL.
- Iterate over each separated polygon:
- Extract the i-th polygon using
separateNaN
.
- Add the z-coordinate to the polygon using
VLaddz
.
- Check the orientation using the
cwi
array:
- If the polygon is counterclockwise, plot it in red using
CPLplot
with the style 'r*-'.
- If the polygon is clockwise, plot it in green using
CPLplot
with the style 'g*-'.
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