Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def PolygonArea(corners):
- n = len(corners) # of corners
- area = 0.0
- for i in range(n):
- j = (i + 1) % n
- area += corners[i][0] * corners[j][1]
- area -= corners[j][0] * corners[i][1]
- area = abs(area) / 2.0
- return area
- # examples
- #-50:50 -26.36:50 40.23:15.18 -5.6:-50 -50:-50
- corners = [ (-26.36, 50), (-50, 50),(40.23, 15.18), (40.23, 15.18), (-50, -50), (-5.6, -50)]
- print(PolygonArea(corners))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement