Class OffsetRectangleShape

java.lang.Object
org.opentrafficsim.base.geometry.OffsetRectangleShape
All Implemented Interfaces:
OtsShape

public class OffsetRectangleShape extends Object implements OtsShape
Shape defined by an offset rectangle.

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
  • Field Summary

    Fields inherited from interface org.opentrafficsim.base.geometry.OtsShape

    CENTER, DEFAULT_POLYGON_SEGMENTS
  • Constructor Summary

    Constructors
    Constructor
    Description
    OffsetRectangleShape(double minX, double maxX, double minY, double maxY)
    Constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    org.djutils.draw.line.Polygon2d
    Returns a polygon representation of the bounds, such that an intersection can be derived.
    boolean
    contains(double x, double y)
    Check if a point is contained in this OtsShape.
    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.
    org.djutils.draw.point.Point2d
    Return the mid point of this Bounds object.
    double
    signedDistance(org.djutils.draw.point.Point2d point)
    Signed distance function.
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface org.opentrafficsim.base.geometry.OtsShape

    contains, getDeltaX, getDeltaY
  • Constructor Details

    • OffsetRectangleShape

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

    • getMinX

      public double getMinX()
      Description copied from interface: OtsShape
      Return the absolute lower bound for x.
      Specified by:
      getMinX in interface OtsShape
      Returns:
      double; the absolute lower bound for x
    • getMaxX

      public double getMaxX()
      Description copied from interface: OtsShape
      Return the absolute upper bound for x.
      Specified by:
      getMaxX in interface OtsShape
      Returns:
      double; the absolute upper bound for x
    • getMinY

      public double getMinY()
      Description copied from interface: OtsShape
      Return the absolute lower bound for y.
      Specified by:
      getMinY in interface OtsShape
      Returns:
      double; the absolute lower bound for y
    • getMaxY

      public double getMaxY()
      Description copied from interface: OtsShape
      Return the absolute upper bound for y.
      Specified by:
      getMaxY in interface OtsShape
      Returns:
      double; the absolute upper bound for y
    • contains

      public boolean contains(double x, double y)
      Description copied from interface: OtsShape
      Check if a point is contained in this OtsShape.
      Specified by:
      contains in interface OtsShape
      Parameters:
      x - x-coordinate
      y - y-coordinate
      Returns:
      true if the point is within this OtsShape; false if the point is not within this OtsShape. Results may be ill-defined for points on the edges of this Polygon.
    • midPoint

      public org.djutils.draw.point.Point2d midPoint()
      Description copied from interface: OtsShape
      Return the mid point of this Bounds object.
      Specified by:
      midPoint in interface OtsShape
      Returns:
      P; the mid point of this Bounds object
    • signedDistance

      public double signedDistance(org.djutils.draw.point.Point2d point)
      Description copied from interface: OtsShape
      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 OtsShape
      Parameters:
      point - point for which distance is returned.
      Returns:
      distance from point to these bounds.
    • asPolygon

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

      public String toString()
      Overrides:
      toString in class Object