CPL2ccw

by Tim C. Lueth, SG-Lib Toolbox: SolidGeometry 5.6 - CPL/Closed Polygon Lists
Introduced first in SolidGeometry 5.5, Creation date: 2024-11-14, Last change: 2025-09-15

changes the orientation of all nested CPLs to ccw

Description

Due to some unclear changes in the polyshape class, it is necessary to rely on a clear direction of rotation of the contours within a CPL in the SGLib.

See Also: , CPL2cw

Example Illustration

 missing image of CPL2ccw(CPL)

Syntax

CPLN=CPL2ccw(CPL)

Input Parameter

CPL: CPL with nested CPLS

Output Parameter

CPLN: CPL with nested CPLS all in ccw

Examples


SGfigure; CPLplotcwccw(CPLsample(38))
SGfigure; CPLplotcwccw(CPL2cw(CPLsample(38)))
SGfigure; CPLplotcwccw(CPLCPL2ccwinvert(CPLsample(38)))
SGfigure; CPLplotcwccw(CPLinvert(CPLsample(38)))




Copyright 2024-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, CPL2ccw, is designed to change the orientation of all nested Closed Polygon Lists (CPLs) to counter-clockwise (ccw). It is part of the SolidGeometry library and addresses issues related to the polyshape class.

Input Parameters

Output Results

Algorithm Steps

  1. The function begins by calling poly2ccw with the x and y coordinates extracted from the input CPL. This function reorders the vertices to ensure a counter-clockwise orientation.
  2. The reordered x and y coordinates are combined into a new matrix, CPLN.
  3. If no output argument is specified (i.e., nargout==0), the function proceeds to visualize the result:
    • SGfigure(0,90) is called to set up a figure window with specific parameters.
    • CPLplotcolors is used to plot the CPLN with a red star-line style ('r*-').

Example Usage

The function can be called with a sample CPL as follows:

CPL2ccw(CPLsample(44))

This will convert the orientation of the sample CPL to counter-clockwise.

Algorithm explaination created using ChatGPT on 2025-08-18 22:47. (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