Click to See Complete Forum and Search --> : Area of Polygon... accurately
wossname
Jan 22nd, 2004, 06:59 AM
How do you calculate the area of an irregular polygon? The algorithm should work for any concievable 2D polygon, irregular or not.
I can't find any code on google.
Thanks.
Shaggy Hiker
Jan 22nd, 2004, 10:27 AM
I was just looking at planimeters and how they work on the web. I don't know an equation for finding the area of any polygon, and wasn't really thinking of doing such a thing, but one possibility would be to look at how planimeters work, and create your own function. Another would be to come up with a technique to chop your polygon into triangles. Once you have that, you can add the areas of the triangles.
wossname
Jan 22nd, 2004, 10:36 AM
Hmm, Planimeters were a real mind-f*** when I first saw one.
How the hell does a wheel on a stick find the area of anything? :D
Anyway, I have though of using a monte-carlo method but that would take too long to generate enough random numbers.
The triangles plan would cause stack problems with very complex polygons. I'm looking at more than 10000 sides here :eek:
Any more ideas anyone?
jemidiah
Jan 22nd, 2004, 08:56 PM
Not if you just put it in a loop instead of in a function. I'd bet the triangle would actually be the best option.
wossname
Jan 23rd, 2004, 03:15 AM
OK. but what triangles would I try to calculate?
Where for example would they be on this polygon...
http://www.vbforums.com/attachment.php?s=&postid=1609524
?
si_the_geek
Jan 23rd, 2004, 04:18 AM
found an explanation, with C and Java code:
http://astronomy.swin.edu.au/~pbourke/geometry/polyarea/
and one with Delphi code:
http://homepages.borland.com/efg2lab/Graphics/PolygonArea.htm
and a VERY simple explanation:
http://coderforums.com/archive/topic/2326-1.html
wossname
Jan 23rd, 2004, 08:46 AM
OK, that's pretty neat.
But what about self-intersecting polygons? Do you reckon that algorithm could be adapted to work on them too?
si_the_geek
Jan 23rd, 2004, 09:16 AM
what do you mean by self-intersecting? the lines crossing each other?
krtxmrtz
Jan 23rd, 2004, 10:22 AM
Originally posted by wossname
OK, that's pretty neat.
But what about self-intersecting polygons? Do you reckon that algorithm could be adapted to work on them too?
A self-intersected polygon can be just regarded as a number of non-intersected polygons.
krtxmrtz
Jan 23rd, 2004, 10:51 AM
I haven't used this for polygons with thousands of sides so I don't know if it might be too slow for you. Maybe it's worth a try.
http://www.vbforums.com/showthread.php?s=&threadid=233516
wossname
Jan 23rd, 2004, 02:53 PM
Thanks, I'll try it on Monday. :)
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.