Given a regular polygon of N sides with side length a. The task is to find the area of the polygon.
Input : N = 6, a = 9 Output : 210.444 Input : N = 7, a = 8 Output : 232.571
Approach: In the figure above, we see the polygon can be divided into N equal triangles. Looking into one of the triangles, we see that the whole angle at the center can be divided into = 360/N
So, angle t = 180/n
Now, tan(t) = a/2*h
So, h = a/(2*tan(t))
Area of each triangle = (base * height)/2 = a * a/(4*tan(t))
So, area of the polygon,
A = n * (area of one triangle) = a2 * n/(4tan t)
Below is the implementation of the above approach:
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.
- Area of Triangle using Side-Angle-Side (length of two sides and the included angle)
- Polygon with maximum sides that can be inscribed in an N-sided regular polygon
- Side of a regular n-sided polygon circumscribed in a circle
- Minimum side of square embedded in Regular polygon with N sides
- Area of a n-sided regular polygon with given Radius
- Program to find Area of Triangle inscribed in N-sided Regular Polygon
- Area of largest Circle inscribe in N-sided Regular polygon
- Length of Diagonal of a n-sided regular polygon
- Find the area of rhombus from given Angle and Side length
- Check if given polygon is a convex polygon or not
- 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
- Number of triangles formed by joining vertices of n-sided polygon with one side common
- 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
- Apothem of a n-sided regular polygon
- Determine the position of the third person on regular N sided polygon
- Central angle 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 firstname.lastname@example.org. 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.