VLunidirect

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

returns a unidirected vector ist

Description

Occasionally in a list of vectors only the direction of a vector is important and not its sign. This function removes the duplication of vectors and always takes the first occurrence of this vector for copies.

See Also: VLnorm , VLdistance

Example Illustration

 missing image of VLunidirect(VL,thr)

Syntax

[NL,ri]=VLunidirect(VL,[thr])

Input Parameter

VL: Vector list
thr: number of relevant digits for round; default is 5

Output Parameter

NL: Reduced Vector list
ri: removal index list

Examples


VL=[1 0 0;-1 0 0; 0 1 0; 0 -1 0; 0 0 1; 0 0 -1;1 -1 0; -1 1 0.00001],
VLunidirect(VL,3)
VLunidirect(VL,5)




Copyright 2018-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, VLunidirect, processes a list of vectors to ensure that each vector is represented only once, regardless of its direction. It removes duplicate vectors that are opposite in direction, keeping only the first occurrence.

Input Parameters

Output Results

Algorithm Steps

  1. Initialize the threshold thr to 5. If a second argument is provided and is not empty, update thr with this value.
  2. Iterate over each vector in VL from the last to the first.
  3. For each vector, check if its negative (opposite direction) is already present in the preceding vectors. Use rounding based on thr to compare vectors.
  4. Store the result of this check in ri, marking vectors that have duplicates in opposite directions.
  5. Convert ri to a column vector.
  6. Create NL by excluding vectors marked in ri.
  7. If no output arguments are specified and the vectors are 3D, plot the original and reduced vector lists using SGfigure and VLplot.
Algorithm explaination created using ChatGPT on 2025-08-19 01:06. (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