Class RadiusCalculator2d

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

public final class RadiusCalculator2d extends Object
Computes signed curvature radii for an OtsLine2d using the fractional projection helpers. Positive radius means left-hand curvature in the design-line direction.

Rules:

  • Radius at a vertex is the distance from the midpoint of the shorter adjacent edge along the perpendicular line to the intersection with the local angle-splitting ray (from helper).
  • Projected radius at a fraction equals the minimum (by absolute value) of the radii at the adjacent vertices.
  • If the polyline is straight throughout, returns NaN.

Copyright (c) 2026-2026 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See OpenTrafficSim License.

Author:
Wouter Schakel
  • Constructor Details

    • RadiusCalculator2d

      public RadiusCalculator2d(OtsLine2d line, FractionalProjectionHelper fracHelper)
      Construct a radius calculator for a line.
      Parameters:
      line - the line
      fracHelper - the fractional projection helper; if null, a new one is created
  • Method Details

    • radiusAtFraction

      public Optional<org.djunits.value.vdouble.scalar.Length> radiusAtFraction(double fraction) throws IllegalArgumentException
      Returns the projected directional radius at a fraction in [0, 1]. Uses the minimum-by-absolute-value of the two adjacent vertex radii. If no curvature exists or degenerate, returns NaN.
      Parameters:
      fraction - fraction along the line, in [0, 1]
      Returns:
      signed radius at the fraction, empty if not defined
      Throws:
      IllegalArgumentException - if fraction out of bounds
    • radiusAtVertex

      public Optional<org.djunits.value.vdouble.scalar.Length> radiusAtVertex(int index) throws IndexOutOfBoundsException
      Returns the directional radius at an internal vertex (index in [1 .. size() - 2]). If the geometry is degenerate or helper cannot construct a valid intersection, returns NaN.
      Parameters:
      index - vertex index
      Returns:
      signed radius at the vertex (NaN if undefined)
      Throws:
      IndexOutOfBoundsException - if index not in [1 .. size() - 2]