Jump to content
  • Advertisement
Sign in to follow this  
afsajghfd

how to calculate the area of a irregular polygon

This topic is 3756 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hi all, well .. the topic says it all I have all the vertex and the lengths of each side. looking for an answer on google, i found the following http://foro.gabrielortiz.com/imagenes/formula_area_poligono.gif A = 1/2 * (SUM [(x(i) * y(i+1)) - (x(i+1) * y(i))] from 0 to n-1 but this doesn't return a very good value :/ and yes i saw that vertex must be clockwise i was thinking .. if I have the perimeter of this polygon .. can I do with this value the maximum box, so then calculate the area ? for example, if the perimeter of the irregular polygon it's 30, can I just divide 30/4 to get one side of the box (7,5) .. and then multiplicate 7,5*7,5 to get the area ? thanks ..

Share this post


Link to post
Share on other sites
Advertisement
Define "doesn't return a very good value". That formula computes the correct value... if you want a different one, you'll need to pick a different polygon.

Share this post


Link to post
Share on other sites
I'm not clear on what the problem is. You found a formula that gives you the exactly correct answer, and it uses only basic operations. If your vertices are in counter clockwise order then it will still work if you just take the absolute value. I don't know of a way to get the area from the perimeter, but I wouldn't recommend it anyways since finding the perimeter is going to require a number of squareroots making it much slower than the correct area formula.

edit: curse my verboseness, beaten again!

Share this post


Link to post
Share on other sites
Quote:
Original post by afsajghfd
hi all, well .. the topic says it all
I have all the vertex and the lengths of each side.
looking for an answer on google, i found the following

http://foro.gabrielortiz.com/imagenes/formula_area_poligono.gif

A = 1/2 * (SUM [(x(i) * y(i+1)) - (x(i+1) * y(i))] from 0 to n-1

but this doesn't return a very good value :/ and yes i saw that vertex must be
clockwise

i was thinking .. if I have the perimeter of this polygon .. can I
do with this value the maximum box, so then calculate the area ?

for example, if the perimeter of the irregular polygon it's 30, can I
just divide 30/4 to get one side of the box (7,5) .. and then multiplicate
7,5*7,5 to get the area ?

thanks ..


No, by maintaining a constant perimeter, or even maining the length of each individual side, or even by maintaining the sequence of each length of your sides within the polygon you can still get a different area by changing the angles between each of the sides.

The formula could be different for each and every polygon unless they are 100% exactly the same each each time. Try dividing the polygon into triangles then calculate the triangles area with law of sines or cosines which is exactly how I would give it a shot...

http://mathworld.wolfram.com/Polygon.html

Good Luck

CrypticDragon

Share this post


Link to post
Share on other sites
Quote:
Original post by afsajghfd
hi all, well .. the topic says it all
I have all the vertex and the lengths of each side.
looking for an answer on google, i found the following

http://foro.gabrielortiz.com/imagenes/formula_area_poligono.gif

A = 1/2 * (SUM [(x(i) * y(i+1)) - (x(i+1) * y(i))] from 0 to n-1

but this doesn't return a very good value :/ and yes i saw that vertex must be
clockwise

i was thinking .. if I have the perimeter of this polygon .. can I
do with this value the maximum box, so then calculate the area ?

for example, if the perimeter of the irregular polygon it's 30, can I
just divide 30/4 to get one side of the box (7,5) .. and then multiplicate
7,5*7,5 to get the area ?

thanks ..


The formula you have written is correct and, as long as you take the absolute value, the orientation of the vertices isn’t relevant. Why do you say that it doesn’t return a very good value? Is the polygon simple (non self-intersecting)? If it isn't simple the formula doesn’t work. You can triangulate the polygon and than sum the are of the triangles in that case (there can be easier solutions...).
You can’t calculate the area only using the perimeter of the polygon, two polygons with the same perimeter can have different areas. Consider for example a square with edge of 4 and a rectangle of edges of 2 and 6. They have the same perimeter 16 but their areas are 42=16 and 2*6=12.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!