I made a simple curve like this.
Is there any function i could use?
double[] px = new double[] { 0.0, 5.0, 10.0 };
double[] py = new double[] { 0.0, 3.0, 10.0 };
CubicSpline spline1 = CubicSpline.InterpolateNatural(px, py);
axis-x is time, axis-y is value. and get value y coding double value = spline1.Interpolate(x);
But sometime i need to know how long the value will become specify value. And I create thisCubicSpline spline2 = CubicSpline.InterpolateNatural(py, px);
Testing with these codeConsole.WriteLine(spline2.Interpolate(spline1.Interpolate(0))); // output: 0
Console.WriteLine(spline2.Interpolate(spline1.Interpolate(5))); // output: 5
Console.WriteLine(spline2.Interpolate(spline1.Interpolate(10))); // output: 10
Console.WriteLine(spline2.Interpolate(spline1.Interpolate(2.0))); // output: 1.553190912
Console.WriteLine(spline2.Interpolate(spline1.Interpolate(3.0))); // output: 2.51721969371429
Its correct at Key point, others are incorrect.Is there any function i could use?