CPLorder

by Tim C. Lueth, SG-Lib Toolbox: SolidGeometry 5.6 - Auxiliary function
Introduced first in SolidGeometry 2.0, Creation date: 2014-12-05, Last change: 2025-09-14

returns an xy ordered and shifted CPL

Description

0) The CPLs are splited by CPLsplitpoints similar to CPLrepair
1) The order of the contours in CPL is sorted by minx-miny or maxx-maxy of the respective contour
2) The starting point of each contour of CPL is shifted to start with minx-miny or maxx-maxy.
3) The orientation of the contours remains unchainged

See Also: , CPLsortinout

Example Illustration

 missing image of CPLorder(CPL,smax)

Syntax

NCPL=CPLorder(CPL,[smax])

Input Parameter

CPL: Closed Polygon List (including NaN)
smax: max if true, min if false; default is false

Output Parameter

NCPL: Ordered closed polygon list

Examples

CPLsample(11); CPL=ans;
CPLo=CPLunsort(CPLo);

CPL=CPLo; SGfigure(0,90); CPLplotcwccw(CPL); textCPL(CPL); % Original
CPL=CPLorder(CPLo); SGfigure(0,90); CPLplotcwccw(CPL); textCPL(CPL); % CPLorder




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

Last html export of this page out of FM database by TL: 2025-09-21