Created
June 7, 2020 18:05
-
-
Save altsoph/7d94fdab21b3ba1b3cf10fe5f3e3f7c0 to your computer and use it in GitHub Desktop.
This file contains 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
# pip install shapely | |
from shapely.geometry.polygon import Polygon | |
def check(polygon, square): | |
polygon = Polygon(polygon) | |
square = Polygon(square) | |
return polygon.contains(square) | |
print( check( [(0, 0), (0, 1), (1, 1), (1, 0)], [(0.1, 0.9), (0.1, 0.9), (0.9, 0.9), (0.9, 0.1)] ) ) | |
# > True | |
print( check( [(0, 0), (0, 1), (1, 1), (1, 0)], [(0.1, 1.1), (0.1, 0.9), (0.9, 0.9), (0.9, 0.1)] ) ) | |
# > False |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment