net.simplace.client.simulation.lap.util.helper.DataTransformHelper
Methods for interpolating and integrating piecewise linear functions
Functions are given by arrays of x and y values.
The class provides methods for
- interpolating a value
- calculating the integral of the function
- rescales the function to have area of 1
public class DataTransformHelper {
// Public Constructors
public DataTransformHelper();
// Class Methods public static double[]
NormalizeCurve(double[] xs, double[] ys);
Normalizes the y-values of an x-y-curve so that the area under the curve is 1.
- xs the x values
- ys the y values
returns new y values
public static double[]
NormalizeCurve(double[] xs, double[] ys, double area);
Normalizes the y-values of an x-y-curve so that the area under the curve has given value.
- xs the x values
- ys the y values
- area the target area under the new curve
returns new y values
public static double[]
RescaleValues(double min, double max, double[] vs);
Rescales an array of values proportionally from new mininimum to new maximum.
- min minimum value of the new array
- max maximum value of the new array
- vs values
returns the rescaled values
public static double
Interpolate(double x, double[] xs, double[] ys, boolean
extrapolate);
Linear interpolation of a piecewise linear curve
- x position where the value should be interpolated
- xs array of x values
- ys array of corresponding y values
- extrapolate if true then first or last y value is returned if x is out of range, if false 0 is returned
returns the interpolated value
public static double
Integral(double[] xs, double[] ys);
Calculates the area under the curve defined by arrays of x and y values
- xs the x values defining the curve
- ys the y values defining the curve
returns the area
public static double
IntegralFromTo(double t1, double t2, double[] xs,
double[] ys);
Calculates the area under the curve defined by arrays of x and y values between the points t1 and t2
- t1 lower boundary of integration interval
- t2 upper boundary of integration interval
- xs the x values defining the curve
- ys the y values defining the curve
returns the area
}