Class BoundingRectangle

java.lang.Object
org.opentrafficsim.base.geometry.BoundingRectangle
All Implemented Interfaces:
org.djutils.draw.bounds.Bounds<OtsBounds2d,org.djutils.draw.point.Point2d,org.djutils.draw.Drawable2d>, OtsBounds2d

public class BoundingRectangle extends Object implements OtsBounds2d
Bounding rectangle; this is a non-centered box.

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

Author:
Wouter Schakel
  • Constructor Details

    • BoundingRectangle

      public BoundingRectangle(double minX, double maxX, double minY, double maxY)
      Constructor.
      Parameters:
      minX - double; minimum x coordinate.
      maxX - double; maximum x coordinate.
      minY - double; minimum y coordinate.
      maxY - double; maximum y coordinate.
  • Method Details

    • midPoint

      public org.djutils.draw.point.Point2d midPoint()
      Specified by:
      midPoint in interface org.djutils.draw.bounds.Bounds<OtsBounds2d,org.djutils.draw.point.Point2d,org.djutils.draw.Drawable2d>
      Specified by:
      midPoint in interface OtsBounds2d
    • signedDistance

      public double signedDistance(org.djutils.draw.point.Point2d point)
      Signed distance function. The coordinates must be transformed to this bound's space. Negative distances returned are inside the bounds, with the absolute value of the distance towards the edge. The default implementation is based on the polygon representation and is expensive.
      Specified by:
      signedDistance in interface OtsBounds2d
      Parameters:
      point - Point2d; point for which distance is returned.
      Returns:
      double; distance from point to these bounds.
    • asPolygon

      public org.djutils.draw.line.Polygon2d asPolygon()
      Returns a polygon representation of the bounds, such that an intersection can be derived.
      Specified by:
      asPolygon in interface OtsBounds2d
      Returns:
      Polygon2d; polygon representation of the bounds.
    • toString

      public String toString()
      Overrides:
      toString in class Object