Package org.opentrafficsim.base.geometry
Class RoundedRectangleShape
java.lang.Object
org.opentrafficsim.base.geometry.RoundedRectangleShape
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
-
Field Summary
Fields inherited from interface org.opentrafficsim.base.geometry.OtsShape
DEFAULT_POLYGON_SEGMENTS, WORLD_MARGIN_LINE -
Constructor Summary
ConstructorsConstructorDescriptionRoundedRectangleShape(double dx, double dy, double r) Constructor.RoundedRectangleShape(double dx, double dy, double r, int polygonSegments) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionReturns the bounds relative to the location.Returns the contour of the object in relative coordinates.doublesignedDistance(Point2d point) Signed distance function.toString()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.opentrafficsim.base.geometry.OtsShape
contains, contains, getAbsoluteBounds, getAbsoluteContour, getAbsoluteContour, getDirZ, getLocation, signedDistance
-
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
Description copied from interface:OtsShapeReturns the bounds relative to the location. The default implementation returns the bounds of the contour.- Specified by:
getRelativeBoundsin interfaceLocatable- Specified by:
getRelativeBoundsin interfaceOtsShape- Returns:
- bounds relative to the location.
-
signedDistance
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:
signedDistancein interfaceOtsShape- Parameters:
point- point for which distance is returned.- Returns:
- distance from point to these bounds.
- See Also:
-
getRelativeContour
Description copied from interface:OtsShapeReturns the contour of the object in relative coordinates.- Specified by:
getRelativeContourin interfaceOtsShape- Returns:
- the contour of the object in relative coordinates
-
toString
-