2

enter image description here

How can i calculate area of that kind of polygon. I know the coordinates of all vertices. I apply Shoelace formula, but it gives me wrong value then expected. Autocad application calculates true value. How can it calculates. What is the correct approach for calculating area of this kind of polygons?

Thanks.

EDIT

Coordinates are :

  1. PointD p1 = new PointD(-50, 0);
  2. PointD p2 = new PointD(50, 0);
  3. PointD p3 = new PointD(50, 8);
  4. PointD p4 = new PointD(15, 8);
  5. PointD p5 = new PointD(3, 20);
  6. PointD p6 = new PointD(3, 76);
  7. PointD p7 = new PointD(15, 88);
  8. PointD p8 = new PointD(50, 88);
  9. PointD p9 = new PointD(50, 96);
  10. PointD p10 = new PointD(-50, 96);
  11. PointD p11 = new PointD(-50, 88);
  12. PointD p12 = new PointD(-15, 88);
  13. PointD p13 = new PointD(-3, 76);
  14. PointD p14 = new PointD(-3, 20);
  15. PointD p15 = new PointD(-15, 8);
  16. PointD p16 = new PointD(-50, 8);
  • 1
    The white area seems much easier to calculate than the green one. In this specific case you can calculate the area of the big rectangle minus the two white areas. In general, you may want to try and split the green area into rectangles, triangles and trapezoids. – Pedro M. Jan 28 '15 at 15:16
  • No i don't want to calculate by splitting into small regions. I think it can be calculated by applying Green's theorem. But i do not understand that theory. – moleschott Jan 28 '15 at 15:22
  • Add the coordinates. Otherwise, it's hard to answer by plain English. – barak manos Jan 28 '15 at 15:22
  • Ok. I added coordinates from c# code. – moleschott Jan 28 '15 at 15:31
  • 1
    The Shoelace formula has been working for centuries, you have not used it properly. Show us your computation. –  Jan 28 '15 at 15:43

2 Answers2

1

The Shoelace formula seems to work OK. $$\begin{array} {rr}\\ x & y & s1 & s2 & area \\ \hline -50 & 0 & 0 & 0 & 0 \\ 50 & 0 & 400 & 0 & 200 \\ 50 & 8 & 400 & 120 & 140 \\ 15 & 8 & 300 & 24 & 138 \\ 3 & 20 & 228 & 60 & 84 \\ 3 & 76 & 264 & 1140 & -438 \\ 15 & 88 & 1320 & 4400 & -1540 \\ 50 & 88 & 4800 & 4400 & 200 \\ 50 & 96 & 4800 & -4800 & 4800 \\ -50 & 96 & -4400 & -4800 & 200 \\ -50 & 88 & -4400 & -1320 & -1540 \\ -15 & 88 & -1140 & -264 & -438 \\ -3 & 76 & -60 & -228 & 84 \\ -3 & 20 & -24 & -300 & 138 \\ -15 & 8 & -120 & -400 & 140 \\ -50 & 8 & 0 & -400 & 200 \\ \hline &&&&2368 \end{array}$$


Confirming the area by summing portions:

  • Bottom bar: $8\times 100 = 800$
  • Top bar: also $800$
  • Centre bar: $6 \times 80 = 480$
  • Bracing triangles, each: $12\times 12 / 2 = 72$
  • Total: $800+800+480+4\times 72 = 2368$
Joffan
  • 39,627
0

Because your polygon is specified as integer coordinates on a square lattice, a simple formula you can use is Pick's theorem. Of course, there is the task of actually counting the interior points and the boundary points, but this should not be too difficult for you to do by visual inspection and some easy computation, due to the nature of the shape. Problem is, this method applied to your figure is not any easier than manually computing the area as the sum of simpler polygons. But if what you are asking for is a computer algorithm, then Pick's theorem may be a method to implement the automation of the area calculation.

heropup
  • 135,869