Syntax
vi=viVLFLnearestneighborVL(VLA,FLA,VL)
Input Parameter
VLA : | | Vertex List of Solid |
FLA : | | Facet List of Solid |
VL : | | Vertex list to check |
Output Parameter
vi : | | neares neighbor index to VLA |
Examples
SG=SGbox; viVLFLnearestneighborVL(SG.VL,SG.FL,rand(1,3)*10)
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, viVLFLnearestneighborVL
, is designed to find the nearest neighbor indices of a given vertex list relative to a solid's vertex list. It is part of the SG-Library and was introduced in SolidGeometry 4.9.
Input Parameters
- VLA: The vertex list of the solid. This is a matrix where each row represents a vertex in 3D space.
- FLA: The facet list of the solid. This is a matrix where each row represents a facet by indexing into the vertex list.
- VL: The vertex list to check against the solid's vertex list. This is also a matrix where each row is a vertex in 3D space.
Output Results
- vi: The indices of the nearest neighbors in
VLA
for each vertex in VL
.
Algorithm Steps
- Create a triangulation object
TR
using the facet list FLA
and vertex list VLA
.
- Use the
nearestNeighbor
function to find the nearest neighbor indices vi
for each vertex in VL
relative to the triangulation TR
.
- Extract unique rows from
VL
and store them in NL
.
- Extract unique indices from
vi
and store them in ni
.
- Create a matrix
IVL
by combining vi
and VL
.
- Extract unique rows from
IVL
.
- If no output is requested, visualize the results:
- Plot the solid using
VLFLplotalpha
with white color and 0.1 transparency.
- Plot the vertices in
VL
as red dots.
- Plot the nearest neighbors in
VLA
as magenta dots.
Example Usage
To use this function, you can call it with a solid's vertex and facet lists, and a random vertex list:
SG = SGbox;
viVLFLnearestneighborVL(SG.VL, SG.FL, rand(1,3) * 10);
Algorithm explaination created using ChatGPT on 2025-08-19 06:44. (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