Package org.opentrafficsim.core.geometry
Class FractionalLengthData
java.lang.Object
org.opentrafficsim.core.geometry.FractionalLengthData
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
ConstructorDescriptionFractionalLengthData
(double... data) Create FractionalLengthData.FractionalLengthData
(Map<Double, Double> data) Create FractionalLengthData. -
Method Summary
Modifier and TypeMethodDescriptiondouble
get
(double fractionalLength) Returns 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[]
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
- double...; 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
- Map<Double, Double>; 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
-
get
public double get(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.- Parameters:
fractionalLength
- double; fractional length, may be outside range [0 ... 1].- Returns:
- double; interpolated or extended value.
-
getDerivative
public double getDerivative(double fractionalLength) Returns the derivative of the data with respect to fractional length.- Parameters:
fractionalLength
- double; fractional length, may be outside range [0 ... 1].- Returns:
- double; derivative of the data with respect to fractional length.
-
getFractionalLengths
Returns the fractional lengths in the underlying data.- Returns:
- ImmutableNavigableSet<Double>; fractional lengths in the underlying data.
-
getValues
Returns the values in the underlying data.- Returns:
- ImmutableSet<Double>; values in the underlying data.
-
getFractionalLengthsAsArray
public double[] getFractionalLengthsAsArray()Returns fractional lengths in array form, including 0.0 and 1.0.- Returns:
- double[]; fractional lengths.
-
getValuesAsArray
public double[] getValuesAsArray()Returns fractional lengths in array form, including values at 0.0 and 1.0.- Returns:
- double[]; fractional lengths.
-
size
public int size()Returns the number of data points.- Returns:
- int; number of data points.
-
of
Create FractionalLengthData.- Parameters:
data
- double...; fractional length - value pairs. Fractional lengths do not need to be in order.- Returns:
- FractionalLengthData; 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].
-