CPLisidenticalregistered
by Tim C. Lueth, SG-Lib Toolbox: SolidGeometry 5.6 - CPL/Closed Polygon Lists
Introduced first in SolidGeometry 5.4, Creation date: 2023-12-20, Last change: 2025-09-15
Compares two CPLS in the same orientation and size
See Also: TregisterConvexHull
, CPLisidenticalcontour
Example Illustration
Syntax
[b,A]=CPLisidenticalregistered(CPLA,CPLB,[tol])
Input Parameter
CPLA: | | 1st CPL |
CPLB: | | 2nd CPL |
tol: | | tolerance in relative difference area; default is 0.1 |
Output Parameter
b: | | logical information |
A: | | difference in area |
Examples
CPL=CPLbox(10,'A');
CPLisidenticalregistered(CPL,PLtransP(CPL,[10 10]))
CPLisidenticalregistered(CPL,PLtransP(CPLbox(10),[10 10]))
Copyright 2023-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, CPLisidenticalregistered, compares two closed polygon lists (CPLs) to determine if they are identical in orientation and size, within a specified tolerance.
Input Parameters
- CPLA: The first closed polygon list.
- CPLB: The second closed polygon list.
- tol: Tolerance for relative difference in area. Default is 0.1 if not specified.
Output Results
- b: A logical value indicating if the two CPLs are identical (true) or not (false).
- A: The difference in area between the two CPLs, normalized by the maximum area of the two.
Algorithm Steps
- Check if both
CPLA and CPLB are empty. If so, set b to true and return.
- If one is empty and the other is not, set
b to false and return.
- Extract the first two columns of
CPLA and CPLB to ensure they are 2D.
- Calculate the area of both CPLs using
CPLarea.
- Add a z-coordinate to both CPLs using
VLaddz.
- Register the convex hull of
VLA and VLB using TregisterConvexHull to get the transformation matrix T.
- Transform
VLB using the transformation matrix T with VLtransT.
- Compute the symmetric difference of the two polygons using
CPLpolybool with the 'xor' operation.
- Calculate the area of the resulting polygon
CPLD and normalize it by the maximum of AA and AB.
- Compare the normalized area
A with the tolerance tol. If A is less than tol, set b to true; otherwise, set it to false.
- If no output arguments are specified, plot the polygons using
SGfigure and CPSplot, coloring them green if identical and red if not.
Algorithm explaination created using ChatGPT on 2025-08-19 07:36. (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