Package org.opentrafficsim.core.geometry
Class OTSShape
java.lang.Object
org.opentrafficsim.core.geometry.OTSLine3D
org.opentrafficsim.core.geometry.OTSShape
- All Implemented Interfaces:
java.io.Serializable
,Locatable
public class OTSShape extends OTSLine3D
Copyright (c) 2013-2019 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:
- Serialized Form
-
Nested Class Summary
Nested classes/interfaces inherited from class org.opentrafficsim.core.geometry.OTSLine3D
OTSLine3D.FractionalFallback, OTSLine3D.OffsetMethod
-
Field Summary
-
Constructor Summary
Constructors Constructor Description OTSShape(java.awt.geom.Path2D path)
Construct a new OTSShape (closed shape) from a Path2D.OTSShape(java.util.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 Type Method Description boolean
contains(java.awt.geom.Rectangle2D rectangle)
Check if this OTSShape completely covers a rectangular region.boolean
contains(OTSPoint3D point)
static OTSShape
createAndCleanOTSShape(java.util.List<OTSPoint3D> pointList)
Create an OTSLine3D, while cleaning repeating successive points.static OTSShape
createAndCleanOTSShape(OTSPoint3D[] points)
Create an OTSLine3D, while cleaning repeating successive points.java.awt.geom.Path2D
getShape()
boolean
intersects(OTSShape otsShape)
static void
main(java.lang.String[] args)
Small test.java.lang.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, getRadius, getVertexFraction, getVertexRadius, hashCode, noiseFilteredLine, noiseFilterRamerDouglasPeuker, 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
public final java.awt.geom.Path2D 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
public final boolean contains(java.awt.geom.Rectangle2D rectangle)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(java.util.List<OTSPoint3D> pointList) throws OTSGeometryExceptionCreate 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
public final java.lang.String toString()
-