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
from polygenerator import random_polygon | |
import matplotlib.pyplot as plt | |
def is_inside(edges, xp, yp): | |
cnt = 0 | |
for edge in edges: | |
(x1, y1), (x2, y2) = edge | |
if (yp < y1) != (yp < y2) and xp < x1 + ((yp-y1)/(y2-y1))*(x2-x1): | |
cnt += 1 |
OlderNewer