CPSdiffarea

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

return the norm difference between two polyshape areas by xor

Description

To analyze which ideal geometry fits best in CPLidealshape, CPSdiffarea is used to calulate the difference of the areas

See Also:

Example Illustration

 missing image of CPSdiffarea(CPLA,CPLB)

Syntax

a=CPSdiffarea(CPLA,CPLB)

Input Parameter

CPLA: Closed Polygon or Polyshape A
CPLB: Closed Polygon or Polyshape B

Output Parameter

a: resulting area




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

Output

Algorithm Steps

  1. Check if CPSA is numeric. If true, convert it to a polyshape using polyshape(CPSA).
  2. Check if CPSB is numeric. If true, convert it to a polyshape using polyshape(CPSB).
  3. Calculate the area of CPSA and store it in aa.
  4. Calculate the area of CPSB and store it in ab.
  5. Perform an XOR operation on CPSA and CPSB to get the resulting shape res.
  6. Calculate the area of the resulting shape res and store it in a.
  7. Normalize the area a by dividing it by the minimum of aa and ab.
  8. If the normalized area a is greater than 1, display a warning indicating no overlap or different shapes.
  9. 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