PDA

View Full Version : Area of a polygon


weedweaver
10-27-2003, 02:52 PM
I am writing a program that calculates the area of a polygon (any shape) given the 5 vertices.

Does any-one know the maths behind calculating areas of polygons? Think its something to do with differentiation and area
under a line?

im creating a type

type vertex = (Float,Float)
data shape =
| Polygon [vertex] **List of tuples**

so for any given 5 verticies it will calcualte the area. if anyone knows any good maths web-sites where i could find the maths for working it out, or if anyone actually knows, please let me know.
Thanks.
Matt

weedweaver
10-27-2003, 03:14 PM
ah its ok worked it out:
* Every pair of adjacent verticies form a trapezioid (with respect to the x axis)
* u can start at any point and work clockwise and calculate the areas of the trapezioid, the area is positive if the x-coordinatre increases and negative if it decreases.
* sum of these areas is the area of the polygon.

quite simple really!! lol