# Area of an irregular polygon

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.

Let $O$ is the origin. Denote "signed area" of triangle $OAB$: $~~S_{OAB}= \dfrac{1}{2}(x_Ay_B-x_By_A)$.
It can be derived from cross product of vectors $\vec{OA}, \vec{OB}$.

If way $AB$ is $\circlearrowleft$ (if polar angle of $A$ less than polar angle of $B$), then $S_{OAB}>0$ ;
if way $AB$ is $\circlearrowright$ (if polar angle of $A$ greater than polar angle of $B$), then $S_{OAB}<0$.

Now, for each edge $A_jA_{j+1}$ ($j=1,2,\ldots,n$; $A_{n+1}\equiv A_1$) of polygon $A_1A_2\ldots A_n$ we can build $2$ vectors: $\vec{OA_j}$ and $\vec{OA_{j+1}}$.

And "signed area" of polygon (which sign depends on numerating direction) $$S_{A_1A_2...A_n} = \sum_{j=1}^n S_{OA_jA_{j+1}} = \sum_{j=1}^n \dfrac{1}{2}(x_jy_{j+1}-x_{j+1}y_j) = \dfrac{1}{2}\sum_{j=1}^n (x_jy_{j+1}-x_{j+1}y_j).$$

When positive term adds, then square will increase, when negative, then area will decrease.

We will mark "positive" area as blue, and "negative" as red.

Illustration:

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).