minkowski_difference_xy
- compas_model.geometry.minkowski_difference_xy(A, B)
Compute the Minkowski difference of convex polygons A and B in the XY plane.
- Parameters:
- A
compas.geometry.Polygon
The first polygon.
- B
compas.geometry.Polygon
The second polygon.
- A
- Returns:
compas.geometry.Polygon
The polygon representing the difference as the sum of A and -B.
Warning
Currently only convex polygons are supported.
See also
compas_model.algorithms.is_collision_poly_poly_xy()
Notes
The Minkwoski “difference” of two polygons A and B, can be formulated as the Minkowski sum of A and inverted B: A + (-B). [1]
A useful application of the Minkowski difference of two convex polygons A and B is collision detection. If the origin (0, 0) is contained in the difference polygon A + (-B), then a collision between A and B exists.
References
Examples
>>> from compas.geometry import Polygon >>> from compas.geometry import is_point_in_convex_polygon_xy >>> from compas_model.geometry import minkowski_difference_xy
>>> A = Polygon.from_rectangle([1, 0, 0], 1, 1) >>> B = Polygon.from_sides_and_radius_xy(5, 1).translated([2.5, 1, 0]) >>> C = minkowski_difference_xy(A, B)
>>> is_point_in_convex_polygon_xy([0, 0, 0], C) True