Pick's Theorem
Pick's theorem says that if a polygon has I vertices/points inside it and B vertices or points on the border of it, then the AREA of this polygon is :
AREA = I + ( B / 2 ) -1
There some conditions for applying this theorem.
- The shape must be a polygon. It can be concave or convex, but not self-intersecting. No circles apply here.
- Each vertex of the polygon must fall on the board.
- The polygon must be complete. No holes. Although, if it does have a hole, we can still compute the area by subtracting the smaller area from the larger area if the interior hole is also a lattice polygon.
- Pick's formula assumes unit measures and unit squares for the area. You can make your unit whatever you desire though if sides of your shape aren't whole numbers. However, you must adjust the value of your unit squares accordingly. So, if you made your lattice units 0.5, your interior squares would each be 0.5*0.5=0.25 square units each.
A problem related to Picks Theorem is LightOJ 1418 - Trees on My Island
So we need to find Area and number of border vertices B.
We can easily find areas using coordinates by the Shoelace formula.
We can easily find areas using coordinates by the Shoelace formula.
Shoelace formula says that if the coordinates are (X1, Y1), (X2, Y2)......(Xn, Yn) then
Area = | 1/2 [ (x1y2 + x2y3 + ... + xn-1yn + xny1) - (x2y1 + x3y2 + ... + xnyn-1 + x1yn) ] |
Now we have to find how many vertices are on the border of the polygon.
We can easily understand that all the input vertices are obviously on the border of the polygon.
now we have to find if there any integer vertices exist that are laying the line of any two adjacent vertices.
If you don't know how to find it out then read this article.
So, now we have an area and B, we can easily calculate I.
We can easily understand that all the input vertices are obviously on the border of the polygon.
now we have to find if there any integer vertices exist that are laying the line of any two adjacent vertices.
If you don't know how to find it out then read this article.
So, now we have an area and B, we can easily calculate I.
<---------------> HAPPY CODING <--------------->
Comments
Post a Comment