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
x * 0x0101010101010101ull | |
is equal to (x + (x<<8) + (x<<16) + ... + (x<<56)) |
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
Source: https://www.johndcook.com/blog/2018/09/26/polygon-area/ | |
Shoelace formula: | |
x1 y2 + x2 y3 + … xn y1 – y1 x2 – y2 x3 – … – yn x1 | |
Python implementation | |
def area(x, y): | |
n = len(x) | |
s = 0.0 |