Interface OtsShape

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

public interface OtsShape extends Locatable
Locatable that provides absolute and relative contours and bounds, both statically and dynamically.

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 Details

    • WORLD_MARGIN_LINE

      static final double WORLD_MARGIN_LINE
      Minimum world margin to click on object line or point objects.
      See Also:
    • DEFAULT_POLYGON_SEGMENTS

      static final int DEFAULT_POLYGON_SEGMENTS
      The default intended number of polygon segments to represent continuous shapes.
      See Also:
  • Method Details

    • getLocation

      DirectedPoint2d getLocation()
      Specified by:
      getLocation in interface Locatable
    • getAbsoluteContour

      default Polygon2d getAbsoluteContour()
      Returns the contour of the object in world coordinates.
      Returns:
      the contour of the object in world coordinates
    • getAbsoluteContour

      default Polygon2d getAbsoluteContour(Duration time)
      Return the contour of a dynamic object at time 'time' in world coordinates. The default implementation returns the static contour.
      Parameters:
      time - simulation time for which we want the shape
      Returns:
      the shape of the object at time 'time'
    • getRelativeContour

      Polygon2d getRelativeContour()
      Returns the contour of the object in relative coordinates.
      Returns:
      the contour of the object in relative coordinates
    • getRelativeBounds

      default Bounds2d getRelativeBounds()
      Returns the bounds relative to the location. The default implementation returns the bounds of the contour.
      Specified by:
      getRelativeBounds in interface Locatable
      Returns:
      bounds relative to the location.
    • contains

      default boolean contains(Point2d point)
      Returns whether the point is contained within the shape. The default implementation calculates this based on the contour.
      Parameters:
      point - point
      Returns:
      whether the point is contained within the shape
    • contains

      default boolean contains(double x, double y)
      Returns whether the point is contained within the shape. The default implementation calculates this based on the contour.
      Parameters:
      x - x coordinate of the point
      y - y coordinate of the point
      Returns:
      whether the point is contained within the shape
    • getAbsoluteBounds

      default Bounds2d getAbsoluteBounds()
      Returns the bounds in world coordinates.
      Returns:
      bounds in world coordinates.
    • getDirZ

      default double getDirZ()
      Specified by:
      getDirZ in interface Locatable
    • signedDistance

      default double signedDistance(Point2d point)
      Signed distance function. The point must be relative. 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, which is expensive.
      Parameters:
      point - point for which distance is returned.
      Returns:
      distance from point to these bounds.
    • signedDistance

      default double signedDistance(double x, double y)
      Signed distance function. The point must be relative. 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, which is expensive.
      Parameters:
      x - x coordinate of the point
      y - y coordinate of the point
      Returns:
      distance from point to these bounds.
    • boundsAsAbsoluteContour

      static Polygon2d boundsAsAbsoluteContour(OtsShape locatable)
      Generates a polygon as contour based on bounds and location of the locatable.
      Parameters:
      locatable - locatable
      Returns:
      contour
    • transformLine

      static PolyLine2d transformLine(PolyLine2d line, Point2d location)
      Transform the line by location, which may also be an OrientedPoint for rotation.
      Parameters:
      line - line
      location - location, which may also be an OrientedPoint for rotation
      Returns:
      transformed line
    • toRelativeTransform

      static Transform2d toRelativeTransform(Point2d location)
      Returns a transformation by which absolute coordinates can be translated and rotated to the frame of the possibly oriented location around which bounds are defined.
      Parameters:
      location - location (can be an Oriented).
      Returns:
      transformation.
    • toAbsoluteTransform

      static Transform2d toAbsoluteTransform(Point2d location)
      Returns a transformation by which relative coordinates can be translated and rotated to the frame of the possibly oriented location around which bounds are defined.
      Parameters:
      location - location (can be an Oriented).
      Returns:
      transformation.