Syntax
CPLX=CPLcrossline(CPL,PL,[acc]);
Input Parameter
CPL : | | CLosed polygon region |
PL : | | Point list |
acc : | | accuracy, line thickness; default is 0.01 |
Output Parameter
Examples
CPLcrossline(CPLsample(37),[0 0;0 10],1)
Copyright 2021-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, CPLcrossline
, calculates the intersection of a closed polygon list (CPL) with a line defined by a point list (PL). It is part of the SolidGeometry library.
Input Parameters
- CPL: A closed polygon region, represented as a list of points that form a closed shape.
- PL: A point list that defines a line. It is a 2D array where each row represents a point in 2D space.
- acc: An optional parameter that specifies the accuracy or thickness of the line. The default value is 0.01 if not provided.
Output
- CPLX: The resulting intersection area between the closed polygon and the line.
Algorithm Steps
- The function begins by determining the accuracy parameter,
acc
, using the getfuncparams
function. If acc
is not provided, it defaults to 0.1.
- The point list
PL
is converted to its real component using real(PL)
, ensuring it is in a suitable format for further processing.
- The function
PLgrowline
is called with PL
and acc
to create a grown line, CPLB
, which represents the line with a specified thickness.
- The intersection of the closed polygon
CPL
and the grown line CPLB
is calculated using the function CPLintersect
, resulting in CPLX
.
- If no output arguments are specified (
nargout==0
), the function proceeds to visualize the results:
SGfigure
is called to create a new figure for plotting.
CPSplot
is used to plot the closed polygon CPL
in green with a line thickness of 0.1.
CPSplot
is used again to plot the grown line CPLB
in green with a white edge.
CPSplot
is used to plot the intersection area CPLX
in red with a line thickness of 1.
PLplot
is used to plot the original line PL
in black with a line thickness of 2.
plotannotation
is called to add a legend to the plot, indicating the colors and their corresponding elements.
Algorithm explaination created using ChatGPT on 2025-08-18 23:31. (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