# Relationship between side length and circumradius of a regular convex polygon

I am trying to solve a programming challange on reddit and I want to understand how circumradius of a regular convex polygon relates to the side length.

I've found that polygons can be separated into n isosceles triangles with circumradius as its legs and side length as its base.

Using law of sines I've arrived at the following formula

$s = 2r * sinS$

Where s is the side length, r is circumradius and S is vertex angle.

As there are $2\pi$ radians available in a circle and vertex angle is only nth part of it, S should be equal to $\frac{2\pi}{n}$.

So the final formula should be

$s = 2r * sin \frac{2\pi}{n}$

Wikipedia provides a similar formula, but with $S=\frac{\pi}{n}$.

Why is that so? Why is the angle of an isosceles triangle in a circle of n isosceles triangles is $\frac{\pi}{n}$ and not $\frac{2\pi}{n}$?

-
The Wikipedia article uses the angle between the sides labeled $a$ and $r$, which is half of the angle you use. This gives a right triangle, so the calculations become easy. I'm not sure how you derived your formula, but you seem to have made a mistake somewhere. –  Jonas Granholm Apr 12 at 12:07
It is possible to create a isosceles triangle with base s and sides r and r. Law of sines gives us 2r = s / sin(S). But S must be an opposite angle, and pi/n is only half of an opposite angle. –  Blin Apr 12 at 14:25
How do you derive $2r=\frac{s}{\sin S}$ from the law of sines? I get $\frac{r}{\sin \frac{\pi-S}{2}}=\frac{s}{\sin S}$. –  Jonas Granholm Apr 12 at 14:39
@JonasGranholm Exactly! –  Sawarnik Apr 12 at 16:35
No, the law of sines isn't very useful here. That's why wikipedia created a right triangle instead, to use the definition of sine :) –  Jonas Granholm Apr 13 at 11:42

Thanks to Jonas Granholm I was able to see that the angle of an isosceles triangle in a circle of n isosceles triangles is $\frac{2\pi}{n}$, but side length calculation on wikipedia was based on half that angle.
Drawing apothem(a) creates a right triangle with sides a, r, $\frac{s}{2}$. Using definition of sine we get $\sin{\frac{S}{2}} = \frac{s}{2r}$, $s=2r\sin{\frac{2\pi}{2n}}=2r\sin{\frac{\pi}{n}}$.