def polygon_obb(polygon):
'''
Find the oriented bounding box of a Shapely polygon.
The OBB is always aligned with an edge of the convex hull of the polygon.
Arguments
-------------
polygons: shapely.geometry.Polygon
Returns
-------------
transform: (3,3) float, transformation matrix
which will move input polygon from its original position
to the first quadrant where the AABB is the OBB
extents: (2,) float, extents of transformed polygon
'''
points = np.asanyarray(polygon.exterior.coords)
return bounds.oriented_bounds_2D(points)
评论列表
文章目录