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-2020 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
$LastChangedDate: 2015-07-24 02:58:59 +0200 (Fri, 24 Jul 2015) $, @version $Revision: 1147 $, by $Author: averbraeck $, initial version Mar 31, 2016
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
-
Fields inherited from class org.opentrafficsim.core.geometry.OTSLine3D
OFFSETMETHOD
-
-
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
All Methods Static Methods Instance Methods Concrete Methods 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, getProjectedRadius, getProjectedVertexRadius, getVertexFraction, hashCode, noiseFilteredLine, noiseFilterRamerDouglasPeucker, offsetLine, offsetLine, offsetLine, projectFractional, projectOrthogonal, reverse, size, toExcel, toPlot, truncate
-
-
-
-
Constructor Detail
-
OTSShape
public OTSShape(OTSPoint3D... points) throws OTSGeometryException
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
public OTSShape(org.locationtech.jts.geom.Coordinate[] coordinates) throws OTSGeometryException
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
public OTSShape(org.locationtech.jts.geom.LineString lineString) throws OTSGeometryException
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
public OTSShape(org.locationtech.jts.geom.Geometry geometry) throws OTSGeometryException
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
public OTSShape(java.util.List<OTSPoint3D> pointList) throws OTSGeometryException
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
public OTSShape(java.awt.geom.Path2D path) throws OTSGeometryException
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 Detail
-
getShape
public final java.awt.geom.Path2D getShape()
- Returns:
- shape
-
contains
public final boolean contains(OTSPoint3D point)
- 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
public final boolean intersects(OTSShape otsShape)
- Parameters:
otsShape
- OTSShape; the shape to test the intersection with- Returns:
- whether the shapes intersect or whether one shape contains the other
-
createAndCleanOTSShape
public static OTSShape createAndCleanOTSShape(OTSPoint3D[] points) throws OTSGeometryException
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 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
public static void main(java.lang.String[] args) throws OTSGeometryException
Small test.- Parameters:
args
- String[]; empty- Throws:
OTSGeometryException
- when construction fails
-
-