Module org.dyn4j

Class AxisAlignedBounds

  • All Implemented Interfaces:
    Bounds, Shiftable, Translatable

    public 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:
    3.4.0
    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:
        java.lang.IllegalArgumentException - if either width or height are less than or equal to zero
    • Method Detail

      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • isOutside

        public boolean isOutside​(Collidable<?> collidable)
        Description copied from interface: Bounds
        Returns true if the given Collidable is fully outside the bounds.

        If the Collidable contains zero Fixtures then Collidable is considered to be outside the bounds.

        Specified by:
        isOutside in interface Bounds
        Parameters:
        collidable - the Collidable to test
        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