c++algorithmeigensplinebspline

Understanding Curve Global Approximation algorithm


Problem description

I am trying to understand and implement the Curve Global Approximation, as proposed here:

https://pages.mtu.edu/~shene/COURSES/cs3621/NOTES/INT-APP/CURVE-APP-global.html

To implement the algorithm it is necessary to calculate base function coefficients, as described here:

https://pages.mtu.edu/~shene/COURSES/cs3621/NOTES/spline/B-spline/bspline-curve-coef.html

I have trouble wrapping my head around some of the details.

  1. First there is some trouble with variable nomenclature. Specifically I am tripped up by the fact there is ![u](https://chart.googleapis.com/chart?cht=tx&chl=%5Csqrt%7Bu%7D) as function parameter as well as input and ![u_0 - u_k](https://chart.googleapis.com/chart?cht=tx&chl=%5Csqrt%7Bfoo%7D). Currently I assume, that first I decide how many knot vectors I want to find for my approximation. Let us say I want 10. So then my parameters are:

enter image description here

I assume this is what is input parameter ![u](https://chart.googleapis.com/chart?cht=tx&chl=%5Csqrt%7Bu%7D) in the coefficient calculation algorithm?

  1. The reason this ![u](https://chart.googleapis.com/chart?cht=tx&chl=%5Csqrt%7Bu%7D) tripped me up is because of the sentence:

Let u be in knot span enter image description here

If input parameter ![u](https://chart.googleapis.com/chart?cht=tx&chl=%5Csqrt%7Bu%7D) was one of the elements of the knot vector ![u_0 - u_k](https://chart.googleapis.com/chart?cht=tx&chl=%5Csqrt%7Bfoo%7D), then there was no need for an interval. So I assume ![u](https://chart.googleapis.com/chart?cht=tx&chl=%5Csqrt%7Bu%7D) is actually one of these elements ( enter image description here ?), defined earlier:

enter image description here

Is that assumption correct?

  1. Most important question. I am trying to get my N to work with the first of the two links, i.e. the implementation of the Global Curve Approximation. As I look at the matrix dimensions (where P, Q, N dimensions are mentioned), it seems that N is supposed to have n rows and h-1 columns. That means, N has rows equal to the amount of data points and columns equal to the curve degree minus one. However when I look at the implementation details of N in the second link, an N row is initialized with n elements. I refer to this:

Initialize N[0..n] to 0; // initialization

But I also need to calculate N for all parameters ![u](https://chart.googleapis.com/chart?cht=tx&chl=%5Csqrt%7Bu%7D) which correspond to my parameters enter image description here which in turn correspond to the datapoints. So the resulting matrix is of ddimension ( n x n ). This does not correspond to the previously mentioned ( n x ( h - 1 ) ).

To go further, in the link describing the approximation algorithm, N is used to calculate Q. However directly after that I am asked to calculate N which I supposedly already had, how else would I have calculated Q? Is this even the same N? Do I have to calculate a new N for the desired amount of control points?

Conclusion

If somebody has any helpful insight on this - please do share. I aim to implement this using C++ with Eigen for its usefulness w.r.t. to solving M * P = Q and matrix calculations. Currently I am at a loss though. Everything seems more or less clear, except for N and especially its dimensions and whether it needs to be calculated multiple times or not.

Additional media

calculation of N


Calculate approximating curve

In the last image it is supposed to say, "[...] used before in the calculation of Q"


Solution

  • The 2nd link is telling you how to compute the basis function of B-spline curve at parameter u where the B-spline curve is defined by its degree, knot vector [u0,...um] and control points. So, for your first question, if you want to have 10 knots in your knot vector, then the typical knot vector will look like:

    [0, 0, 0, 0, 0.3, 0.7, 1, 1, 1, 1]

    This will be a B-spline curve of degree 3 with 6 control points.

    For your 2nd question, The input parameter u is generally not one of the knots [u0, u1,...um]. Input parameter u is simply the parameter we would like to evaluate the B-spline curve at. The value of u actually varies from 0 to 1 (assuming the knot vector ranges is also from 0 to 1).

    For your 3rd questions, N (in the first link) represents a matrix where each element of this matrix is a Ni,p(tj). So, basically the N[] array computed from 2nd link is actually a row vector of the matrix N in the first link.

    I hope my answers have cleared out some of your confusions.