Class OtsGeometryUtil

java.lang.Object
org.opentrafficsim.base.geometry.OtsGeometryUtil

public final class OtsGeometryUtil extends Object
Utility class for OTS geometry.

Copyright (c) 2013-2024 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, Wouter Schakel
  • Method Summary

    Modifier and Type
    Method
    Description
    static int
    getNumSegmentsForRadius(double maxSpatialError, org.djunits.value.vdouble.scalar.Angle angle, double r)
    Returns the number of segments to use for a given maximum spatial error, and radius.
    static org.djutils.draw.line.PolyLine2d
    offsetLine(org.djutils.draw.line.PolyLine2d line, double[] relativeFractions, double[] offsets)
    Create a line at linearly varying offset from this line.
    static org.djutils.draw.point.OrientedPoint2d
    offsetPoint(org.djutils.draw.point.OrientedPoint2d point, double offset)
    Returns a point on a line through the given point, perpendicular to the given direction, at the offset distance.
    static String
    printCoordinate(String prefix, org.djutils.draw.point.Point2d point)
    Print one Point2d on the console.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • printCoordinate

      public static String printCoordinate(String prefix, org.djutils.draw.point.Point2d point)
      Print one Point2d on the console.
      Parameters:
      prefix - text to put before the output
      point - the coordinate to print
      Returns:
      String
    • getNumSegmentsForRadius

      public static int getNumSegmentsForRadius(double maxSpatialError, org.djunits.value.vdouble.scalar.Angle angle, double r)
      Returns the number of segments to use for a given maximum spatial error, and radius.
      Parameters:
      maxSpatialError - maximum spatial error.
      angle - angle of arc at radius.
      r - critical radius (largest radius).
      Returns:
      number of segments to use for a given maximum spatial error, and radius.
    • offsetPoint

      public static org.djutils.draw.point.OrientedPoint2d offsetPoint(org.djutils.draw.point.OrientedPoint2d point, double offset)
      Returns a point on a line through the given point, perpendicular to the given direction, at the offset distance. A negative offset is towards the right hand side relative to the direction.
      Parameters:
      point - point.
      offset - offset, negative values are to the right.
      Returns:
      offset point.
    • offsetLine

      public static org.djutils.draw.line.PolyLine2d offsetLine(org.djutils.draw.line.PolyLine2d line, double[] relativeFractions, double[] offsets) throws OtsGeometryException
      Create a line at linearly varying offset from this line. The offset may change linearly from its initial value at the start of the reference line via a number of intermediate offsets at intermediate positions to its final offset value at the end of the reference line.
      Parameters:
      line - reference line.
      relativeFractions - positional fractions for which the offsets have to be generated
      offsets - offsets at the relative positions (positive value is Left, negative value is Right)
      Returns:
      the PolyLine2d of the line at multi-linearly changing offset of the reference line
      Throws:
      OtsGeometryException - when this method fails to create the offset line