Finding the Radius & Segments of a Polygonal Circle to Match a Specific Face Size

40 Views Asked by At

bit of a weird question, but I am a 3D artist and I need to create a polygonal circle spline in which all the faces making up the circle have to be a specific size, but I am unsure of how to calculate this.

Polygonal Circle With Radius of 1 & 2 Steps

The above image (linked) is an example of what I can create. I have access to the radius and the step (face) amount, but I am trying to work out how to calculate the required step amount when using x radius and x size for each face.

If confused by the steps system, this shape is technically a subdivided square oriented diagonally, so the steps are the ADDITIONAL faces for each side (90 degrees diagonal).

Is there any easy way of doing this? Thank you in advance for any help you can render.

1

There are 1 best solutions below

3
On

If we have the required length of face $l$ and radius $r$:

To determine the minimum number of faces of size $a \leq l$ use the formula (for $0<x\leq 2r $): $$n=\left\lceil\frac{\pi}{\arcsin \frac{l}{2r}} \right\rceil$$

var n=Math.Ceiling(Math.Pi/Math.Asin(l/(2*r)));

Or maximum number of faces of size $a \geq l$: $$n=\left\lfloor\frac{\pi}{\arcsin \frac{l}{2r}} \right\rfloor$$

var n=Math.Floor(Math.Pi/Math.Asin(l/(2*r)));

If we are given the radius $r$ and number of faces $n$, the length of each face is: $$a=2r \sin \frac{\pi}{n}$$

var a = 2*r*Math.Sin(Math.Pi/n);

From the length of face $a$ and number of faces $n$ we can easily obtain the radius $r$ $$r=\frac{a}{2 \sin \frac{\pi}{n}}$$

var r = a/(2*Math.Sin(Math.Pi/n));

Having number of faces $n$ and radius $r$ you can generate the vertices of 'circle': $$\begin{cases}x=r \cos { \frac{2k \pi}{n}}\\y=r \sin { \frac{2k \pi}{n}} \end{cases}$$ for $k=0,1,..., n-1$

var x=new double[n];
var y=new double[n];
for(var k=0; k<n; ++k)
{
   x[k]=r*Math.Cos(2*Math.Pi*k/n);
   y[k]=r*Math.Sin(2*Math.Pi*k/n);
}