Given a n-sided regular polygon of side length a.The task is to find the length of it’s diagonal.
Input: a = 9, n = 10 Output: 17.119 Input: a = 4, n = 5 Output: 6.47213
We know that the sum of interior angles of a polygon = (n – 2) * 180 where, n is the no. of sides in the polygon.
So, each interior angle = (n – 2) * 180/n
Now, we have to find BC = 2 * x. If we draw a perpendicular AO on BC, we will see that the perpendicular bisects BC in BO and OC, as triangles AOB and AOC are congruent to each other.
Now, t = (n – 2) * 180/2n
So, sint = x/a
Therefore, x = asint
Hence, diagonal=2x = 2asint = 2asin((n – 2) * 180/2n)
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Length of a Diagonal of a Parallelogram using the length of Sides and the other Diagonal
- Area of a n-sided regular polygon with given side length
- Filling diagonal to make the sum of every row, column and diagonal equal of 3x3 matrix
- Maximum sum of elements in a diagonal parallel to the main diagonal of a given Matrix
- Diagonal of a Regular Pentagon
- Diagonal of a Regular Hexagon
- Diagonal of a Regular Heptagon
- Diagonal of a Regular Decagon
- Regular polygon using only 1s in a binary numbered circle
- Program to find the Interior and Exterior Angle of a Regular Polygon
- Program to find the Circumcircle of any regular polygon
- Program to find the Perimeter of a Regular Polygon
- Program to find Area of Triangle inscribed in N-sided Regular Polygon
- Side of a regular n-sided polygon circumscribed in a circle
- Area of a n-sided regular polygon with given Radius
- Apothem of a n-sided regular polygon
- Area of largest Circle inscribe in N-sided Regular polygon
- Determine the position of the third person on regular N sided polygon
- Angle between 3 given vertices in a n-sided regular polygon
- Number of occurrences of a given angle formed using 3 vertices of a n-sided regular polygon
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.