TITLE: Area of an irregular polygon
QUESTION [7 upvotes]: I was searching for methods on how to calculate the area of a polygon and stubled across this: http://www.mathopenref.com/coordpolygonarea.html.
$$
\mathop{area} = 
\left\lvert\frac{(x_1y_2 − y_1x_2) + (x_2y_3 − y_2x_3) + \cdots
                  + (x_ny_1 − y_nx_1)}{2} \right\rvert
$$
where $x_1,\ldots,x_n$ are the $x$-coordinates and $y_1,\ldots,y_n$ are the $y$-coordinates of the vertices.
It does work and all, yet I do not fully understand why this works.
As far as I can tell you take the area of each triangle between two points. Basically you reapeat the formula of $\frac{1}{2} * h * w$ for each of the triangles and take the sum of them? Yet doesn't this leave a "square" in te center of the polygon that is not taken into account? (Apparently not since the correct answer is produced yet I cannot understand how).
If someone could explain this some more to me I would be grateful.

REPLY [7 votes]: The formula in question can be explained by means of Green's formula in the plane.
Let ${\bf F}=(P,Q)$ be a force field in the plane, and assume that $\Omega$ is a finite domain with boundary cycle $\partial\Omega$. Then Green's formula says that
$$\int\nolimits_{\partial B} (P\>dx+Q\>dy)=\int\nolimits_B (Q_x-P_y)\ {\rm d}(x,y)\ .\tag{1}$$
When ${\bf F}=(0,x)$ or ${\bf F}=(-y,0)$ then $Q_x-P_y\equiv1$, and the right hand side of $(1)$ just gives the area of $\Omega$. It follows that
$${\rm area}(\Omega)=\int\nolimits_{\partial B} x\ dy=-\int\nolimits_{\partial B} y\ dx={1\over2}\int\nolimits_{\partial B} (x\> dy-y\>dx)\ ,$$
where practical considerations dictate which version should be applied in the particular case at hand.
When $\Omega$ is a polygon with $n$ vertices given in cyclic order then $\partial\Omega$ consists of $n$ directed segments $\sigma_k$. Writing out the line integral for each $\sigma_k$ and cyclically summing over $k$ one arrives at the given formula (resp. to one of its equivalents).