AVEbrahimi
AVEbrahimi

Reputation: 19154

C# Spline Interpolation for interpolating a key between array of points

I need an interpolation function for interpolating a point:

var times = new List<double>();
var offsets = new List<double>();
..
..
..//I fill times and offsets arrays with some points
..
var newTime= splineInterpolate(cursorOffset, offsets.ToArray(), times.ToArray())

Upvotes: 0

Views: 2982

Answers (1)

EvilTak
EvilTak

Reputation: 7579

It depends on what kind of interpolation you want. If you don't want the interpolation function to pass through the control points, you can use a Bezier curve (you can choose the order of the curve).

If you want the curve to pass through the control points, a popular choice is a cubic Hermite spline. There are many types of hermite splines like cardinal and catmull-rom splines (which are C1 and C2 continuous).

If you just do a simple Google search, you will come across thousands of results for splines with their implementation in C# provided.

Upvotes: 1

Related Questions