lengthC
by Tim C. Lueth, SG-Lib Toolbox: SolidGeometry 5.6 - Analytical Geometry
Introduced first in SolidGeometry 1.0, Creation date: 2012-05-18, Last change: 2025-09-14
returns length and maximum of changing angle plus
Description
This procedure is helpful to estimate features of an automatically designed contour for instance by VLBezier4P etc. Beside the length also the maximum angle between two segments is calculated. In addition the maximum bending force is calculated.
Since 2017b its possible using sum(vecnormr(PL-circshift(PL,+1)))
See Also: vecnormr
Example Illustration
Syntax
[l,wmax,dwmax]=lengthC(VL)
Input Parameter
VL: | | Vertex list of the contour |
Output Parameter
l: | | length of the contour |
wmax: | | maximum segment angle of the contour |
dwmax: | | maximum bending force factor of the contour |
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 function calculates the length of a contour, the maximum angle between segments, and the maximum bending force factor. It is useful for analyzing automatically designed contours.
Input Parameters
- VL: A vertex list representing the contour. Each row corresponds to a vertex in the contour.
Output Results
- l: The total length of the contour.
- wmax: The maximum angle between any two consecutive segments of the contour.
- dwmax: The maximum bending force factor of the contour.
Algorithm Steps
- Determine the number of vertices
n in the vertex list VL.
- Initialize the length
l to zero.
- If there is only one vertex (
n == 1), return immediately as the length is zero.
- Iterate over each pair of consecutive vertices to calculate the total length
l of the contour:
- For each pair of vertices
VL(i) and VL(i+1), compute the Euclidean distance and add it to l.
- If the function is called with more than one output argument, calculate
wmax and dwmax:
- Initialize
wmax and dwmax to zero.
- For each vertex from the second to the second-to-last (
i = 2 to n-1):
- Calculate vectors
pa and pb representing the segments before and after the vertex.
- Compute the angle
wa between these segments using the dot product and arccosine function.
- Update
wmax if wa is greater than the current wmax.
- Calculate the bending force
dw using the sine of wa and the maximum of the norms of pa and pb.
- Update
dwmax if dw is greater than the current dwmax.
Algorithm explaination created using ChatGPT on 2025-08-19 01:34. (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