Syntax
[ENL,VNL]=NLcontourVL(VL)
Input Parameter
VL : | | Vertex list of a sorted(!) contour: Use VLGraham before or VLsortC |
Output Parameter
ENL : | | List of normal vector of the edges |
VNL : | | List of normal vector of the edges |
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 calculates the normal vectors for the edges and vertices of a sorted contour. It is part of the SG-Library and is used in analytical geometry.
Input Parameters
- VL: A vertex list of a sorted contour. The vertices should be sorted using functions like VLGraham or VLsortC before using this function.
Output Results
- ENL: A list of normal vectors for the edges.
- VNL: A list of normal vectors for the vertices.
Algorithm Steps
- Determine the number of vertices
n
from the size of VL
.
- Initialize
ENL
as a zero matrix with dimensions n x 3
.
- Loop through each vertex from 1 to
n-1
to calculate the edge normal vectors:
- Calculate the difference in x (
dx
) and y (dy
) coordinates between consecutive vertices.
- Compute the length
l
as the inverse of the norm of the vector [dx, dy]
.
- Calculate the normal vector for the edge and store it in
ENL
.
- Calculate the normal vector for the edge between the last and the first vertex to close the contour.
- Negate
ENL
to ensure the normals point outward.
- Initialize
VNL
as a zero matrix with dimensions n x 3
.
- Loop through each vertex from 2 to
n
to calculate the vertex normal vectors:
- Average the normal vectors of the adjacent edges and store in
VNL
.
- Calculate the normal vector for the first vertex by averaging the first and last edge normals.
- Normalize each vector in
VNL
to ensure they have a length of 1.
Algorithm explaination created using ChatGPT on 2025-08-19 01:18. (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