0

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"

Community
  • 1
  • 1
Koenigsberg
  • 1,726
  • 1
  • 10
  • 22
  • 1
    https://mathoverflow.net/ or https://math.stackexchange.com/ may be a better fit for this question. It doesn't have any C++ in it (except tags) as far as I can see. – Ted Lyngmo Oct 25 '19 at 16:48
  • Admittedly I am not certain which SE is best for this. I chose SO, because the questions refer specifically to these two algoithm implementations and because I want to implement this using Eigen. – Koenigsberg Oct 25 '19 at 16:52
  • 1
    Then I think you need to start implementing it and ask for specific questions with regards to the problems that arise. As it is, I think it'll be closed. Your questions look math related and not implementation related - but I don't know much math so I could be wrong. – Ted Lyngmo Oct 25 '19 at 16:55
  • I do not understand how I am supposed to start implementing this, if I am unclear on key questions *w.r.t.* to the sample algorithms. – Koenigsberg Oct 25 '19 at 16:58
  • 1
    That's why I suggest that you start in a math forum. Get help there and return here with implementation problems. I'm sure `eigen` isn't new to them. – Ted Lyngmo Oct 25 '19 at 16:59
  • FWIW, the question on the math SE generated zero comments and zero answers. – Koenigsberg Oct 26 '19 at 20:45
  • That was sad but it doesn't change the fact that it was the right decision to post there. – Ted Lyngmo Oct 26 '19 at 23:21

1 Answers1

1

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.

fang
  • 3,473
  • 1
  • 13
  • 19
  • Yes and no. First, have an upvote for your effort, as some things I assumed are confirmed. But especially *w.r.t.* N - I mentioned myself, that I assume the algorithm in the second link computes a row of N. But that row is initialized with *n* elements, this results in *n* columns. According to the matrx N as shown in the first link, N should have *n* rows, but *p - 1* columns. Following these two algorithms I get to an N with *n x n* dimensions and this is where I am stuck. – Koenigsberg Oct 26 '19 at 20:48
  • In the 2nd link, (n+1) is number of control points whereas in the first link (n+1) is number of data points. BTW, matrix N has (h-1) columns, not (p-1) columns. – fang Oct 26 '19 at 21:04
  • I think this may help me. I will review your explanation - if I can resolve my problem and confirm your responses your answer will be accepted. – Koenigsberg Oct 28 '19 at 07:49
  • I believe the probblem lies in the knot vector generation. You generate the vector by apending 0 p+1 times to the front and 1 p+1 times to the back. You also derive the total amount of elements in the vector from your desired amount of control points and so you can interpolate the blank inner ones. However when you look at their knot generation, which I post below this comment, you see they generate the knot vector by averaging parameter set entries depending on degree. And parameter set clearly has as many elements as dataset. I can't seem to bring the two together. – Koenigsberg Oct 28 '19 at 15:05
  • https://pages.mtu.edu/~shene/COURSES/cs3621/NOTES/INT-APP/PARA-knot-generation.html – Koenigsberg Oct 28 '19 at 15:05
  • From Global Curve Approx.: *" Note that the number of parameters is equal to the number of data points. *". There is no statement how large their knot vector is, though. – Koenigsberg Oct 28 '19 at 15:08
  • To sum up: Target are 10 control points. Formula for knot vector is *n+p+1*, therefore it is dependent on the amount of parameters (*n*). Your knot vector doesn't transate to that, because there is no dependency on parameter set at all, only the target amount of knots as well as degree. – Koenigsberg Oct 28 '19 at 15:13
  • Let's assume in alg. from the second link you initialized *N* with the target amount of control points which is 10. Then you would proceed to look for the indices between which your *u* is located. But as there are potentially a lot more parameters and therefore knots than target control points, this would result in attempting to access indices that don't exist. – Koenigsberg Oct 28 '19 at 15:20
  • Averaging parameters to obtain knot vector is typically used for interpolation case where the number of control points is the same as the number of data points. For approximation case (e.g. LS fitting), this is not necessarily required. Of course, if you want to derive your knot vector from parameters for approximation case, that is OK as well. – fang Oct 28 '19 at 17:09
  • Supposed you have 100 data points, the B-spline curve you choose to approximate these 100 data points could have 2 control points (with degree 1) or 100 control points (at the maximum). When you use 100 control points , then your case actually become interpolation. What number of control points to use is really your choice. – fang Oct 28 '19 at 17:18
  • I understand this, the interpol. matrix indeed does have `n x n` dimensions. For approx. I *assume* the aim is to derive `h-1` control points from `n` data points. Parameter set is derived from data points, it corresponds 1:1. Knot vector is derived from parameter set and degree of curve via `n+p+1`. Matrix `N` is then derived from knot vector and parameter set *w.r.t.* to its dimensions. Control points are found using data points and N. I fail to see how initially to build N using chosen amount of control points, if its dimensions depend on knot vector which depends on amount of data points. – Koenigsberg Oct 29 '19 at 08:24
  • To put differently, if I just choose a control point vector and a parameter set, then I don't see how approximation is different from sampling `k` points from my data set and then do interpolation. Get params: https://pages.mtu.edu/~shene/COURSES/cs3621/NOTES/INT-APP/PARA-chord-length.html Get knot vector: https://pages.mtu.edu/~shene/COURSES/cs3621/NOTES/INT-APP/PARA-knot-generation.html Since for approx. they stated, that parameter set corresponds to amount of data points, I *assume* they derive control points from all given datapoints, not just a subset. – Koenigsberg Oct 29 '19 at 08:28
  • Just in case this does not come accross - I am not arguing with you, just trying to comprehend this myself. – Koenigsberg Oct 29 '19 at 08:28
  • I suppose the problem is the knot generation. Since my parameter set must correspond to all data points, this then means that my knot vector must be derived from the desired amount of control points rather than from data points / degree, as is done in their material. This also means, *de Boor*'s algorithm cannot be used. – Koenigsberg Oct 29 '19 at 08:33
  • Update: Last week I was able to complete the implementation. I used a knot vector as defined by the formula *n+p+1* rather than a chord length based version, because it is unclear if and how it can be adapted to an arbitrary amount of control points. In any case, curves are looking wonderful, thank you for your input. Marking as answered. – Koenigsberg Nov 04 '19 at 15:46