Syntax
[VL,FL]=VLFLcloseC(VL)
Input Parameter
VL : | | Vertex list or point list with 4 ore more points |
Output Parameter
VL : | | Vertex list (resorted) |
FL : | | Facet list |
Examples
Close a simple square:
PL=[0 0 0; 10 0 0; 10 10 0; 0 10 0];
[VL,FL]=VLFLcloseC (PL);
VLFplot (VL,FL);
Copyright 2012-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 designed to generate facets for a closed contour using a vertex list (VL) as input. It is a part of the SG-Library and was created by Tim Lueth in 2012.
Input Parameters
- VL: A vertex list or point list containing four or more points. It is expected to be a matrix where each row represents a point in 3D space.
Output Results
- VL: The vertex list, potentially resorted.
- FL: The facet list, which contains the indices of the vertices that form each facet.
Algorithm Steps
- Check if the input vertex list (VL) has more than three columns. If so, transpose it to ensure it is in the correct format.
- Find the starting point for the contour. This is done using the
VLGraham
function, which likely implements the Graham scan algorithm to find the convex hull of the points.
- Determine the index of the starting point in the original vertex list and shift the list so that this point is the first.
- Initialize indices
k0
, k1
, and k2
to represent the first three points in the list. Initialize an empty facet list FL
.
- Enter a loop that continues until
k0
equals k2
, indicating the contour is closed.
- Calculate the cross product of vectors formed by the points at indices
k0
, k1
, and k2
to determine the orientation of the turn.
- If the cross product
S
is positive, it indicates a counter-clockwise turn, and a facet is formed with these points. Update the facet list FL
and move to the next point by incrementing k1
and k2
.
- If
S
is not positive, it indicates a clockwise turn, and the algorithm backtracks by adjusting the indices k0
, k1
, and k2
to consider previous points.
- Repeat the process until the contour is closed, and all facets are generated.
The algorithm efficiently generates a set of facets for a closed contour by iteratively checking the orientation of turns and adjusting the indices of the points accordingly.
Algorithm explaination created using ChatGPT on 2025-08-18 23:43. (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