 Math to calculate area of polygon
by ericlin

This discussion is a note after reading the page:

http://www.brunel.ac.uk/~castjjg/java/polygon/polygon.html

The most wonderful thing in that page is the idea that the calculated area of a triangle can be "signed". Positive means clockwise and Negative means counterClockwise. So, the equation to calculate the area of polygon is very very simple.

To calculate the area of a polygon composed by pt0,pt1,pt2,pt3,pt34,pt5 the equation is like this:

area=function(ptA,ptB){
return (ptA.x*ptB.y-ptA.y*ptB.x)/2;
}
polygonArea=area(pt0,pt1)+area(pt1,pt2)+area(pt2,pt3)+area(pt3,pt4)+area(pt4,pt5)+area(pt5,pt0);

It is just a function sum of sequential points. Of-course, we are talking about a closed polygon.

At the last few lines of that page, the professor did not try to explain the details to convince me that equation is valid. He gave only two examples which is not enough for me.

So, I try to convice myself. Here is my notes.

First lets try to calculate the area of an arbituray triangle.

You see, if we make C to be (0,0), then for a vector A->B, the triangle area will be just

area=(A.x*B.y-A.y*B.x)/2;

Lets try another way to calculate the area of an arbituray triangle by that equation:

So, the equation will be a sum function of sequential vectors that compose the triangle.

Lets add a corner to the side of A->B, so the triangle will be quandrangle.

Here we see that, if we change a "side" into a "corner", the new area will eliminate the area composed by that old "side" and then two triangle area calculated by two new "sides" of that corner will be added to the new polygon area. The result is an equation about sum up dequential vector area.

If we pick a side and change it to a corner, then the same calculation works. The area about old side vector is eliminated and the area of two new side vectors are added. It remains the form of dequential sum. And now this is a polygon of 5 points.

For any polygon, it is derived from adding corner points. So, the equation works.