Area of a Regular Polygon

Calculates the area of a regular n-gon as n × side² ÷ (4 × tan(180° ÷ n)). Each interior angle is 180° × (n − 2) ÷ n. The polygon needs at least 3 sides.

A regular polygon has equal sides and equal angles; equilateral triangles, squares and regular hexagons are all examples. The number of sides nn and the side length aa are enough to pin down the area.

S=na24tan(180n)S = \dfrac{n a^2}{4 \tan\left(\dfrac{180^\circ}{n}\right)}

Each interior angle is 180(n2)n\dfrac{180^\circ (n - 2)}{n}, and the perimeter is nan a.

Example

With the defaults, n=6n = 6 and a=4a = 4, a regular hexagon. Since tan30=130.5774\tan 30^\circ = \dfrac{1}{\sqrt{3}} \approx 0.5774,

S=6×424tan30=962.309441.5692S = \dfrac{6 \times 4^2}{4 \tan 30^\circ} = \dfrac{96}{2.3094} \approx 41.5692

The interior angle is 180×46=120\dfrac{180^\circ \times 4}{6} = 120^\circ and the perimeter is 6×4=246 \times 4 = 24.

Where the formula comes from

Join the centre to every vertex and the polygon splits into nn congruent isosceles triangles. Each has base aa and height equal to the apothem, the distance from the centre to a side, which is a2tan(180/n)\dfrac{a}{2 \tan(180^\circ / n)}. Multiplying the area of one triangle by nn gives the formula above.

Watch out

The number of sides has to be a whole number of at least 3; decimals and values below 3 are rejected. Do not confuse the interior angle, the angle between two adjacent sides and 120120^\circ in the example, with the central angle 360n\dfrac{360^\circ}{n}, which is 6060^\circ here.