Syntax
m=circ2poly(n,[r])
Input Parameter
n : | | number of polygon edges/corners |
r : | | optional radius |
Output Parameter
Examples
circ2poly(6)
Copyright 2019-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, circ2poly
, calculates the magnification factor for a regular polygon inscribed in a circle. The function is part of the SolidGeometry library and was introduced in version 4.5. It is designed to determine the ratio of the polygon's radius when rotated by À/n radians.
Input Parameters
- n: The number of edges or corners of the polygon. This is a mandatory parameter.
- r: An optional parameter representing the radius of the circle in which the polygon is inscribed. If not provided, a default value is used.
Output Results
- m: The magnification factor, which is greater than 1. This factor represents the ratio of the polygon's radius when rotated by À/n radians.
Algorithm Steps
- The function begins by retrieving the radius
r
using the helper function getfuncparams
. If r
is not provided, a default value of 1 is assumed.
- The magnification factor
m
is calculated as 1/cos(pi/n)
. This formula derives from the geometric properties of a regular polygon inscribed in a circle.
- The sine of the angle
pi/n
is computed and stored in s
.
- The length
l
is calculated as r * m * s
, which represents a specific geometric property related to the polygon.
- If no output arguments are specified, the function proceeds to visualize the results:
- A new figure is created using
SGfigure
, and the view is set to a top-down perspective.
- The function
CPLplot
is used to plot the original circle with radius r
and the polygon with n
edges.
- The magnified polygon with radius
r * m
is also plotted.
- A circle with 100 segments is plotted in green for reference.
- Lines and annotations are added to the plot to illustrate the relationships between the original and magnified polygons, including labels for
R
, R*m
, and R/m
.
- The magnification factor
m
is annotated on the plot using plotannotation
.
The function is designed to provide both a numerical result and a visual representation of the geometric transformation, aiding in the understanding of the relationship between a circle and its inscribed polygon.
Algorithm explaination created using ChatGPT on 2025-08-19 00:23. (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