Created
March 27, 2025 13:24
-
-
Save WiwilZ/2ee97099a0da3f4cce6f2c0973cd6ad8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def calc_polygon_area(points): | |
| assert len(points) >= 3 | |
| area = 0 | |
| for i in range(len(points) - 1): | |
| x1, y1 = points[i] | |
| x2, y2 = points[i + 1] | |
| area += (y1 + y2) * (x2 - x1) | |
| x1, y1 = points[-1] | |
| x2, y2 = points[0] | |
| area += (y1 + y2) * (x2 - x1) | |
| return abs(-area * 0.5) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment