Interface OtsShape

All Known Implementing Classes:
CircleShape, OffsetRectangleShape, PolygonShape, RectangleShape, RoundedRectangleShape

public interface OtsShape
Shape representation of objects that is suitable for continuous spatial 2D algorithms. Default methods use the polygon representation of the shape. For many simple shapes there may be faster methods to determine information.

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
    Modifier and Type
    Field
    Description
    static final org.djutils.draw.point.Point2d
    Standard mid point.
    static final int
    Default number of segments in polygon.
  • 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.
    default boolean
    contains(double x, double y)
    Check if a point is contained in this OtsShape.
    default boolean
    contains(org.djutils.draw.point.Point2d point)
    Check if a point is contained in this OtsShape.
    default double
    Return the extent of this Bounds2d in the x-direction.
    default double
    Return the extent of this Bounds2d in the y-direction.
    default double
    Return the absolute upper bound for x.
    default double
    Return the absolute upper bound for y.
    default double
    Return the absolute lower bound for x.
    default double
    Return the absolute lower bound for y.
    default org.djutils.draw.point.Point2d
    Return the mid point of this Bounds object.
    default double
    signedDistance(org.djutils.draw.point.Point2d point)
    Signed distance function.
  • Field Details

    • CENTER

      static final org.djutils.draw.point.Point2d CENTER
      Standard mid point.
    • DEFAULT_POLYGON_SEGMENTS

      static final int DEFAULT_POLYGON_SEGMENTS
      Default number of segments in polygon.
      See Also:
  • Method Details

    • getMinX

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

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

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

      default 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

      default org.djutils.draw.point.Point2d midPoint()
      Return the mid point of this Bounds object.
      Returns:
      P; the mid point of this Bounds object
    • contains

      default boolean contains(org.djutils.draw.point.Point2d point)
      Check if a point is contained in this OtsShape.
      Parameters:
      point - the point
      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.
    • contains

      default boolean contains(double x, double y)
      Check if a point is contained in this 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.
    • asPolygon

      org.djutils.draw.line.Polygon2d asPolygon()
      Returns a polygon representation of the bounds, such that an intersection can be derived.
      Returns:
      polygon representation of the bounds.
    • signedDistance

      default 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.
      Parameters:
      point - point for which distance is returned.
      Returns:
      distance from point to these bounds.