# equation of a regular polygon in polar coordinates [duplicate]

Consider a regular polygon with n-sides ith radius 1. I want to construct an equation in polar coordinates for this polygon.

On the internet, I found this:

(first part) Consider the equation of just one half of one side of the $n$-gon. It's the side of a right triangle opposite angle $A = π/n$. The hypotenuse of this triangle is $1$ (the radius of the $n$-gon), so the equation of this one side is $\cos(π/n)/\cos(θ)$, where $θ$ goes from $0$ to $π/n$. The other half of this side has the same equation, so we're already at the point where we know the equation of one side of the $n$-gon: $r = \cos(π/n) / \cos(θ), -π/n ≤ θ ≤ π/n .$

(second part)Next, we will need to develop a function of θ that "normalizes" θ to be within plus or minus $π/n$. This is accomplished by the "floor" function, as follows: $B = θ - 2 π/n \lfloor(n θ + π)/(2 π)\rfloor$

Putting it together, the equation of an n-gon is $r = \cos(A)/\cos(B)$, which is $r = \cos(π/n)/\cos(θ - 2 π/n \lfloor(n θ + π)/(2 π)\rfloor)$

Someone can give me a help to understand the second part or show me an another solution?

• You might also like to take a look here: math.stackexchange.com/questions/735792/… , where a similar question was asked. May 2, 2014 at 2:15
• When you say radius 1 do you mean the distance from the centre to any corner is one or the distance from the centre to middle of each face is 1? Aug 29, 2014 at 11:28

Let me explain with a specific example, in the case $n=6$, and then the general argument may be clearer. I'm also going to use degrees, rather than radians, because I think it's more intuitive that way, so you will need to translate this back into radians when it's all done.
The first part tells you how to construct one side: You use the function $r=\cos(30°)/ \cos(\theta)$ as $\theta$ ranges from $-30°$ to $30°$. (Note that for $\theta = ± 30°$ this gives $r=1$, so the vertices of that side are 1 unit away from the origin, as required.)
Now, for the second side you want to describe what $r$ should be as $\theta$ ranges from 30° to 90°. So what, for example, should $r$ be when $\theta = 40°$? The answer is, you just need to subtract 60° from $\theta$ and compute what $r$ is for $\theta = -20°$. And in fact for every angle in the range $30° \leq \theta \leq 90°$ you can compute $r$ by first subtracting 60°, which brings you into the range of angles that defines the first side, and then using the rule that is already known for that first side.
For the third side, which ranges from 90° to 150°, you need to subtract 120° from $\theta$ and then use the formula that works for the 1st side. For the fourth side, which ranges from 150° to 210°, you need to subtract 180° from $\theta$. And so on. In other words for any given value of $\theta$, you subtract some multiple of 60° to bring it into the range of values that defines the first side.
What multiple of 60° do you use? Well, that depends on how big $\theta$ is. One way to figure it out is to (a) add 30° to theta, (b) divide the result of that by 60°, and (c) round down. You can check that if $\theta$ is between 30° and 90° this produces the result 1; if $\theta$ is between 90° and 150° this produces 2; if $\theta$ is between 150° and 210° this produces 3; and so on. Then take that whole number result and multiply it by 60°. That tells you what you need to subtract from $\theta$ before computing.
I think if you take what I've just explained and you translate it into radians, and replace the specific example of $n=6$ with the general case, you'll end up with the solution you already found (or at least an equivalent one).