Class Arc2d

java.lang.Object
org.djutils.draw.curve.Arc2d
All Implemented Interfaces:
Curvature, Curve<DirectedPoint2d,Double,Point2d,Flattener2d,PolyLine2d>, Curve2d, Flattener.FlattableCurve<Point2d,Double>, OffsetCurve2d

public class Arc2d extends Object implements Curvature, Curve2d, OffsetCurve2d
Continuous definition of an arc in 2d.

Copyright (c) 2023-2025 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
  • Constructor Details

    • Arc2d

      public Arc2d(DirectedPoint2d startPoint, double radius, boolean left, double angle)
      Define arc by starting point, radius, curve direction, and angle.
      Parameters:
      startPoint - starting point
      radius - radius (must be positive)
      left - truefor left turning curve; false for for right turning curve
      angle - angle of arc (must be positive)
  • Method Details

    • getStartCurvature

      public double getStartCurvature()
      Description copied from interface: Curvature
      Start curvature of this Curve2d..
      Specified by:
      getStartCurvature in interface Curvature
      Returns:
      start curvature of this Curve2d.
    • getEndCurvature

      public double getEndCurvature()
      Description copied from interface: Curvature
      End curvature of this Curve2d..
      Specified by:
      getEndCurvature in interface Curvature
      Returns:
      end curvature of this Curve2d
    • getStartRadius

      public double getStartRadius()
      Description copied from interface: Curvature
      Start radius of this Curve2d..
      Specified by:
      getStartRadius in interface Curvature
      Returns:
      start radius of this Curve2d
    • getEndRadius

      public double getEndRadius()
      Description copied from interface: Curvature
      End radius of this Curve2d..
      Specified by:
      getEndRadius in interface Curvature
      Returns:
      end radius of this Curve2d
    • isLeft

      public boolean isLeft()
      Does this arc bend to the left?
      Returns:
      true if this Arc bends to the left; false if this Arc bends to the right
    • getAngle

      public double getAngle()
      Retrieve the total change of direction on this Arc.
      Returns:
      the total change of direction on this Arc
    • getPoint

      public Point2d getPoint(double fraction)
      Description copied from interface: Curve
      Returns the point at the given fraction of this Curve. The fraction may represent any parameter, such as t in a Bézier curve, s in a Clothoid, or simply the fraction of length.
      Specified by:
      getPoint in interface Curve<DirectedPoint2d,Double,Point2d,Flattener2d,PolyLine2d>
      Specified by:
      getPoint in interface Flattener.FlattableCurve<Point2d,Double>
      Parameters:
      fraction - the fraction
      Returns:
      the point at the given fraction
    • getPoint

      public Point2d getPoint(double fraction, ContinuousPiecewiseLinearFunction of)
      Description copied from interface: OffsetCurve2d
      Returns the point at the given fraction. The fraction may represent any parameter, such as t in a Bézier curve, s in a Clothoid, or simply the fraction of length.
      Specified by:
      getPoint in interface OffsetCurve2d
      Parameters:
      fraction - the fraction
      of - provides fraction-dependent lateral offset to the point
      Returns:
      the point at the given fraction
    • getDirection

      public Double getDirection(double fraction)
      Description copied from interface: Curve
      Returns the direction at the given fraction. The fraction may represent any parameter, such as t in a Bézier curve, s in a Clothoid, or simply the fraction of length. The default implementation performs a numerical approach by looking at the direction between the points at fraction, and a point 1e-6 away.
      Specified by:
      getDirection in interface Curve<DirectedPoint2d,Double,Point2d,Flattener2d,PolyLine2d>
      Specified by:
      getDirection in interface Curve2d
      Specified by:
      getDirection in interface Flattener.FlattableCurve<Point2d,Double>
      Parameters:
      fraction - the fraction
      Returns:
      the direction at the given fraction
    • getDirection

      public double getDirection(double fraction, ContinuousPiecewiseLinearFunction of)
      Description copied from interface: OffsetCurve2d
      Returns the direction at the given fraction. The fraction may represent any parameter, such as t in a Bézier curve, s in a Clothoid, or simply the fraction of length. The default implementation performs a numerical approach by looking at the direction between the points at fraction, and a point 1e-6 away.
      Specified by:
      getDirection in interface OffsetCurve2d
      Parameters:
      fraction - the fraction
      of - provides fraction-dependent lateral offset to the curve
      Returns:
      the direction at the given fraction
    • toPolyLine

      public PolyLine2d toPolyLine(Flattener2d flattener)
      Description copied from interface: Curve
      Flatten a Curve into a PolyLine. Implementations should use the flattener when relevant and possible.
      Specified by:
      toPolyLine in interface Curve<DirectedPoint2d,Double,Point2d,Flattener2d,PolyLine2d>
      Parameters:
      flattener - the flattener
      Returns:
      approximation of this Curve as a PolyLine
    • toPolyLine

      public PolyLine2d toPolyLine(OffsetFlattener2d flattener, ContinuousPiecewiseLinearFunction offsets)
      Description copied from interface: OffsetCurve2d
      Flatten a Curve2d while offsetting with the provided continuous offset into a PolyLine2d. Implementations should use the flattener when relevant and possible.
      Specified by:
      toPolyLine in interface OffsetCurve2d
      Parameters:
      flattener - OffsetFlattener
      offsets - offset data
      Returns:
      approximation of this curve2d with offset as a PolyLine2d
    • getLength

      public double getLength()
      Description copied from interface: Curve
      Return the length of this Curve.
      Specified by:
      getLength in interface Curve<DirectedPoint2d,Double,Point2d,Flattener2d,PolyLine2d>
      Returns:
      length of this Curve
    • toString

      public String toString()
      Overrides:
      toString in class Object