Class OTSBufferingJTS

java.lang.Object
org.opentrafficsim.core.geometry.OTSBufferingJTS

public final class OTSBufferingJTS
extends java.lang.Object

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

Author:
Alexander Verbraeck, Peter Knoppers
  • Method Details

    • distanceLineSegmentToPoint

      public static double distanceLineSegmentToPoint​(OTSPoint3D lineP1, OTSPoint3D lineP2, OTSPoint3D point)
      Compute the distance of a line segment to a point. If the the projected points lies outside the line segment, the nearest end point of the line segment is returned. Otherwise the point return lies between the end points of the line segment.
      Adapted from example code provided by Paul Bourke.
      Parameters:
      lineP1 - OTSPoint3D; start of line segment
      lineP2 - OTSPoint3D; end of line segment
      point - OTSPoint3D; Point to project onto the line segment
      Returns:
      double; the distance of the projected point or one of the end points of the line segment to the point
    • closestPointOnSegmentToPoint

      public static OTSPoint3D closestPointOnSegmentToPoint​(OTSPoint3D lineP1, OTSPoint3D lineP2, OTSPoint3D point)
      Project a point on a line (2D). If the the projected points lies outside the line segment, the nearest end point of the line segment is returned. Otherwise the point return lies between the end points of the line segment.
      Adapted from example code provided by Paul Bourke.
      Parameters:
      lineP1 - OTSPoint3D; start of line segment
      lineP2 - OTSPoint3D; end of line segment
      point - OTSPoint3D; Point to project onto the line segment
      Returns:
      Point2D.Double; either lineP1, or lineP2 or a new OTSPoint3D that lies somewhere in between those two
    • offsetLine

      public static OTSLine3D offsetLine​(OTSLine3D referenceLine, double offset)
      Construct parallel line without.
      Parameters:
      referenceLine - OTSLine3D; the reference line
      offset - double; offset distance from the reference line; positive is LEFT, negative is RIGHT
      Returns:
      OTSLine3D; the line that has the specified offset from the reference line
    • offsetGeometryOLD

      public static OTSLine3D offsetGeometryOLD​(OTSLine3D referenceLine, double offset) throws OTSGeometryException
      Generate a Geometry that has a fixed offset from a reference Geometry.
      Parameters:
      referenceLine - OTSLine3D; the reference line
      offset - double; offset distance from the reference line; positive is LEFT, negative is RIGHT
      Returns:
      OTSLine3D; the line that has the specified offset from the reference line
      Throws:
      OTSGeometryException - on failure
    • offsetLine

      public static OTSLine3D offsetLine​(OTSLine3D referenceLine, double offsetAtStart, double offsetAtEnd) throws OTSGeometryException
      Create a line at linearly varying offset from a reference line. The offset may change linearly from its initial value at the start of the reference line to its final offset value at the end of the reference line.
      Parameters:
      referenceLine - OTSLine3D; the Geometry of the reference line
      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)
      Returns:
      Geometry; the Geometry of the line at linearly changing offset of the reference line
      Throws:
      OTSGeometryException - when this method fails to create the offset line
    • main

      public static void main​(java.lang.String[] args) throws NetworkException, OTSGeometryException
      Parameters:
      args - String[]; args
      Throws:
      NetworkException - on error
      OTSGeometryException - on error