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.
Printable View
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.
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.
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?
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.
OK. but what triangles would I try to calculate?
Where for example would they be on this polygon...
http://www.vbforums.com/attachment.p...postid=1609524
?
found an explanation, with C and Java code:
http://astronomy.swin.edu.au/~pbourk...etry/polyarea/
and one with Delphi code:
http://homepages.borland.com/efg2lab...olygonArea.htm
and a VERY simple explanation:
http://coderforums.com/archive/topic/2326-1.html
OK, that's pretty neat.
But what about self-intersecting polygons? Do you reckon that algorithm could be adapted to work on them too?
what do you mean by self-intersecting? the lines crossing each other?
A self-intersected polygon can be just regarded as a number of non-intersected polygons.Quote:
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?
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.p...hreadid=233516
Thanks, I'll try it on Monday. :)