Package org.opentrafficsim.core.geometry
Class OtsShape
java.lang.Object
org.opentrafficsim.core.geometry.OtsLine3d
org.opentrafficsim.core.geometry.OtsShape
- All Implemented Interfaces:
Serializable
,Locatable
Copyright (c) 2013-2023 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See OpenTrafficSim License.
- Author:
- Alexander Verbraeck, Peter Knoppers
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.opentrafficsim.core.geometry.OtsLine3d
OtsLine3d.FractionalFallback, OtsLine3d.OffsetMethod
-
Field Summary
Fields inherited from class org.opentrafficsim.core.geometry.OtsLine3d
OFFSETMETHOD
-
Constructor Summary
ConstructorsConstructorDescriptionConstruct a new OtsShape (closed shape) from a Path2D.OtsShape
(List<OtsPoint3d> pointList) Construct a new OtsShape (closed shape) from a List<OtsPoint3d>.OtsShape
(org.locationtech.jts.geom.Coordinate[] coordinates) Construct a new OtsShape (closed shape) from an array of Coordinate.OtsShape
(org.locationtech.jts.geom.Geometry geometry) Construct a new OtsShape (closed shape) from a Geometry.OtsShape
(org.locationtech.jts.geom.LineString lineString) Construct a new OtsShape (closed shape) from a LineString.OtsShape
(OtsPoint3d... points) Construct a new OtsShape (closed shape). -
Method Summary
Modifier and TypeMethodDescriptionfinal boolean
contains
(Rectangle2D rectangle) Check if this OtsShape completely covers a rectangular region.final boolean
contains
(OtsPoint3d point) static OtsShape
createAndCleanOtsShape
(List<OtsPoint3d> pointList) Create an OtsLine3d, while cleaning repeating successive points.static OtsShape
createAndCleanOtsShape
(OtsPoint3d[] points) Create an OtsLine3d, while cleaning repeating successive points.final Path2D
getShape()
final boolean
intersects
(OtsShape otsShape) static void
Small test.final String
toString()
Methods inherited from class org.opentrafficsim.core.geometry.OtsLine3d
concatenate, concatenate, concatenate, createAndCleanOtsLine3d, createAndCleanOtsLine3d, equals, extract, extract, extractFractional, get, getBounds, getCentroid, getCoordinates, getEnvelope, getFirst, getLast, getLength, getLengthSI, getLineString, getLocation, getLocation, getLocationExtended, getLocationExtendedSI, getLocationFraction, getLocationFraction, getLocationFractionExtended, getLocationSI, getPoints, getProjectedRadius, getProjectedVertexRadius, getVertexFraction, hashCode, noiseFilteredLine, noiseFilterRamerDouglasPeucker, offsetLine, offsetLine, offsetLine, projectFractional, projectOrthogonal, reverse, size, toExcel, toPlot, truncate
-
Constructor Details
-
OtsShape
Construct a new OtsShape (closed shape).- Parameters:
points
- OtsPoint3d...; the array of points to construct this OtsLine3d from.- Throws:
OtsGeometryException
- when the provided points do not constitute a valid line (too few points or identical adjacent points)
-
OtsShape
Construct a new OtsShape (closed shape) from an array of Coordinate.- Parameters:
coordinates
- Coordinate[]; the array of coordinates to construct this OtsLine3d from- Throws:
OtsGeometryException
- when the provided points do not constitute a valid line (too few points or identical adjacent points)
-
OtsShape
Construct a new OtsShape (closed shape) from a LineString.- Parameters:
lineString
- LineString; the lineString to construct this OtsLine3d from.- Throws:
OtsGeometryException
- when the provided LineString does not constitute a valid line (too few points or identical adjacent points)
-
OtsShape
Construct a new OtsShape (closed shape) from a Geometry.- Parameters:
geometry
- Geometry; the geometry to construct this OtsLine3d from- Throws:
OtsGeometryException
- when the provided Geometry do not constitute a valid line (too few points or identical adjacent points)
-
OtsShape
Construct a new OtsShape (closed shape) from a List<OtsPoint3d>.- Parameters:
pointList
- List<OtsPoint3d>; the list of points to construct this OtsLine3d from.- Throws:
OtsGeometryException
- when the provided points do not constitute a valid line (too few points or identical adjacent points)
-
OtsShape
Construct a new OtsShape (closed shape) from a Path2D.- Parameters:
path
- Path2D; the Path2D to construct this OtsLine3d from.- Throws:
OtsGeometryException
- when the provided points do not constitute a valid line (too few points or identical adjacent points)
-
-
Method Details
-
getShape
- Returns:
- shape
-
contains
- Parameters:
point
- OtsPoint3d; the point to check if it is inside the shape- Returns:
- whether the point is inside the shape
-
contains
Check if this OtsShape completely covers a rectangular region.- Parameters:
rectangle
- Rectangle2D; the rectangular region- Returns:
- boolean; true if this OtsShape completely covers the region; false otherwise (or when the implementation of java.awt.geom.Path2D.contains found it prohibitively expensive to decide. Let us hope that this cannot happen with OtsShape objects. Peter has been unable to find out when this might happen.
-
intersects
- Parameters:
otsShape
- OtsShape; the shape to test the intersection with- Returns:
- whether the shapes intersect or whether one shape contains the other
-
createAndCleanOtsShape
Create an OtsLine3d, while cleaning repeating successive points.- Parameters:
points
- OtsPoint3d[]; the coordinates of the line as OtsPoint3d- Returns:
- the line
- Throws:
OtsGeometryException
- when number of points < 2
-
createAndCleanOtsShape
public static OtsShape createAndCleanOtsShape(List<OtsPoint3d> pointList) throws OtsGeometryException Create an OtsLine3d, while cleaning repeating successive points.- Parameters:
pointList
- List<OtsPoint3d>; list of the coordinates of the line as OtsPoint3d; any duplicate points in this list are removed (this method may modify the provided list)- Returns:
- OtsLine3d; the line
- Throws:
OtsGeometryException
- when number of non-equal points < 2
-
main
Small test.- Parameters:
args
- String[]; empty- Throws:
OtsGeometryException
- when construction fails
-
toString
-