finduniqueVL

by Tim C. Lueth, SG-Lib Toolbox: SolidGeometry 5.6 - Auxiliary function
Introduced first in SolidGeometry 4.9, Creation date: 2020-02-08, Last change: 2025-09-14

similar to unique but more reliable



See Also:

Example Illustration

 missing image of finduniqueVL(NVL,VL,tol,warn)

Syntax

[ic,err,ia]=finduniqueVL(NVL,VL,[tol,warn])

Input Parameter

NVL: vector row list to search in
VL: vector row list to search for
tol: tolerance for warning; default is 1e-12
warn: if true; warnings are shown; default is true

Output Parameter

ic: list of index entries; 3rd result of unique
err: deviation between VL and best fit in NVL
ia: list of index entries; 2nd result of unique

Examples


finduniqueVL(rand(10,3),rand(6,3))
X=rand(10,3); X=[X(1:5,:);X(3,:); X(1,:);X(6:end,:)]
[ic,err,ia]=finduniqueVL(X,X) % identical mapping
[ic,err,ia]=finduniqueVL(X,X+1e-3) % warning since thr= 1e-12
[ic,err,ia]=finduniqueVL(X,X+1e-3,0.01) % No warning since thr= 0.01




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, finduniqueVL, is designed to find unique vector rows in a list with a specified tolerance. It is more reliable than the standard unique function.

Input Parameters

Output Results

Algorithm Steps

  1. Initialize tol and warn using getfuncparams to handle optional parameters.
  2. Preallocate ic and err as NaN arrays with the same number of rows as VL.
  3. For each row in VL:
    • Calculate the Euclidean distance from the row to each row in NVL using vecnormr.
    • Find the index of the minimum distance and store it in ic.
    • Store the minimum distance in err.
    • If the distance exceeds tol and warn is true, display a warning.
  4. If the number of output arguments is greater than 2, compute ia as the unique indices from ic.

Example Usage

Here are some examples of how to use the function:

Algorithm explaination created using ChatGPT on 2025-08-19 07:57. (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