by Tim C. Lueth, SG-Lib Toolbox: SolidGeometry 5.6 - PL/Point Lists
Introduced first in SolidGeometry 4.5, Creation date: 2019-04-20, Last change: 2025-09-14
[CPL,PLE]=PLconnectopenends(PL,[])
PL: | single open line |
CPL: | Closed contour without doubled entries | |
PLE: | Externsion may contain start or end point |
PLX=PLradialEdges(PLrand(10,4)*10,30); SGfigure; PLplot(PLX,'b-'); % Arbitrary Line
PLconnectopenends(PLX)
CPLfft(PLconnectopenends(PLsample(3)),4)
This algorithm is designed to close an open line by forming a contour. It is part of the SolidGeometry library and was introduced in version 4.5. The function is named PLconnectopenends and it takes an open line as input to produce a closed contour.
PLtangentarc4P is called with the last two points of the line and the first two points of the line. This function is assumed to calculate a tangent arc that connects these points.PLtangentarc4P is stored in PLE.PL is concatenated with PLE to form CPL.rpi is created to remove duplicate points by checking if the norm of the difference between consecutive points is greater than a small threshold (1e-6).CPL is updated to only include points that are not duplicates.SGfigure and the following plots are made:
PL is plotted in blue.PLE is plotted in red.PLE are marked with magenta stars.PL is marked with a black star.