SGselect3dPL
by Tim C. Lueth, SG-Lib Toolbox: SolidGeometry 5.6 - Surfaces
Introduced first in SolidGeometry 4.9, Creation date: 2020-01-08, Last change: 2025-09-14
similar to select3d cals nearest point and vertices but for any fiven point
See Also: select3d
, crosspointVLFL2
, SGselect3d
, SGselect3Dsurface
Example Illustration
Syntax
[NL,FVL,fi]=SGselect3dPL(SG,[p])
Input Parameter
SG: | | Solid Geoemtry |
p: | | point to be checked |
Output Parameter
NL: | | List of point with nearest distance to PL |
FVL: | | list of point on nearest vertex |
fi: | | index of nearest vertex |
Examples
SGselect3dPL(SGsample(3),[0 -6 80])
SGselect3dPL(SGsample(3),[0 -6 8])
SGselect3dPL(SGsample(3),[1 -6 8])
[a,b,c]=SGselect3dPL(SGsample(3),[1 -6 8])
[a,b,c]=SGselect3dPL(SGsample(3),[1 -6 80])
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)
The function SGselect3dPL is designed to find the nearest point and vertices on a 3D solid geometry (SG) to a given point p. It is part of the SolidGeometry library.
Input Parameters
- SG: The solid geometry object containing vertex and face information.
- p: A point in 3D space to be checked against the solid geometry.
Output Results
- NL: A list of points with the nearest distance to the given point
p.
- FVL: A list of points on the nearest vertex.
- fi: The index of the nearest vertex.
Algorithm Steps
- Retrieve the point
p from the input parameters using getfuncparams.
- Extract the vertex list (VL) and face list (FL) from the solid geometry
SG using SGofSG.
- Calculate the nearest vertex and its index using
crosspointVLFL2, which returns the nearest vertex list FVL, distance di, index fi, and additional data a.
- Compute the Euclidean distance from each vertex in
SG.VL to the point p using vecnormr.
- Identify the nearest point(s)
NL by selecting vertices with the minimum distance.
- If no output arguments are specified, visualize the results:
- Plot the solid geometry with transparency using
SGplotalpha.
- Plot the point
p in red, the nearest vertex FVL in black, and the nearest point(s) NL in green using VLplot.
- If
FVL is not empty, draw a dashed line from p to FVL using lplot.
- If
fi is not empty, highlight the nearest face using VLFLplot and adjust lighting with setplotlight.
Algorithm explaination created using ChatGPT on 2025-08-19 06: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