Package org.opentrafficsim.base.geometry
Class BoundingRectangle
java.lang.Object
org.opentrafficsim.base.geometry.BoundingRectangle
- All Implemented Interfaces:
org.djutils.draw.bounds.Bounds<OtsBounds2d,
,org.djutils.draw.point.Point2d, org.djutils.draw.Drawable2d> OtsBounds2d
Bounding rectangle; this is a non-centered box.
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.OtsBounds2d
CENTER
-
Constructor Summary
ConstructorDescriptionBoundingRectangle
(double minX, double maxX, double minY, double maxY) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionorg.djutils.draw.line.Polygon2d
Returns a polygon representation of the bounds, such that an intersection can be derived.org.djutils.draw.point.Point2d
midPoint()
double
signedDistance
(org.djutils.draw.point.Point2d point) Signed distance function.toString()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.djutils.draw.bounds.Bounds
getDeltaX, getDeltaY
Methods inherited from interface org.opentrafficsim.base.geometry.OtsBounds2d
contains, contains, covers, covers, disjoint, getMaxX, getMaxY, getMinX, getMinY, intersection, intersects
-
Constructor Details
-
BoundingRectangle
public BoundingRectangle(double minX, double maxX, double minY, double maxY) Constructor.- Parameters:
minX
- double; minimum x coordinate.maxX
- double; maximum x coordinate.minY
- double; minimum y coordinate.maxY
- double; maximum y coordinate.
-
-
Method Details
-
midPoint
public org.djutils.draw.point.Point2d midPoint()- Specified by:
midPoint
in interfaceorg.djutils.draw.bounds.Bounds<OtsBounds2d,
org.djutils.draw.point.Point2d, org.djutils.draw.Drawable2d> - Specified by:
midPoint
in interfaceOtsBounds2d
-
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 interfaceOtsBounds2d
- Parameters:
point
- Point2d; point for which distance is returned.- Returns:
- double; distance from point to these bounds.
-
asPolygon
public org.djutils.draw.line.Polygon2d asPolygon()Returns a polygon representation of the bounds, such that an intersection can be derived.- Specified by:
asPolygon
in interfaceOtsBounds2d
- Returns:
- Polygon2d; polygon representation of the bounds.
-
toString
-