Class InnerPlacementBoundaryCalculator


  • public class InnerPlacementBoundaryCalculator
    extends java.lang.Object
    • Constructor Detail

      • InnerPlacementBoundaryCalculator

        public InnerPlacementBoundaryCalculator()
    • Method Detail

      • innerPlacementBoundary

        public static Polygon2D innerPlacementBoundary​(Polygon2D outer,
                                                       Polygon2D inner)
        Calculates the boundary for placing the inner polygon within the outer polygon. Consider translating inner by some vector (x, y), such that inner is contained within outer. All such vectors form a shape, the boundary of this shape is itself a polygon, which is what this function calculates.

        Consider an example: Outer is a rectangle with vertices (0, 0), (6, 0), (6, 5), (0, 5). Inner is a square with vertices (-1, -1), (1, -1), (1, 1), (-1, 1). The result would be a rectangle with vertices (1, 1), (5, 1), (5, 4), (1, 4).

        If inner does not fit within outer null is returned.

        If inner fits exactly within outer, ie. inner can be translated so it is equal to outer, then a 1-gon is returned.

        If inner fits exactly within outer in only one of two dimensions, then a 2-gon is returned.

        Both inner and outer must have at least three vertices, and must be convex.

        Parameters:
        outer - The inner polygon.
        inner - The outer polygon.
        Returns:
        The placement boundary polygon.