I need some assistance with the formula/algorithm to find the vertices of a regular convex polygon (centered at (0,0) and with a circumradius of 1) rotated so that the vertices are as far away from both the x and y axis as possible.

The formula for the vertices of a rotated polygon is ($n$ is the number of sides of the polygon, $i$ is the zero-based vertex number and $\theta$ is the angle of rotation):

Given: $n, i \in \mathbb Z, n \ge 3, 0 \le i \lt n, 0 \le \theta \lt \frac{2\pi}n$

$$ \left(x, y\right)_i = f\left(n, i\right) = \begin{cases} x = \cos\left(i\frac{2\pi}n+\theta\right) \\ y = \sin\left(i\frac{2\pi}n+\theta\right) \\ \end{cases} $$

I need to find a function $\theta = g\left(n\right)$ that will give me the correct rotation for a given polygon. All I have so far is (which doesn't cover all cases):

$$ \theta = g\left(n\right) = \begin{cases} \frac{\pi}n, & \text{if $\left(n \mod 4\right) = 0$} \\ \frac{\pi}{2n}, & \text{if $\left(n \mod 2\right) = 0$} \\ \end{cases} $$

Is there a general formula/algorithm to compute $\theta$?

I'm a programmer working with a neural network and I'm trying to find a way to catagorize my input data. I'm dealing with an n-of-m situtation, i.e. 5 inputs each having one of 26 different values. My first attempt was to have 26 different inputs with the appropriate inputs "on" and the rest "off". That didn't work out very well, so I'm trying something different. This may or may not work, (and if you know the answer to that, please don't spoil it for me) but it's worth a try.


1 Answer 1


The general formula is: $$\theta=\pi\frac{\operatorname{gcd}(n,4)}{4n} \tag{1}$$ In simpler terms: it's $\pi/(4n)$ when $n$ is odd, $\pi/(2n)$ when $n\equiv 2\mod 4$ and $\pi/n$ when $n\equiv 0\mod 4$. (As you said).

Proof: instead of looking at the distances between the vertices and four half-lines (up, down, left, right), we can rotate the polygon by multiples of $\pi/2$, take the union of all vertices, and consider the distance only to the positive real axis. The rotation in multiples of $\pi/2$ creates vertices with polar angles $$2\pi\left(\frac{k}{n}+\frac{l}{4}\right) \tag{2}$$ where $2\pi k/n$ was the original polar angle of a vertex, and $l$ is the number of times we rotated by $\pi/2$. Rewrite (2) as $$\frac{\pi}{2n}\left(4k+ nl \right) \tag{2}$$ As $k$ and $l$ vary, the sum $4k+ nl$ runs over all multiples of $\operatorname{gcd}(n,4)$. Hence, we have uniformly placed points with polar angles $$\frac{\pi}{2n}\operatorname{gcd}(n,4) j \tag{3}$$ where $j$ runs through integers. The amount of rotation should be half the distance between points in (3), which leads to (1).


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .