Package org.opentrafficsim.base.geometry
Class RoundedRectangleShape
java.lang.Object
org.opentrafficsim.base.geometry.RoundedRectangleShape
- All Implemented Interfaces:
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
-
Field Summary
Fields inherited from interface org.opentrafficsim.base.geometry.OtsShape
CENTER, DEFAULT_POLYGON_SEGMENTS
-
Constructor Summary
ConstructorsConstructorDescriptionRoundedRectangleShape
(double dx, double dy, double r) Constructor.RoundedRectangleShape
(double dx, double dy, double r, int polygonSegments) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionorg.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.boolean
contains
(org.djutils.draw.point.Point2d point) Check if a point is contained in this OtsShape.double
getMaxX()
Return the absolute upper bound for x.double
getMaxY()
Return the absolute upper bound for y.double
getMinX()
Return the absolute lower bound for x.double
getMinY()
Return the absolute lower bound for y.double
signedDistance
(org.djutils.draw.point.Point2d point) Signed distance function.toString()
-
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
-
getMinX
public double getMinX()Description copied from interface:OtsShape
Return the absolute lower bound for x. -
getMaxX
public double getMaxX()Description copied from interface:OtsShape
Return the absolute upper bound for x. -
getMinY
public double getMinY()Description copied from interface:OtsShape
Return the absolute lower bound for y. -
getMaxY
public double getMaxY()Description copied from interface:OtsShape
Return the absolute upper bound for y. -
contains
Description copied from interface:OtsShape
Check if a point is contained in this OtsShape.- Specified by:
contains
in interfaceOtsShape
- 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.
- Throws:
NullPointerException
-
contains
Description copied from interface:OtsShape
Check if a point is contained in this OtsShape.- Specified by:
contains
in interfaceOtsShape
- Parameters:
x
- x-coordinatey
- 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.
- Throws:
NullPointerException
-
signedDistance
public 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.- Specified by:
signedDistance
in interfaceOtsShape
- Parameters:
point
- point for which distance is returned.- Returns:
- distance from point to these bounds.
- See Also:
-
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. -
toString
-