Package org.opentrafficsim.core.geometry
Class FractionalLengthData
java.lang.Object
org.opentrafficsim.core.geometry.FractionalLengthData
- All Implemented Interfaces:
Function<Double,
,Double> 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 Summary
ConstructorsConstructorDescriptionFractionalLengthData
(double... data) Create FractionalLengthData.FractionalLengthData
(Map<Double, Double> data) Create FractionalLengthData. -
Method Summary
Modifier and TypeMethodDescriptionReturns the data at given fractional length.double
getDerivative
(double fractionalLength) Returns the derivative of the data with respect to fractional length.org.djutils.immutablecollections.ImmutableNavigableSet<Double>
Returns the fractional lengths in the underlying data.double[]
getKnots()
Returns fractional lengths in array form, including 0.0 and 1.0.org.djutils.immutablecollections.ImmutableSet<Double>
Returns the values in the underlying data.double[]
Returns fractional lengths in array form, including values at 0.0 and 1.0.static FractionalLengthData
of
(double... data) Create FractionalLengthData.int
size()
Returns the number of data points.
-
Constructor Details
-
FractionalLengthData
Create FractionalLengthData.- Parameters:
data
- fractional length - value pairs. Fractional lengths do not need to be in order.- 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].
-
FractionalLengthData
Create FractionalLengthData.- Parameters:
data
- fractional length - value pairs. Fractional lengths do not need to be in order.- Throws:
IllegalArgumentException
- when the input data is null or empty.IllegalArgumentException
- when a fractional value is not in the range [0 ... 1].
-
-
Method Details
-
apply
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. -
getDerivative
public double getDerivative(double fractionalLength) Returns the derivative of the data with respect to fractional length.- Specified by:
getDerivative
in interfaceContinuousLine.ContinuousDoubleFunction
- Parameters:
fractionalLength
- fractional length, may be outside range [0 ... 1].- Returns:
- derivative of the data with respect to fractional length.
-
getFractionalLengths
Returns the fractional lengths in the underlying data.- Returns:
- fractional lengths in the underlying data.
-
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 interfaceContinuousLine.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
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].
-