Interface Bounds<B extends Bounds<B,​S>,​S extends Space>

  • Type Parameters:
    B - The bounds type
    S - The space type (2d or 3d)
    All Known Implementing Classes:
    Bounds2d, Bounds3d

    public interface Bounds<B extends Bounds<B,​S>,​S extends Space>
    Bounds is the generic tagging interface that indicates the bounds for an object, where the simplest implementation is minX, minY, maxX and maxY for 2D, and minX, minY, minZ and maxX, maxY and maxZ for 3D. Other bounds such as a BoundingCircle, BoundingSphere or BoundingPolytope could also be defined.

    Copyright (c) 2020-2021 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
    BSD-style license. See DJUTILS License.

    Author:
    Alexander Verbraeck, Peter Knoppers
    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      boolean covers​(B otherBounds)
      Check if this Bounds contains another Bounds.
      boolean disjoint​(B otherBounds)
      Return whether this Bounds is disjoint from another Bounds.
      default double getDeltaX()
      Return the extent of this Bounds2d in the x-direction.
      default double getDeltaY()
      Return the extent of this Bounds2d in the y-direction.
      double getMaxX()
      Return the upper bound for x.
      double getMaxY()
      Return the upper bound for y.
      double getMinX()
      Return the lower bound for x.
      double getMinY()
      Return the lower bound for y.
      B intersection​(B otherBounds)
      Return the intersecting Bounds of this Bounds and another Bounds.
      boolean intersects​(B otherBounds)
      Return whether this Bounds intersects another Bounds.
    • Method Detail

      • getMinX

        double getMinX()
        Return the lower bound for x.
        Returns:
        double; the lower bound for x
      • getMaxX

        double getMaxX()
        Return the upper bound for x.
        Returns:
        double; the upper bound for x
      • getMinY

        double getMinY()
        Return the lower bound for y.
        Returns:
        double; the lower bound for y
      • getMaxY

        double getMaxY()
        Return the upper bound for y.
        Returns:
        double; the upper bound for y
      • getDeltaX

        default double getDeltaX()
        Return the extent of this Bounds2d in the x-direction.
        Returns:
        double; the extent of this Bounds2d in the x-direction
      • getDeltaY

        default double getDeltaY()
        Return the extent of this Bounds2d in the y-direction.
        Returns:
        double; the extent of this Bounds2d in the y-direction
      • covers

        boolean covers​(B otherBounds)
                throws NullPointerException
        Check if this Bounds contains another Bounds. Covers returns true when one of the edges of the other Bounds (partly) overlaps a border of this Bounds.
        Parameters:
        otherBounds - B; the Bounds for which to check if it is contained within this Bounds
        Returns:
        boolean; whether this Bounds contains the provided Bounds, including overlapping borders
        Throws:
        NullPointerException - when otherBounds is null
      • disjoint

        boolean disjoint​(B otherBounds)
                  throws NullPointerException
        Return whether this Bounds is disjoint from another Bounds. Only touching at an edge is considered disjoint.
        Parameters:
        otherBounds - B; the other Bounds
        Returns:
        boolean; whether this Bounds is disjoint from another Bounds
        Throws:
        NullPointerException - when bounds is null
      • intersects

        boolean intersects​(B otherBounds)
        Return whether this Bounds intersects another Bounds. Only touching at an edge is not seen as intersecting.
        Parameters:
        otherBounds - B; the other Bounds
        Returns:
        boolean; whether this bounding rectangle intersects the other Bounds
        Throws:
        NullPointerException - when otherBounds is null
      • intersection

        B intersection​(B otherBounds)
        Return the intersecting Bounds of this Bounds and another Bounds. Touching at the edge is not seen as intersecting. In case there is no intersection, null is returned.
        Parameters:
        otherBounds - B; the other Bounds
        Returns:
        Bounds; the intersecting Bounds of this Bounds and another Bounds. Touching at the edge is not seen as intersecting. If not intersecting; null is returned
        Throws:
        NullPointerException - when otherBounds is null