Syntax
CPL=CPLsubtract(A,B,[rel]);
Input Parameter
A : | | CPL A |
B : | | CPL B |
rel : | | list of spatial relations same of CPLtransrelCPL |
Output Parameter
Examples
CPLsubtract(PLcircle(10),PLcircle(5)+[7 0]);
CPLsubtract(PLcircle(10),PLcircle(5),'ontop',-2);
Copyright 2020-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, CPLsubtract
, performs a Boolean subtraction of two closed polygon lists (CPLs), A and B. It is part of the SolidGeometry library and was introduced in version 4.9.
Input Parameters
- A: The first closed polygon list (CPL).
- B: The second closed polygon list (CPL) to be subtracted from A.
- rel: An optional list of spatial relations, similar to those used in
CPLtransrelCPL
.
Output
- CPL: The resulting CPL after performing the Boolean subtraction of B from A.
Algorithm Steps
- The function begins by checking if any spatial relations are provided in
varargin
. If so, it applies these relations to B using the CPLtransrelCPL
function.
- It then calls the
CPLbool
function with the '-' operator to perform the subtraction of B from A.
- If no output argument is specified, the function visualizes the result using
SGfigure
and plots A, B, and the resulting CPL in different colors (green, red, and magenta, respectively).
- Annotations are added to the plot to label the colors corresponding to each CPL.
Example Usage
Two examples are provided to demonstrate the function:
CPLsubtract(PLcircle(10), PLcircle(5) + [7 0]);
- Subtracts a circle of radius 5, offset by [7, 0], from a circle of radius 10.
CPLsubtract(PLcircle(10), PLcircle(5), 'ontop', -2);
- Subtracts a circle of radius 5 from a circle of radius 10 with a specified spatial relation.
Algorithm explaination created using ChatGPT on 2025-08-19 00:30. (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