# Fitting a line curve to 3D data

I have a set of points in 3D which I need to fit a curve (not a plane) to. Essentially these points describe a string with a set order (i.e. point one connects to point two, etc.) and I need to fit a curve to follow these points and produce a smoothed, single-width string as a result.

Unfortunately all of the 3D fitting algorithms I've found so far (I'd probably go with polynomial fitting) result in a plane, not a line, and it's lead me to believe what I need is a 2D fitting algorithm which operates on three sets of coordinates.

I can work out how to do linear interpolation for these points, it's figuring out the polynomial that I'm struggling with. Does anybody have any helpful pointers for this?

-
Since your points are already in a specified order, you could try fitting the $x$, $y$, and $z$ coordinates independently as functions of the index of the point in the ordering. That is, if you have points $(x_1,y_1,z_1)$, $(x_2,y_2,z_2)$, and so on, you fit $x_i$ as a function of $i$, then $y_i$ as a function of $i$, and $z_i$ as a function of $i$. Then your curve is given by $t\mapsto(x(t),y(t),z(t))$.