public class OTSLine3D extends Object implements nl.tudelft.simulation.dsol.animation.Locatable, Serializable
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.
$LastChangedDate: 2015-07-16 10:20:53 +0200 (Thu, 16 Jul 2015) $, @version $Revision: 1124 $, by $Author: pknoppers $,
initial version Jul 22, 2015
| Modifier and Type | Class and Description |
|---|---|
static class |
OTSLine3D.FractionalFallback
Fallback method for when fractional projection fails as the point is beyond the line or from numerical limitations.
|
static class |
OTSLine3D.OffsetMethod
Which offsetLine method to use...
|
| Modifier and Type | Field and Description |
|---|---|
static OTSLine3D.OffsetMethod |
OFFSETMETHOD
Which offset line method to use...
|
| Constructor and Description |
|---|
OTSLine3D(org.locationtech.jts.geom.Coordinate[] coordinates)
Construct a new OTSLine3D from an array of Coordinate.
|
OTSLine3D(org.locationtech.jts.geom.Geometry geometry)
Construct a new OTSLine3D from a Geometry.
|
OTSLine3D(org.locationtech.jts.geom.LineString lineString)
Construct a new OTSLine3D from a LineString.
|
OTSLine3D(List<OTSPoint3D> pointList)
Construct a new OTSLine3D from a List<OTSPoint3D>.
|
OTSLine3D(OTSPoint3D... points)
Construct a new OTSLine3D.
|
OTSLine3D(Path2D path)
Construct a new OTSShape (closed shape) from a Path2D.
|
| Modifier and Type | Method and Description |
|---|---|
static OTSLine3D |
concatenate(double toleranceSI,
OTSLine3D... lines)
Concatenate several OTSLine3D instances.
|
static OTSLine3D |
concatenate(double toleranceSI,
OTSLine3D line1,
OTSLine3D line2)
Concatenate two OTSLine3D instances.
|
static OTSLine3D |
concatenate(OTSLine3D... lines)
Concatenate several OTSLine3D instances.
|
static OTSLine3D |
createAndCleanOTSLine3D(List<OTSPoint3D> pointList)
Create an OTSLine3D, while cleaning repeating successive points.
|
static OTSLine3D |
createAndCleanOTSLine3D(OTSPoint3D... points)
Create an OTSLine3D, while cleaning repeating successive points.
|
boolean |
equals(Object obj) |
OTSLine3D |
extract(double start,
double end)
Create a new OTSLine3D that covers a sub-section of this OTSLine3D.
|
OTSLine3D |
extract(Length start,
Length end)
Create a new OTSLine3D that covers a sub-section of this OTSLine3D.
|
OTSLine3D |
extractFractional(double start,
double end)
Construct a new OTSLine3D covering the indicated fraction of this OTSLine3D.
|
OTSPoint3D |
get(int i)
Return one point of this OTSLine3D.
|
javax.media.j3d.Bounds |
getBounds() |
OTSPoint3D |
getCentroid()
Retrieve the centroid of this OTSLine3D.
|
org.locationtech.jts.geom.Coordinate[] |
getCoordinates()
Construct a Coordinate array and fill it with the points of this OTSLine3D.
|
org.locationtech.jts.geom.Envelope |
getEnvelope()
Get the bounding rectangle of this OTSLine3D.
|
OTSPoint3D |
getFirst()
Return the first point of this OTSLine3D.
|
OTSPoint3D |
getLast()
Return the last point of this OTSLine3D.
|
Length |
getLength()
Return the length of this OTSLine3D in meters.
|
double |
getLengthSI()
Return the length of this OTSLine3D as a double value in SI units.
|
org.locationtech.jts.geom.LineString |
getLineString()
Construct a LineString from this OTSLine3D.
|
nl.tudelft.simulation.language.d3.DirectedPoint |
getLocation() |
nl.tudelft.simulation.language.d3.DirectedPoint |
getLocation(Length position)
Get the location at a position on the line, with its direction.
|
nl.tudelft.simulation.language.d3.DirectedPoint |
getLocationExtended(Length position)
Get the location at a position on the line, with its direction.
|
nl.tudelft.simulation.language.d3.DirectedPoint |
getLocationExtendedSI(double positionSI)
Get the location at a position on the line, with its direction.
|
nl.tudelft.simulation.language.d3.DirectedPoint |
getLocationFraction(double fraction)
Get the location at a fraction of the line, with its direction.
|
nl.tudelft.simulation.language.d3.DirectedPoint |
getLocationFraction(double fraction,
double tolerance)
Get the location at a fraction of the line, with its direction.
|
nl.tudelft.simulation.language.d3.DirectedPoint |
getLocationFractionExtended(double fraction)
Get the location at a fraction of the line (or outside the line), with its direction.
|
nl.tudelft.simulation.language.d3.DirectedPoint |
getLocationSI(double positionSI)
Get the location at a position on the line, with its direction.
|
OTSPoint3D[] |
getPoints()
Return an array of OTSPoint3D that represents this OTSLine3D.
|
Length |
getRadius(double fraction)
Returns the directional radius of the line at a given fraction.
|
double |
getVertexFraction(int index)
Returns the length fraction at the vertex.
|
Length |
getVertexRadius(int index)
Calculates the directional radius at a vertex.
|
int |
hashCode() |
static void |
main(String[] args)
Test/development code for the fractional helper stuff.
|
OTSLine3D |
noiseFilteredLine(double noiseLevel)
Construct a line that is equal to this line except for segments that are shorter than the noiseLevel.
|
OTSLine3D |
noiseFilterRamerDouglasPeuker(double epsilon,
boolean useHorizontalDistance)
Clean up a list of points that describe a polyLine by removing points that lie within epsilon distance of a more
straightened version of the line.
|
OTSLine3D |
offsetLine(double offset)
Construct parallel line.
TODO Let the Z-component of the result follow the Z-values of the reference line. |
OTSLine3D |
offsetLine(double[] relativeFractions,
double[] offsets)
Create a line at linearly varying offset from this line.
|
OTSLine3D |
offsetLine(double offsetAtStart,
double offsetAtEnd)
Create a line at linearly varying offset from this line.
|
double |
projectFractional(Direction start,
Direction end,
double x,
double y,
OTSLine3D.FractionalFallback fallback)
Returns the fractional projection of a point to a line.
|
double |
projectOrthogonal(double x,
double y)
Returns the fractional position along this line of the orthogonal projection of point (x, y) on this line.
|
OTSLine3D |
reverse()
Construct a new OTSLine3D with all points of this OTSLine3D in reverse order.
|
int |
size()
Return the number of points in this OTSLine3D.
|
String |
toExcel()
Convert the 2D projection of this OTSLine3D to something that MS-Excel can plot.
|
String |
toPlot()
Convert the 2D projection of this OTSLine3D to Peter's plot format.
|
String |
toString() |
OTSLine3D |
truncate(double lengthSI)
Truncate a line at the given length (less than the length of the line, and larger than zero) and return a new line.
|
public static final OTSLine3D.OffsetMethod OFFSETMETHOD
public OTSLine3D(OTSPoint3D... points) throws OTSGeometryException
points - OTSPoint3D...; the array of points to construct this OTSLine3D from.OTSGeometryException - when the provided points do not constitute a valid line (too few points or identical
adjacent points)public OTSLine3D(org.locationtech.jts.geom.Coordinate[] coordinates)
throws OTSGeometryException
coordinates - Coordinate[]; the array of coordinates to construct this OTSLine3D fromOTSGeometryException - when the provided points do not constitute a valid line (too few points or identical
adjacent points)public OTSLine3D(org.locationtech.jts.geom.LineString lineString)
throws OTSGeometryException
lineString - LineString; the lineString to construct this OTSLine3D from.OTSGeometryException - when the provided LineString does not constitute a valid line (too few points or identical
adjacent points)public OTSLine3D(org.locationtech.jts.geom.Geometry geometry)
throws OTSGeometryException
geometry - Geometry; the geometry to construct this OTSLine3D fromOTSGeometryException - when the provided Geometry do not constitute a valid line (too few points or identical
adjacent points)public OTSLine3D(List<OTSPoint3D> pointList) throws OTSGeometryException
pointList - List<OTSPoint3D>; the list of points to construct this OTSLine3D from.OTSGeometryException - when the provided points do not constitute a valid line (too few points or identical
adjacent points)public OTSLine3D(Path2D path) throws OTSGeometryException
path - Path2D; the Path2D to construct this OTSLine3D from.OTSGeometryException - when the provided points do not constitute a valid line (too few points or identical
adjacent points)public final OTSLine3D offsetLine(double offset)
offset - double; offset distance from the reference line; positive is LEFT, negative is RIGHTpublic final OTSLine3D noiseFilteredLine(double noiseLevel)
noiseLevel - double; the minimum segment length that is not removedpublic final OTSLine3D noiseFilterRamerDouglasPeuker(double epsilon, boolean useHorizontalDistance)
epsilon - double; maximal deviationuseHorizontalDistance - boolean; if true; the horizontal distance is used; if false; the 3D distance is usedpublic final OTSLine3D offsetLine(double offsetAtStart, double offsetAtEnd) throws OTSGeometryException
offsetAtStart - double; offset at the start of the reference line (positive value is Left, negative value is Right)offsetAtEnd - double; offset at the end of the reference line (positive value is Left, negative value is Right)OTSGeometryException - when this method fails to create the offset linepublic final OTSLine3D offsetLine(double[] relativeFractions, double[] offsets) throws OTSGeometryException
relativeFractions - double[]; positional fractions for which the offsets have to be generatedoffsets - double[]; offsets at the relative positions (positive value is Left, negative value is Right)OTSGeometryException - when this method fails to create the offset linepublic static OTSLine3D concatenate(OTSLine3D... lines) throws OTSGeometryException
lines - OTSLine3D...; OTSLine3D... one or more OTSLine3D. The last point of the first
<strong>must</strong> match the first of the second, etc.OTSGeometryException - if zero lines are given, or when there is a gap between consecutive linespublic static OTSLine3D concatenate(double toleranceSI, OTSLine3D line1, OTSLine3D line2) throws OTSGeometryException
toleranceSI - double; the tolerance between the end point of a line and the first point of the next lineline1 - OTSLine3D; first lineline2 - OTSLine3D; second lineOTSGeometryException - if zero lines are given, or when there is a gap between consecutive linespublic static OTSLine3D concatenate(double toleranceSI, OTSLine3D... lines) throws OTSGeometryException
toleranceSI - double; the tolerance between the end point of a line and the first point of the next linelines - OTSLine3D...; OTSLine3D... one or more OTSLine3D. The last point of the first
<strong>must</strong> match the first of the second, etc.OTSGeometryException - if zero lines are given, or when there is a gap between consecutive linespublic final OTSLine3D reverse()
public final OTSLine3D extractFractional(double start, double end) throws OTSGeometryException
start - double; starting point, valid range [0..end)end - double; ending point, valid range (start..1]OTSGeometryException - when start >= end, or start < 0, or end > 1public final OTSLine3D extract(Length start, Length end) throws OTSGeometryException
start - Length; the length along this OTSLine3D where the sub-section starts, valid range [0..end)end - Length; length along this OTSLine3D where the sub-section ends, valid range
(start..length (length is the length of this OTSLine3D)OTSGeometryException - when start >= end, or start < 0, or end > lengthpublic final OTSLine3D extract(double start, double end) throws OTSGeometryException
start - double; length along this OTSLine3D where the sub-section starts, valid range [0..end)end - double; length along this OTSLine3D where the sub-section ends, valid range
(start..length (length is the length of this OTSLine3D)OTSGeometryException - when start >= end, or start < 0, or end > lengthpublic static OTSLine3D createAndCleanOTSLine3D(OTSPoint3D... points) throws OTSGeometryException
points - OTSPoint3D...; the coordinates of the line as OTSPoint3DOTSGeometryException - when number of points < 2public static OTSLine3D createAndCleanOTSLine3D(List<OTSPoint3D> pointList) throws OTSGeometryException
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)OTSGeometryException - when number of non-equal points < 2public final org.locationtech.jts.geom.Coordinate[] getCoordinates()
public final org.locationtech.jts.geom.LineString getLineString()
public final int size()
public final OTSPoint3D getFirst()
public final OTSPoint3D getLast()
public final OTSPoint3D get(int i) throws OTSGeometryException
i - int; the index of the point to retrieveOTSGeometryException - when i < 0 or i > the number of pointspublic final double getLengthSI()
public final Length getLength()
public final OTSPoint3D[] getPoints()
public final nl.tudelft.simulation.language.d3.DirectedPoint getLocationExtended(Length position)
position - Length; the position on the line for which to calculate the point on, before, of after the linepublic final nl.tudelft.simulation.language.d3.DirectedPoint getLocationExtendedSI(double positionSI)
positionSI - double; the position on the line for which to calculate the point on, before, of after the line, in SI
unitspublic final nl.tudelft.simulation.language.d3.DirectedPoint getLocationFraction(double fraction)
throws OTSGeometryException
fraction - double; the fraction for which to calculate the point on the lineOTSGeometryException - when fraction less than 0.0 or more than 1.0.public final nl.tudelft.simulation.language.d3.DirectedPoint getLocationFraction(double fraction,
double tolerance)
throws OTSGeometryException
fraction - double; the fraction for which to calculate the point on the linetolerance - double; the delta from 0.0 and 1.0 that will be forgivenOTSGeometryException - when fraction less than 0.0 or more than 1.0.public final nl.tudelft.simulation.language.d3.DirectedPoint getLocationFractionExtended(double fraction)
fraction - double; the fraction for which to calculate the point on the linepublic final nl.tudelft.simulation.language.d3.DirectedPoint getLocation(Length position) throws OTSGeometryException
position - Length; the position on the line for which to calculate the point on the lineOTSGeometryException - when position less than 0.0 or more than line length.public final nl.tudelft.simulation.language.d3.DirectedPoint getLocationSI(double positionSI)
throws OTSGeometryException
positionSI - double; the position on the line for which to calculate the point on the lineOTSGeometryException - when position less than 0.0 or more than line length.public final OTSLine3D truncate(double lengthSI) throws OTSGeometryException
lengthSI - double; the location where to truncate the lineOTSGeometryException - when position less than 0.0 or more than line length.public final double projectOrthogonal(double x,
double y)
x - double; x-coordinate of point to projecty - double; y-coordinate of point to projectpublic final double projectFractional(Direction start, Direction end, double x, double y, OTSLine3D.FractionalFallback fallback)
____________________________ G .
. | | . .
. | . . . . helper lines | . .
. | _.._.._ projection line | I. .
. |____________________________| _.'._ . L
F. _.' . '-. .
.. B _.' . '-.
. . _.\ . . D
. . _.' : . .
J . . _.' \ . .
.. . _.' : . M
. . ..-' \ .
. . /H. A .
. . / . .
C _________/ . .
. . . .
K . . . .
. . . .
. . . . N
. . . .
. . . .
. . . .
. . . .
. .E
. .
. .
. .
Fractional projection may fail in three cases.
orthoFallback = true, or NaN if orthoFallback = false.start - Direction; direction in first pointend - Direction; direction in last pointx - double; x-coordinate of point to projecty - double; y-coordinate of point to projectfallback - FractionalFallback; fallback method for when fractional projection failspublic Length getRadius(double fraction) throws OTSGeometryException
fraction - double; fraction along the line, between 0.0 and 1.0 (both inclusive)OTSGeometryException - fraction out of boundspublic Length getVertexRadius(int index) throws OTSGeometryException
index - int; index of the vertex in range [1 ... size() - 2]OTSGeometryException - if the index is out of boundspublic double getVertexFraction(int index)
throws OTSGeometryException
index - int; index of vertex [0 ... size() - 1]OTSGeometryException - if the index is out of boundspublic final OTSPoint3D getCentroid()
public final org.locationtech.jts.geom.Envelope getEnvelope()
public nl.tudelft.simulation.language.d3.DirectedPoint getLocation()
getLocation in interface nl.tudelft.simulation.dsol.animation.Locatablepublic javax.media.j3d.Bounds getBounds()
getBounds in interface nl.tudelft.simulation.dsol.animation.Locatablepublic final String toExcel()
public final String toPlot()
public static void main(String[] args) throws OTSGeometryException
args - String[]; the command line arguments (not used)OTSGeometryException - in case of errorCopyright © 2014–2019 Delft University of Technology. All rights reserved.