Syntax
PLN=PLsetdiff(CPL,PL,[tol])
Input Parameter
CPL : | | Point list A |
PL : | | Point list B |
tol : | | Tolerance |
Output Parameter
PLN : | | Returns a Point list CPL without PL |
Examples
CPLsample(9); CPLA=ans; PLsetdiff(CPLA,[CPLA(3,:); CPLA(end-3,:)]); CPLB=ans
CPLinsertPL(CPLB,[CPLA(3,:);CPLA(end-3,:)])
Copyright 2021-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 algorithm is a custom implementation of the set difference operation for point lists, with added tolerance for numerical precision. It is designed to work with closed polygon lists (CPL) and point lists (PL).
Input Parameters
- CPL: A matrix representing the first point list (Point list A).
- PL: A matrix representing the second point list (Point list B).
- tol: An optional tolerance value for numerical comparison, defaulting to 1e-3 if not provided.
- rem: An optional boolean flag indicating whether to remove NaN values from the result, defaulting to false if not provided.
Output
- PLN: A matrix representing the point list CPL with points from PL removed, considering the specified tolerance.
Algorithm Steps
- Extract the first two columns of CPL and PL to ensure only 2D points are considered.
- Determine the number of points in CPL (np).
- Initialize a logical array
isi
of size np to false.
- Iterate over each point in CPL:
- Calculate the Euclidean distance between the current CPL point and all points in PL using
vecnormr
.
- Find the first point in PL within the specified tolerance of the current CPL point.
- Set the corresponding index in
isi
to true if a match is found.
- Create PLN by excluding points in CPL that have a corresponding true value in
isi
.
- If
rem
is true, remove NaN values from PLN using woNaN
.
- If no output is requested (nargout == 0), plot the results using
SGfigure
, CPSplot
, PLplot
, and CPLplot
functions.
Algorithm explaination created using ChatGPT on 2025-08-19 00:12. (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