Quantcast
Channel: Math.NET Numerics
Viewing all articles
Browse latest Browse all 971

New Post: (CubicSpline) Could I get value X from value Y?

$
0
0
I made a simple curve like this.
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 this
CubicSpline spline2 = CubicSpline.InterpolateNatural(py, px);
Testing with these code
Console.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?

Viewing all articles
Browse latest Browse all 971

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>