Skip to content

Commit 228d99c

Browse files
author
maoyifei
committed
add collision
1 parent 8ba5052 commit 228d99c

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

GEMstack/mathutils/collisions.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,18 @@ def polygon_intersects_polygon_2d(poly1 : List[Tuple[float,float]], poly2 : List
159159
"""
160160
return shapely.Polygon(poly1).intersects(shapely.Polygon(poly2))
161161

162+
def polygon_contains_polygon_2d(poly1 : List[Tuple[float,float]], poly2 : List[Tuple[float,float]]) -> bool:
163+
"""Returns whether one polygon contains another polygon.
164+
165+
Args:
166+
poly1 (List[Tuple[float,float]]): The containing polygon
167+
poly2 (List[Tuple[float,float]]): The polygon to check if it's contained
168+
169+
Returns:
170+
bool: True if poly1 contains poly2, False otherwise
171+
"""
172+
return shapely.Polygon(poly1).contains_properly(shapely.Polygon(poly2))
173+
162174
def polygon_polygon_distance_2d(poly1 : List[Tuple[float,float]], poly2 : List[Tuple[float,float]]) -> float:
163175
"""Returns the distance between two polygons.
164176

0 commit comments

Comments
 (0)