VLFLcloseC

by Tim C. Lueth, SG-Lib Toolbox: SolidGeometry 5.6 - SG/Solids
Introduced first in SolidGeometry 1.0, Creation date: 2012-04-29, Last change: 2025-09-14

Solid and fast procedure to generate facets for ONE closed contour

Example Illustration

 missing image of VLFLcloseC(VL)

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

Output Results

Algorithm Steps

  1. Check if the input vertex list (VL) has more than three columns. If so, transpose it to ensure it is in the correct format.
  2. 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.
  3. Determine the index of the starting point in the original vertex list and shift the list so that this point is the first.
  4. Initialize indices k0, k1, and k2 to represent the first three points in the list. Initialize an empty facet list FL.
  5. Enter a loop that continues until k0 equals k2, indicating the contour is closed.
  6. Calculate the cross product of vectors formed by the points at indices k0, k1, and k2 to determine the orientation of the turn.
  7. 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.
  8. 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.
  9. 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