Class RoundedRectangleShape

java.lang.Object
org.opentrafficsim.base.geometry.RoundedRectangleShape
All Implemented Interfaces:
Locatable, OtsShape

public abstract class RoundedRectangleShape extends Object implements OtsShape
Shape defined by a rounded 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
  • Constructor Details

    • RoundedRectangleShape

      public RoundedRectangleShape(double dx, double dy, double r)
      Constructor.
      Parameters:
      dx - complete length along x dimension.
      dy - complete length along y dimension.
      r - radius of rounding, must be positive.
      Throws:
      IllegalArgumentException - when r is negative, or so large no net shape remains
    • RoundedRectangleShape

      public RoundedRectangleShape(double dx, double dy, double r, int polygonSegments)
      Constructor.
      Parameters:
      dx - complete length along x dimension.
      dy - complete length along y dimension.
      r - radius of rounding, must be positive.
      polygonSegments - number of segments in polygon representation.
      Throws:
      IllegalArgumentException - when r is negative, or so large no net shape remains
  • Method Details

    • getRelativeBounds

      public Bounds2d getRelativeBounds()
      Description copied from interface: OtsShape
      Returns the bounds relative to the location. The default implementation returns the bounds of the contour.
      Specified by:
      getRelativeBounds in interface Locatable
      Specified by:
      getRelativeBounds in interface OtsShape
      Returns:
      bounds relative to the location.
    • signedDistance

      public 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.
      Specified by:
      signedDistance in interface OtsShape
      Parameters:
      point - point for which distance is returned.
      Returns:
      distance from point to these bounds.
      See Also:
    • getRelativeContour

      public Polygon2d getRelativeContour()
      Description copied from interface: OtsShape
      Returns the contour of the object in relative coordinates.
      Specified by:
      getRelativeContour in interface OtsShape
      Returns:
      the contour of the object in relative coordinates
    • toString

      public String toString()
      Overrides:
      toString in class Object