Interface Bounds<B extends Bounds<B,P>,P extends Point<P>>

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

public interface Bounds<B extends Bounds<B,P>,P extends Point<P>>
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-2024 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

    Modifier and Type
    Method
    Description
    boolean
    contains(B otherBounds)
    Check if this Bounds completely contains another Bounds.
    boolean
    contains(P point)
    Check if a point is contained in this Bounds.
    boolean
    covers(B otherBounds)
    Check if no part of a Bounds is outside this Bounds.
    boolean
    covers(P point)
    Check if this Bounds covers or touches a point.
    boolean
    disjoint(B otherBounds)
    Return whether a Bounds is disjoint from this Bounds.
    default double
    Return the extent of this Bounds2d in the x-direction.
    default double
    Return the extent of this Bounds2d in the y-direction.
    double
    Return the absolute upper bound for x.
    double
    Return the absolute upper bound for y.
    double
    Return the absolute lower bound for x.
    double
    Return the absolute lower bound for y.
    intersection(B otherBounds)
    Return the intersecting Bounds of this Bounds and another Bounds.
    boolean
    intersects(B otherBounds)
    Return whether this Bounds intersects another Bounds.
    Return the mid point of this Bounds object.
  • Method Details

    • getMinX

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

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

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

      double getMaxY()
      Return the absolute upper bound for y.
      Returns:
      double; the absolute 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
    • midPoint

      P midPoint()
      Return the mid point of this Bounds object.
      Returns:
      P; the mid point of this Bounds object
    • contains

      boolean contains(P point) throws NullPointerException
      Check if a point is contained in this Bounds.
      Parameters:
      point - P; the point
      Returns:
      boolean; true if the point is within this Bounds; false if the point is not within this Bounds, or on an edge of this Bounds
      Throws:
      NullPointerException - when point is null
    • contains

      boolean contains(B otherBounds) throws NullPointerException
      Check if this Bounds completely contains another Bounds. If any point of the other Bounds lies on an edge (2d) or surface (3d) of this Bounds, this method returns false.
      Parameters:
      otherBounds - B; the Bounds to check for complete containment within this Bounds.
      Returns:
      boolean; false if any point of D is on or outside one of the borders of this Bounds; true when all points of D are contained within this Bounds.
      Throws:
      NullPointerException - when drawable2d is null
    • covers

      boolean covers(P point) throws NullPointerException
      Check if this Bounds covers or touches a point.
      Parameters:
      point - P; the Point for which to check if it is covered/touched by this Bounds
      Returns:
      boolean; whether this Bounds covers or touches the point
      Throws:
      NullPointerException - when point is null
    • covers

      boolean covers(B otherBounds) throws NullPointerException
      Check if no part of a Bounds is outside this Bounds. The edges/surfaces of this Bounds are considered inside.
      Parameters:
      otherBounds - B; the Bounds for which to check if it is covered by 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 a Bounds is disjoint from this Bounds. Touching at an edge is not considered disjoint. A Bounds that completely surrounds this Bounds is not disjoint.
      Parameters:
      otherBounds - B; the other Bounds
      Returns:
      boolean; true if the drawable is disjoint from this Bounds, or only touches an edge; false if any point of the other Bounds is inside this Bounds, or the other Bounds surrounds this Bounds
      Throws:
      NullPointerException - when bounds is null
    • intersects

      boolean intersects(B otherBounds)
      Return whether this Bounds intersects another Bounds. Touching at an edge is considered intersecting.
      Parameters:
      otherBounds - B; the other Bounds
      Returns:
      boolean; whether this bounding box/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 an edge is considered 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