Give me the general mathematical formula for NURBS curves, with special cases (B-spline and Bézier curves)
[Math] the general formula for NURBS curves
bezier-curveplane-curves
Related Solutions
I'm not sure I understand the problem 100%, but here are some suggestions, anyway.
If you want an explicit NURBS representation of a curve that lies exactly on your surface of revolution, then the only option is a surface parameter space curve of the type mentioned by Fang.
So, take the data you want to fit, and map it back into a two-dimensional $uv$ space. Then, do whatever fitting you want to do in this space. This will give you curves $(u,v) = \big(u(t), v(t)\big)$ that match your data to the desired accuracy. In your fitting, you need to use polynomial or rational curves, and it would be best if the degree was pretty low. In fact, quadratic polynomials might be adequate.
Now, to get an explicit 3D NURBS curve, we need to form the composition of these $uv$ curves with the equation of the surface of revolution. So, suppose $S(u,v)$ is a rational parameterization of the surface of revolution. Then $t \mapsto S\big(u(t), v(t)\big)$ is a curve lying exactly on the surface of revolution that satisfies your constraints (if I understand them correctly).
Since this curve is a composition of rational functions, it is itself rational. There are a couple of ways to get the coefficients (i.e. the "control points") of this curve. One option is to fire up your favorite computer algebra system and just do the function compositions. Another way is to interpolate a suitably chosen set of points in 4D. If done correctly,the interpolation process will exactly reproduce the curve.
Actually, it looks like the composition mess is already worked out for you in this paper. and this one, and this one. The third one is the most recent, so it has the best references, and it's available on-line in PDF form.
If your surface of revolution (expressed in NURBS form) has degree $3 \times 2$, and your $uv$ curves are quadratic, then your final curve will have degree $3*2 + 2*2 = 10$. This is a bit high, but not too bad. And, if you want a NURBS curve that lies exactly on the surface, you have no choice.
The interpolation approach is probably the easiest to implement. Here's how you might approach it. If we regard the surface as a polynomial mapping from $[0,1] \times [0,1]$ to $\mathbb{R}^4$, then the composition curve $C(t) = S\big(u(t), v(t)\big)$ can be regarded as a polynomial mapping from $[0,1]$ to $\mathbb{R}^4$. If we use quadratic curves in $uv$ space, then as explained above, we know that $C$ has degree 10. So, take any 11 points on the curve, and interpolate them with a curve of degree 10, and you know that the curve you get will be exactly $C$, because this interpolation problem has a unique solution. So, take 11 parameter values $t_0, t_1, \ldots, t_{10} \in [0,1]$ and compute the ten points $Q_i = S\big(u(t_i), v(t_i)\big)$ for $i = 0,1, \ldots, 10$. Then find the control points of the unique curve $X$ of degree 10 such that $X(t_i) = Q_i$ for $i = 0,1, \ldots, 10$. You can find these control points just by solving a linear system -- easy. By uniqueness, $X$ must be the curve $C$ that we're seeking.
All of this reasoning applies only to a Bezier curve lying on a (rational) Bezier surface. If you want to deal with b-spline curves and surfaces, you first have to decompose them into their constituent Bezier pieces to do the interpolation calculations. Then, after you're all done, you can glue the Bezier curves back together to form NURBS curves, if you want to.
Catmull-Rom and Natural spline are both ways for creating a cubic spline curve interpolating a given set of points. Typically, the curve will be in parametric form where x and y are both function of t. For parametric spline interpolation, assigning a parameter to each data point is the most essential step, which is often referred as parametrization. Typically, we will use either chord-length or centripetal parametrization.
If you need "cubic spline function", all you need to do is to use $t=(x-x_{min})/(x_{max}-x_{min})$ for parametrization where $x_{min}$ is the smallest $x$ value and $x_{max}$ the largest $x$ value among your data points. You can choose either Catmull-Rom or Natural spline to construct your "spline function". Afterwards, evaluating the spline function will simply require an additional step to convert $x_i$ to $t_i$ as $t_i=(x_i-x_{min})/(x_{max}-x_{min})$.
Best Answer
Suppose we have a sequence of $n$ 3D control points $\mathbf P_1, \mathbf P_2, \ldots, \mathbf P_n$, and corresponding weights $w_1, w_2, \ldots, w_n$. If we want a NURBS curve of degree $m$ (order $k = m+1$), then we need $n+k$ knots $t_1, \ldots , t_{n+k}$. Then the NURBS curve is given by the formula $$ \mathbf C(t) = \frac{\sum_{i=1}^n N_i(t)w_i \mathbf P_i}{\sum_{i=1}^n N_i(t)w_i} $$ where $N_i(t)$ is the $i$-th b-spline basis function of degree $m$ constructed from the knots $t_1, \ldots , t_{n+k}$.
If all the $w_i$ are equal, then they cancel out, and we get the polynomial b-spline $$ \mathbf C(t) = \sum_{i=1}^n N_i(t)\mathbf P_i $$ If the knots are of the form $(a,a, \ldots, a,b,b,\ldots,b)$ --- $k$ $a$'s followed by $k$ $b$'s, then the b-spline curve has only a single segment, which means that it's a Bezier curve.