Area of largest Circle inscribed in N-sided Regular polygon in C Program?


An n-sided regular polygon inscribed in a circle, the radius of this circle is given by the formula,

r = a/(2*tan(180/n))

Suppose a polygon have 6 faces i.e., a hexagon and as we know mathematically that the angle is 30 degree

So the radius of circle will be (a / (2*tan(30)))

Therefore, r = a√3/2

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 x = 180/n
Now, tan(x) = (a / 2) * r
So, r = a / ( 2 * tan(x))
So, Area of the Inscribed Circle is,
A = Πr2 = Π * (a / (2 * tan(x))) * (a / (2*tan(x)))

Example

#include <iostream>
using namespace std;
int main() {
   float area;
   float n = 6; float a = 4;
   float r = a / (2 * tan((180 / n) * 3.14159 / 180));
   area = (3.14) * (r) * (r);
   cout <<”area = ”<<area<< endl;
   return 0;
}

Output

area = 37.6801
raja
Published on 09-Aug-2019 06:34:34
Advertisements