CPLofPLseparatedlines

by Tim C. Lueth, SG-Lib Toolbox: SolidGeometry 5.6 - CPL/Closed Polygon Lists
Introduced first in SolidGeometry 5.2, Creation date: 2022-04-01, Last change: 2025-09-15

converts a list of 2D points paris into a CPLs that separates the each pair by nan nan

Description

Used in CPLofSGTez

See Also: CPLofSGTez , CPLofPLcrossCPL , PLofCPLequidistant

Example Illustration

 missing image of CPLofPLseparatedlines(PL)

Syntax

CPL=CPLofPLseparatedlines(PL)

Input Parameter

PL: List of point [nx2] n is an even integer

Output Parameter

CPL: Pairs separated by nan nan

Examples


CPLofPLseparatedlines([0 0; 10 0; 20 20 ; 20 40])




Copyright 2022-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, CPLofPLseparatedlines, is designed to convert a list of 2D point pairs into a closed polygon list (CPL) where each pair is separated by nan nan. This is useful for visualizing or processing line segments as distinct entities.

Input Parameters

Output Results

Algorithm Steps

  1. Reshape Input: The input list PL is reshaped to a 4-column format using reshape(PL',4,[])'. This groups the points into pairs.
  2. Add NaN Separation: A new matrix NL is created by appending nan values to each pair using nan(size(LL,1),2). This effectively separates each pair with nan nan.
  3. Reshape to Output Format: The matrix NL is reshaped back to a 2-column format using reshape(NL',2,[])', creating the final CPL.
  4. Remove Last NaN: The last row, which contains nan nan, is removed from CPL using CPL(1:end-1,:).
  5. Optional Plotting: If no output is requested (nargout==0), the function plots the CPL using SGfigure and PLplot with red stars and lines.

Example

For example, calling CPLofPLseparatedlines([0 0; 10 0; 20 20; 20 40]) will produce a CPL where each pair of points is separated by nan nan.

Algorithm explaination created using ChatGPT on 2025-08-18 23: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