Send Close Add comments: (status displays here)
Got it!  This site uses cookies. You consent to this by clicking on "Got it!" or by continuing to use this website.nbsp; Note: This appears on each machine/browser from which this site is accessed.
Area of a polygon


1. Area of a polygon
A polygon in a plane is a connected and closed set of line segments, called legs.

2. Polygon
polygon step 0Consider the following set of points in the form (x,y).
   [6.000 6.000]    [10.400 6.000]    [12.600 9.811]    [10.400 13.621]    [6.000 13.621]    [3.800 9.811]

Note: Computer people usually start counting at zero (0) but others usually start counting at one (1). The diagrams start counting points at one (1).

3. Algorithm
An algorithm is a step by step method for (eventually) solving a (well-defined) problem.

An algorithm for determining the area of a polygon is now covered.

4. Pseudo-code
Given a polygon, here is a pseudo-code for the algorithm.
Get units and number of points Set total area to 0.0 FOR EACH pair of adjacent points (x1,y1) and (x2,y2)    IF the pair is the first pair THEN       set the base (x0,y0) to (x1, y1)    ELSE       calculate triangle area of points (x0,y0) , (x1,y1) , (x2,y2)       add area to total area       END IF    END FOR output total area of the polygon


5. Area of a triangle
The algorithm requires the calculation of the area of a triangle.

See Area of a triangle to see how to determine the area of a triangle.

6. Order
polygon step 1The points of the polygon will be taken in order.

The last point of a polygon, to close the polygon, is usually omitted, as is done here. Since the perimeter of the polygon is not considered here, that last omitted point is not needed for the current discussion.

7. Point 1
polygon step 2At point 1, there is nothing to do at the first point except save that point as the base of all other triangles.

8. Point 2
polygon step 3At point 2, there is no triangle, but the previous point needs to be saved for the next step.

For more information on data pairs, see C: Loops for data pairs .

9. Point 3
polygon step 4At point 3, the area of the first triangle (points 1, 2 and 3) can be determined and added to the total area of the polygon.

10. Point 4
polygon step 5At point 4, the area of the second triangle (points 1, 3 and 4) can be determined and added to the total area of the polygon.

11. Point 5
polygon step 6At point 5, the area of the third triangle (points 1, 4 and 5) can be determined and added to the total area of the polygon.

12. Point 6
polygon step 7At point 6, the area of the fourth triangle (points 1, 5 and 6) can be determined and added to the total area of the polygon.

This is the last point so we are done.

13. Perimeter
polygon step 1If the perimeter were needed, the length from the last point to the first point would need to be computed and added the the length of all line segments of the polygon.

14. Notes
In the example, a regular polygon of six sides was used. Any polygon can be used. It may zig-zag in and out. There may be negative areas and positive areas, but they will cancel out.

The actual area is the absolute value of the calculated area. The positive or negative has to do with the direction of the points. Going the other way around the points will produce the negative of the original way.

15. End of page