Polygon Area and Perimeter
A polygon is a closed 2D shape made of straight line segments.
Two common tasks are:
perimeter (total boundary length) and area (surface inside the boundary).
Perimeter from vertices
If vertices are \( (x_1,y_1), (x_2,y_2), \dots, (x_n,y_n) \) in order, the perimeter is the sum of edge lengths:
\[
P=\sum_{i=1}^{n} \sqrt{(x_{i+1}-x_i)^2+(y_{i+1}-y_i)^2},
\quad \text{with } (x_{n+1},y_{n+1})=(x_1,y_1).
\]
Area of an irregular polygon (Shoelace formula)
The shoelace formula computes area directly from coordinates:
\[
A=\frac{1}{2}\left|\sum_{i=1}^{n}\left(x_i y_{i+1}-x_{i+1} y_i\right)\right|,
\quad (x_{n+1},y_{n+1})=(x_1,y_1).
\]
Why “shoelace”? If you write the coordinates in a column, you multiply diagonally down-right and down-left like lacing shoes.
Regular polygons
For a regular polygon (all sides equal, all angles equal):
- \(P = n s\) where \(n\) is the number of sides and \(s\) is the side length.
- \(A = \frac{1}{2} P a\) where \(a\) is the apothem (distance from center to a side).
Useful relations (with angle \(\pi/n\)):
\[
a=\frac{s}{2\tan(\pi/n)},\quad s=2R\sin(\pi/n),\quad a=R\cos(\pi/n).
\]
Common mistakes
- Wrong order of vertices: The shoelace formula needs vertices in boundary order (clockwise or counterclockwise).
- Self-intersecting polygons: The simple shoelace result may not match the “visual” area you expect.
- Units: Perimeter is in units; area is in square units.
Interactive canvas
This calculator includes an interactive canvas:
- Drag vertices to change the polygon and update area/perimeter.
- Pan/zoom to inspect shapes precisely.
- Optional “trace perimeter” animation to visualize how perimeter is accumulated along edges.