[Math] Distance between center of side of regular polygon inscribed in a circle, and the perimeter of that circle

circles

Point A : The center of a side of a polygon inscribed in a circle

Point B : The point on the perimeter of that circle that is opposite Point A

I want to calculate the distance between Point A & Point B

I know the number of sides the polygon has and the radius of the circle it's inscribed in.

I believe this is the way to calculate the length of the side of a regular polygon with n sides (Please correct me if I'm wrong as I am not a mathematician and found this online) :

x = nrsin(π/n)

Now is the distance I'm looking for : distance = 2r - x ?

I'm trying to figure out a formula that I could use in a bit of code I'm writing

Best Answer

The length of a side is $2r sin(\frac{\pi}{n})$ by trigonometry.

The distance is $r(1-cos\frac{\pi}{n})$, which is the difference between the radius and the length of the line from the center of the circle to the center of the side.