Associated Topics || Dr. Math Home || Search Dr. Math

### Area of a Polygon

```
Date: 06/27/97 at 08:36:03
From: Rainer WILHELM
Subject: Area of polygon (3-6 corners)

How do you calculate the area of a polygon (minimum 3, maximum 6
vertices) in the plane? The polygon is always convex.

I've found a formula, but this formula requires that one know the
order of the corner points. I have to calculate the area in a computer
program which only knows the coordinates of the corners, but not their
order.

Rainer
```

```
Date: 06/27/97 at 11:42:55
From: Doctor Rob
Subject: Re: Area of polygon (3-6 corners)

The program can determine the order. First pick the point with the
smallest y-coordinate. If there is a tie between two, pick the one
with the larger x-coordinate. Call it P(1). Let the last slope be 0.

For each i from 1 to n-1, compute the slopes of the lines from P(i) to
each of the other vertices not already labeled. If there are any with
slope greater than the last slope, pick the point with the smallest
slope line to be P(i+1). If there are none with greater slope, pick
the point with the most negative slope to be P(i+1).

The slope from P(i) to P(j) is [y(j)-y(i)]/[x(j)-x(i)].

(If x(j) = x(i), say the slope is either plus or minus infinity).

When you are done, the vertices will be P(1), P(2), ..., P(n) in
order. This works because the polygon is convex.

Once you have this information, you can add up the areas of the
triangles P(1)P(i)P(i+1) for i = 2, ..., n-1.  Compute these by using
the formula:

| 1   x(1)    y(1)  |
A(i) = (1/2)*Absolute value of | 1   x(i)    y(i)  |
| 1  x(i+1)  y(i+1) |

This also works because the triangle is convex.

If this doesn't suit your needs, write again, and we'll try again to

-Doctor Rob,  The Math Forum
Check out our web site!  http://mathforum.org/dr.math/
```
Associated Topics:
High School Coordinate Plane Geometry
High School Geometry
High School Triangles and Other Polygons

Search the Dr. Math Library:

 Find items containing (put spaces between keywords):   Click only once for faster results: [ Choose "whole words" when searching for a word like age.] all keywords, in any order at least one, that exact phrase parts of words whole words

Submit your own question to Dr. Math
Math Forum Home || Math Library || Quick Reference || Math Forum Search