Syntax
[PLCmax,PLCmin,rmax,rmin,cp]=PLcircleofPL(CPL)
Input Parameter
Output Parameter
PLCmax : | | PLcircle(Rmax) |
PLCmin : | | PLcircle(Rmin) |
rmax : | | rmax |
rmin : | | rmin |
cp : | | cp |
Examples
PLcircleofPL(CPLsample(3))
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, PLcircleofPL
, calculates the minimal and maximal circles that can enclose a given closed polygon list (CPL). It returns the parameters of these circles, including their radii and center points.
Input Parameters
- CPL: A closed polygon list, which is a set of points defining a closed shape.
Output Results
- PLCmax: The maximal enclosing circle as a polygon list.
- PLCmin: The minimal enclosing circle as a polygon list.
- rmax: The radius of the maximal circle.
- rmin: The radius of the minimal circle.
- cp: The center point of the circles.
Algorithm Steps
- Convert the input CPL to a standard format using
PLofCPL
.
- Calculate the center point of the CPL using
centerPL
.
- Translate the CPL so that its center is at the origin.
- Convert the Cartesian coordinates of the CPL to polar coordinates to find the angles.
- Determine the maximal radius
rmax
as the maximum distance from the center to any point in the CPL.
- Calculate the maximal circle
PLCmax
using PLcircle
and translate it back to the original center.
- Calculate the edge vectors of the CPL by shifting the points and subtracting.
- Initialize an array
rr
to store distances for the minimal circle calculation.
- For each point in the CPL, calculate the mirrored point and determine the distance using
mirroringatline
.
- Check if the mirrored point lies within the segment; if not, set the distance to NaN.
- Calculate the minimal radius
rmin
as the minimum of the valid distances and angles.
- Calculate the minimal circle
PLCmin
using PLcircle
and translate it back to the original center.
- If no output arguments are specified, plot the original CPL, maximal circle, minimal circle, and center point using
CPLplot
and annotate the plot with the center and radius of the maximal circle.
Algorithm explaination created using ChatGPT on 2025-08-19 06:43. (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