[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Algorithm for Area of a closed polygon.



Hi TEd,
Here is a simple method,
 
let us say the polygon is given by { (0,0), (10,0), (10,10), (0,10) }
Gven the array of [x,y] write then in 2 columns
 
X  Y
--------
0    0
10  0
10  10
0   10
0   0
 
do cross multiplication as you march down the column and sum the results on left side and right side
eg
0*0 + 10*10+10*10+0*0 = 200 on left column
0*10+ 0*10 +10*0 + 10*0 = 0 on right column
subtract the left column from right column = 0 - 200 = -200
divide this by 2 to get area = -100 (if you want absolute area use abs)
 
HTH
sandeep
btw: this can be programmed in 4way SIMD on Intel and others to run "extremely fast"
 
 
 
-----Original Message-----
From: Ted Hill [mailto:thill@tomotherapy.com]
Sent: Wednesday, November 12, 2003 7:00 AM
To: compgeom-discuss@research.bell-labs.com
Subject: Algorithm for Area of a closed polygon.

I want to be able to calculate the area inside a closed many-sided polygon.

 

Given an array of the (x,y) vertices that define the polygon, is there a well-known algorithm that can calculate the enclosed area quickly?

 

Thanks,

 

Ted Hill