Syntax
CPL=CPLofPolygon(h,[ascell]);
Input Parameter
h : | | handle to polygon |
ascell : | | if return as cell list or as array |
Output Parameter
Examples
h=plot(polyshape(PLcircle(4)))
CPLofPolygon(h)
h=plot(polyshape([PLcircle(4);nan nan; PLcircle(4)+[5 5]])); shg
CPLofPolygon(h)
Copyright 2018-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, CPLofPolygon
, is designed to convert a polygon graphics object handle into a Closed Polygon Line (CPL). It is part of the SolidGeometry library and is used in interactive functions like uipolygoncontextmenu
.
Input Parameters
- h: Handle to the polygon graphics object. It represents the polygon whose vertices are to be extracted.
- ascell (optional): A boolean parameter that determines the format of the output. If true, the output is returned as a cell array; otherwise, it is returned as a numeric array.
Output
- CPL: The Closed Polygon Line, which is a list of vertices representing the polygon. It can be returned as either a numeric array or a cell array, depending on the
ascell
parameter.
Algorithm Steps
- Retrieve the
ascell
parameter using getfuncparams
, defaulting to false if not provided.
- Determine the number of polygon handles,
n
, using numel(h)
.
- If
n
is 1 or ascell
is false:
- Initialize
nv
to count the total number of vertices across all polygons.
- Iterate over each polygon handle to accumulate the number of vertices.
- Create a
CPL
array with nan
separators between polygons.
- Fill the
CPL
array with vertices from each polygon.
- If
ascell
is true:
- Initialize
CPL
as a cell array with n
elements.
- For each polygon handle, store its vertices in the corresponding cell.
- If no output is requested (
nargout==0
):
- Open a new figure and plot the polygons using
CVLplot
.
- Annotate the plot with vertex labels using
textCVL
.
Algorithm explaination created using ChatGPT on 2025-08-19 08:26. (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