Syntax
ll=PLlength(b)
Input Parameter
Output Parameter
Examples
PLlength([])
PLlength([0 0])
PLlength([0 0;10 0])
PLlength([0 0;10 0; 0 0])
Copyright 2024-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 cumulative distance between points in an open list, effectively measuring the length of a polyline defined by a series of points.
Input Parameters
- b: A list of points, where each point is represented as a row in a matrix. Each row contains the coordinates of a point in a 2D space.
Output Results
- ll: The total length of the open list, which is the sum of the distances between consecutive points.
Algorithm Steps
- Check if the number of points in the list
b
is less than 2. If true, set the length ll
to 0 and return, as there are not enough points to form a line.
- Calculate the difference between each point and the next point in the list using
circshift(b,-1)
, which shifts the list to align each point with its successor.
- Compute the Euclidean distance between each pair of consecutive points using
vecnormr
, which calculates the norm of each row vector.
- Use
cumsum
to compute the cumulative sum of these distances, effectively summing the lengths of each segment of the polyline.
- Extract the last value of the cumulative sum, which represents the total length of the polyline, and assign it to
ll
.
This function is part of the SolidGeometry library and is used to calculate the length of open polygonal chains.
Algorithm explaination created using ChatGPT on 2025-08-18 22: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