Syntax
a=CPSdiffarea(CPLA,CPLB)
Input Parameter
CPLA : | | Closed Polygon or Polyshape A |
CPLB : | | Closed Polygon or Polyshape B |
Output Parameter
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 calculates the normalized difference in area between two closed polygons or polyshapes, CPSA and CPSB, using the exclusive OR (XOR) operation.
Input Parameters
- CPSA: A closed polygon or polyshape A. If numeric, it is converted to a polyshape.
- CPSB: A closed polygon or polyshape B. If numeric, it is converted to a polyshape.
Output
- a: The resulting normalized area difference between the two shapes.
Algorithm Steps
- Check if CPSA is numeric. If true, convert it to a polyshape using
polyshape(CPSA)
.
- Check if CPSB is numeric. If true, convert it to a polyshape using
polyshape(CPSB)
.
- Calculate the area of CPSA and store it in
aa
.
- Calculate the area of CPSB and store it in
ab
.
- Perform an XOR operation on CPSA and CPSB to get the resulting shape
res
.
- Calculate the area of the resulting shape
res
and store it in a
.
- Normalize the area
a
by dividing it by the minimum of aa
and ab
.
- If the normalized area
a
is greater than 1, display a warning indicating no overlap or different shapes.
- If no output is requested (
nargout==0
), plot the resulting shape res
in red using CPSplot
.
Algorithm explaination created using ChatGPT on 2025-08-19 00:04. (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