Class FractionalLengthData

java.lang.Object
org.opentrafficsim.core.geometry.FractionalLengthData
All Implemented Interfaces:
Function<Double,Double>, ContinuousLine.ContinuousDoubleFunction

public class FractionalLengthData extends Object implements ContinuousLine.ContinuousDoubleFunction
Container for fractional length data.

Copyright (c) 2023-2024 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

  • Method Details

    • apply

      public Double apply(Double fractionalLength)
      Returns the data at given fractional length. If only data beyond the fractional length is available, the first available value is returned. If only data before the fractional length is available, the last available value is returned. Otherwise data is linearly interpolated.
      Specified by:
      apply in interface Function<Double,Double>
      Parameters:
      fractionalLength - fractional length, may be outside range [0 ... 1].
      Returns:
      interpolated or extended value.
    • getDerivative

      public double getDerivative(double fractionalLength)
      Returns the derivative of the data with respect to fractional length.
      Specified by:
      getDerivative in interface ContinuousLine.ContinuousDoubleFunction
      Parameters:
      fractionalLength - fractional length, may be outside range [0 ... 1].
      Returns:
      derivative of the data with respect to fractional length.
    • getFractionalLengths

      public org.djutils.immutablecollections.ImmutableNavigableSet<Double> getFractionalLengths()
      Returns the fractional lengths in the underlying data.
      Returns:
      fractional lengths in the underlying data.
    • getValues

      public org.djutils.immutablecollections.ImmutableSet<Double> getValues()
      Returns the values in the underlying data.
      Returns:
      values in the underlying data.
    • getKnots

      public double[] getKnots()
      Returns fractional lengths in array form, including 0.0 and 1.0.
      Specified by:
      getKnots in interface ContinuousLine.ContinuousDoubleFunction
      Returns:
      fractional lengths.
    • getValuesAsArray

      public double[] getValuesAsArray()
      Returns fractional lengths in array form, including values at 0.0 and 1.0.
      Returns:
      fractional lengths.
    • size

      public int size()
      Returns the number of data points.
      Returns:
      number of data points.
    • of

      public static FractionalLengthData of(double... data) throws IllegalArgumentException
      Create FractionalLengthData.
      Parameters:
      data - fractional length - value pairs. Fractional lengths do not need to be in order.
      Returns:
      fractional length data.
      Throws:
      IllegalArgumentException - when the number of input values is not even or 0.
      IllegalArgumentException - when a fractional value is not in the range [0 ... 1].