Module org.dyn4j

Class AxisAlignedBounds

  • All Implemented Interfaces:
    Bounds, Shiftable, Translatable

    public final class AxisAlignedBounds
    extends AbstractBounds
    implements Bounds, Translatable
    Represents a bounding region that is an Axis-Aligned bounding box.

    This class compares its AABB with the AABB of the given body and returns true if they do not overlap.

    Since:
    3.1.1
    Version:
    4.2.1
    Author:
    William Bittle
    • Field Detail

      • aabb

        protected final AABB aabb
        The local coordinates AABB
    • Constructor Detail

      • AxisAlignedBounds

        public AxisAlignedBounds​(double width,
                                 double height)
        Minimal constructor.
        Parameters:
        width - the width of the bounds; must be greater than zero
        height - the height of the bounds; must be greater than zero
        Throws:
        IllegalArgumentException - if either width or height are less than or equal to zero
    • Method Detail

      • isOutside

        public boolean isOutside​(AABB aabb)
        Description copied from interface: Bounds
        Returns true if the given AABB is fully outside the bounds.

        If the AABB is a degenerate AABB (has zero area) then it's considered to be outside the bounds.

        Specified by:
        isOutside in interface Bounds
        Parameters:
        aabb - the AABB to test
        Returns:
        boolean true if outside the bounds
      • isOutside

        public boolean isOutside​(AABB aabb,
                                 Transform transform,
                                 Fixture fixture)
        Description copied from interface: Bounds
        Returns true if the given AABB or Fixture is fully outside the bounds.

        The implementation can use any of the provided information. For example, the AxisAlignedBounds class only uses the provided AABB. For implementations of complex bounds, you can use the Transform and shape contained in the Fixture.

        Specified by:
        isOutside in interface Bounds
        Parameters:
        aabb - the AABB to test
        transform - the Transform for the fixture
        fixture - the Fixture (shape)
        Returns:
        boolean true if outside the bounds
      • getBounds

        public AABB getBounds()
        Returns the world space Axis-Aligned bounding box for this bounds object.
        Returns:
        AABB
      • getWidth

        public double getWidth()
        Returns the width of the bounds.
        Returns:
        double
      • getHeight

        public double getHeight()
        Returns the height of the bounds.
        Returns:
        double