Talk:B-spline
Computer graphics Start‑class | ||||||||||
|
Mathematics B‑class Low‑priority | ||||||||||
|
Old stuff
The definiton of B-spline is not correct:
- Knots may repeat, i.e. t_i <= t_{i+1}, not t_i < t_{i+1} as article states.
- S(t) domain is [0,1], but B-spline is defined in range [t_n, t_{m-n-1}] and thus additions are done across indexes i=0..m-n-1, not i=0..m.
- Since knots may repeat, denominators appear in de Boor-Cox formula, i.e. t_{i+n}-t_i and t_{i+n+1} - t_{i+1} may eqaul zero. In such cases certain part of sum just disappear.
- Count of control points is limited: n = m-k-1, where k is a degree of curves, and n is a max index of P.
And two notes:
- The full name of Cox-de Boor formula is "Mansfield-de Boor-Cox".
- B-spline is a shotening from "basis spline function", thus "basis B-spline" means "basis basis spline function" and it is quite redundant.
I am not native speaker, so I haven't touched the article. Someone, please consider my remarks.
The matrix form of the uniform B-splines may not be correct. If the basis formula is derived from the Bernstein polynomial, then the correct cubic matrix is [-1 3 -3 1; 3 -6 3 0; -3 3 0 0; 1 0 0 0].
An excellent reference for B-splines & Bezier curves is G. Farin's Curves and Surfaces for Computer Aided Geometric Design Academic Press, 4th ed. 1994 (I don't know the correct way to add a book reference.)
- The sum should be over all points, not just 0 to "m-n-1". The reason is trivial: If the points are not included in the sum, they have no effect on the curve at any value of t. Fyo 20:20, 3 July 2007 (UTC)
- Unless anyone objects, I will change the nomenclature used in this article to reflect the majority of bspline texts: n is the number of control points -1, k is the degree and m the number of knots (the article currently uses n as the degree). While p is also commonly used to denote degree, my experience is that students tend to confuse it with the capital P used for the control points. Since "k" is also used quite often in the literature, this would be my preference. Fyo 20:20, 3 July 2007 (UTC)
The definition of B-spline at the top, as a function into the plane, is not consistent with most of the rest of the article, where B-splines are real-valued. The definition doesn't need to be the most general, but should cover common cases at least, so whoever fixes the other points, could you have a look at this, too? Possibly a simple definition with references for variants? Reidhuntsinger (talk) 20:53, 29 April 2010 (UTC)
OK, I misunderstood. Maybe distinguish between a "B-spline curve" (the first instance of B-spline) and a B-spline? Note that the former is often referred to as a B-spline, too. Define a spline as a linear combination of B-splines, then point out that a "B-spline curve" is just a pair of splines t -> (f(t),g(t)). Reidhuntsinger (talk) 21:03, 29 April 2010 (UTC)
Blending Function
What is the exact definition of a blending function?--SiriusB 08:18, 5 September 2005 (UTC)
Changing the degree
I am not an expert on this - but the degree in the Cox-deBoor recursion looks out by 1. I will change (change back if you object) Michael Kemp. —Preceding unsigned comment added by 137.166.4.130 (talk) 00:37, 26 September 2008 (UTC)
I think there is some information missing to make this comprehensible for people that (like me) are new to B-splines:
After quite some time of thinking I think to have found out that the parameter t is for all three segments, while in the form that constant and linear B-splines are given in, t does not "jump" from 1 to 0 at the segment borders. Am I right? If so, this should definitely be clarified. --Zupftom (talk) 12:36, 1 May 2009 (UTC)
P.S.: It is said that the B-spline given in the above form is uniform, but this doesn't say anything about the distance between two knots, right? —Preceding unsigned comment added by Zupftom (talk • contribs) 12:43, 1 May 2009 (UTC)
How useful would a higher-order uniform B-spline be?
D. Salomon's book "Computer graphics and geometric modeling" has some higher-order basis matrices worked out...
For example, the quartic spline:
Any value in putting this on the article (or at least referring to the book) ?
--Immer in Bewegung (talk) 06:06, 21 May 2009 (UTC)
- IMO I wouldn't copy the matrix into the article. But a mention that quartic splines are used in computer graphics (or wording supported by that book), with that ref given, might be a good addition to the article. After all, nearly all splines used are cubic (or less).
Propose this be split into two articles
I propose that this article be split into two articles, one pertaining to the use of the term "B-spline" to refer to a curve, the other pertaining to the use of "B-spline" to refer to a mathematical function.
"Spline" already has a disambiguation page. It seems to me that "B-Spline" needs one too, for parallel reasons. Dratman (talk) 21:28, 24 January 2011 (UTC)
- Has there been a discussion of a problem that this is a solution to? I don't see it. I don't quite get the distinction you're making; can you explain and point out sources for the different interpretations? Dicklyon (talk) 21:39, 24 January 2011 (UTC)
B-spline name
Isn't B in B-spline just from name Bazier. It is just like linear, quadratic, qubic splines have in each interval linear quadratic or qubic form, similary in B(azier)-splines in each subinterval we have a Bezier function (which is a function of basis polynomials aka Bernstein basis functions). So who and why, call B-splines a "basis splines" ? I do not get it, and I'm not sure if this is correct. —Preceding unsigned comment added by 149.156.82.207 (talk) 19:13, 7 April 2011 (UTC)
- The relation of "basis spline" to Bezier curves is covered in many books. Dicklyon (talk) 20:30, 14 August 2011 (UTC)
Correctness of definition
I have two objections with the definition of the B-Spline. Firstly, the article states , but the next formula states . Isn't this inconsistent? Please clarify.
Secondly, consider the following B-Spline: Degree n=1, p=2 points, thus m=p+n+1=4 knots. Let the knot vector be (0,0,1,1), thus t in [0,1]. For t=1 however, both and evaluate to 0 according to the definition in the article. What is the problem? In particular, but .
SimonFuhrmann (talk) 20:18, 14 August 2011 (UTC)
- I believe the first interval should be changed to match the second, since there's not enough info to define the spline near the ends where you don't have enough knots for the order. And your knots are too degenerate for order 1, leading to division by zero.
- But why is it even talking about instead of amore general point space; doesn't it work just as well in 2D, 1D, and 4D? Dicklyon (talk) 20:48, 14 August 2011 (UTC)
- I agree that should be a more general space --- I changed this to be . I also changed the domain of to be . The problem with the basis polynomials that are all zero for is, however, more serious. It does not only happen for knots that are "too degenerate for order 1", it happens for all orders. So the domain of the spline should either be limited to , or should be relaxed to with the comment that the basis polynomials are >0 only in . The same goes for the last sentence before the "uniform b-spline" section, where the "limited subrange" should be . The reason for this is that the "linear support", i.e. the functions, are only defined in . --SimonFuhrmann (talk) 14:40, 15 August 2011 (UTC)
- I'm a bit confused about the domain of . As I read it, means that can be drawn from anywhere in between and , where is the degree of the B-spline, and is the number of knots. Assuming this is the case, it doesn't seem to work properly: for example, if we had a spline of degree with knots, this would yield , which doesn't make sense. Should it instead be , giving a total of knot spans? ProframFiles (talk) 08:39, 8 July 2012 (UTC)
External links
I added the external link to my free Web e-book. It is a more complete treatment of piecewise interpolation for those new to the subject and aimed at graphics. I'll add references to other related Wiki pages in the future.
My e-book is both a study of the fundamentals described in simple terms as well as a reference showing many types of Polynomial Interpolation -both common types and some developed by the author. It also shows some techniques not seen elsewhere. Linear interpolation is looked at carefully and shown is as the basis for all more advanced types using only Algebra. Only after understanding how adding squared and cubed terms cause smooth curves, are the more advanced curves examined such as Bezier, Catmul-Rom, b-spline, and Hermite. More advanced mathematical concepts and notations are kept to a minimum. Some additional techniques that are suggested by the mathematics and that the author has not seen elsewhere are examined. A reference is also included with all the most common curve drawing methods and includes drawings to allow comparison with other types.
WHY: I had hoped, but failed to find a book explaining polynomial interpolation basics and thought that one must certainly exist with a collection of interpolation types. I found either purely mathematical tests or advanced graphics texts. Several years later, I started reading the original Internet Usenet "groups", comp.graphics.algorithms, and did lots of searching on the net. I saved whatever I found related to splines and curves, but did not look at it or try to understand any of it until early in 1996, I decided to look at what I had collected, and started to figure things out. I begin recording my thoughts for future reference and this is the result. The very book I wanted originally is now freely available for others.
I do not believe this has any issues with the Wiki self cite guidelines. -- Steve -- (talk) 22:48, 28 August 2011 (UTC)
Cardinal splines confusing
Is it true that a cardinal spline is a b spline? Just that we assume that consecutive t_i's have distance 1? I think a remark along those lines in the text would really help understand it. 12.25.180.20 (talk) 22:57, 13 June 2013 (UTC)
Major revision
I have done a major revision of this article which was rather confused. In particular, the bits pertaining to computer graphics are now in a separate section. I have had to delete statements such as "Put in matrix-form, it is:<ref>[http://graphics.idav.ucdavis.edu/education/CAGDNotes/Quadratic-Uniform-B-Spline-Curve-Splitting/Quadratic-Uniform-B-Spline-Curve-Splitting.html Splitting a uniform B-spline curve]</ref>
- for ".
because
- citing a web-site is not sufficient for verification
- there is no reference to any such formula in Non-uniform rational B-spline, though it is clearly related
- I don't know of a book which could be used to verify the formula (I'm not sufficiently knowledgeable about computer graphics).
If someone can provide an acceptable verification source, it could be re-instated into the section on computer graphics, but it will need further explanation (e.g. uniform knots) and perhaps a revision of the terminology. Petergans (talk) 17:25, 13 August 2013 (UTC)
Definitions of functions
It is not clear what the domains and ranges of any functions defined in this article are. The standard notation is to denote a function f with domain A and range B by . Please adhere to this. — Preceding unsigned comment added by 128.32.92.238 (talk) 20:28, 23 September 2013 (UTC)
- The notation follows that in de Boor's book. The domain of a B-spline is clearly stated in the first sentence of Definition. BTW, non-mathematicians will not understand the notation . Petergans (talk) 08:57, 24 September 2013 (UTC)
Very confusing Definition section
I find the definition section highly confusing and little illuminating! The problem is that it is completely unclear why the basis sometimes has 1, sometimes 2 and sometimes 3 subscript indices. It would be great if someone could make that a bit more rigorous. (22. Jan 2014) — Preceding unsigned comment added by 149.217.40.222 (talk) 13:54, 22 January 2014 (UTC)
Derivative
The formulae in the section on derivative expressions have a factor of k-1. This would seem to suggest that the derivative of a B-spline of degree k=1 is identically equal to 0. But surely that can't be true. I suspect that the source for these expressions uses indexing starting from k=1 whereas this article uses indexing starting from k=0. Does anyone object if I change the k-1 to k? Ossi (talk) 14:48, 30 March 2014 (UTC)
- I have put in the summation limits, copied from de Boor eqn. 11b, p139. Petergans (talk) 09:42, 1 April 2014 (UTC)
- I wasn't talking about the summation limits. I was talking about the degree k of the splines. It seems de Boor uses the convention that the lowest degree splines have k=1, whereas this article uses k=0. Do you disagree? Do you object if I change the k-1 into k in the formulae? Ossi (talk) 23:29, 2 April 2014 (UTC)
- I have used de Boor's book as the main source for my contributions, so I don't understand how there is an inconsistency. I'm not expert regarding the maths, but have published an application (P. Gans and J.B. Gill,"Smoothing and differentiation of spectroscopic curves using spline functions", Applied Spectroscopy 1983, 38, 370 375 for which I used the computer code in the book. If there is an issue with the degree of the spline, it needs to be stated explicitly, where appropriate. I don't think that there is an issue, as a piece-wise polynomial of degree 0 is simply a set of constants and that is not a spline function as it does not have any continuity property at the knots. Petergans (talk) 09:30, 4 April 2014 (UTC)
- "I have used de Boor's book as the main source for my contributions, so I don't understand how there is an inconsistency."
- There's inconsistency because it seems that de Boor and this article use a different convention regarding whether the index k starts from 1 or 0.
- I have used de Boor's book as the main source for my contributions, so I don't understand how there is an inconsistency. I'm not expert regarding the maths, but have published an application (P. Gans and J.B. Gill,"Smoothing and differentiation of spectroscopic curves using spline functions", Applied Spectroscopy 1983, 38, 370 375 for which I used the computer code in the book. If there is an issue with the degree of the spline, it needs to be stated explicitly, where appropriate. I don't think that there is an issue, as a piece-wise polynomial of degree 0 is simply a set of constants and that is not a spline function as it does not have any continuity property at the knots. Petergans (talk) 09:30, 4 April 2014 (UTC)
- I wasn't talking about the summation limits. I was talking about the degree k of the splines. It seems de Boor uses the convention that the lowest degree splines have k=1, whereas this article uses k=0. Do you disagree? Do you object if I change the k-1 into k in the formulae? Ossi (talk) 23:29, 2 April 2014 (UTC)
- "I don't think that there is an issue, as a piece-wise polynomial of degree 0 is simply a set of constants and that is not a spline function as it does not have any continuity property at the knots."
- The base case for B-splines is a piecewise constant polynomial as you can see the definition. The issue is whether we say that k=0 or k=1 for these. De Boor seems to use k=1 and this article seems to use k=0 (except in the derivative section). Both conventions are fine, but one should not mix them. Does this clarify the issue for you? Ossi (talk) 11:40, 4 April 2014 (UTC)
I don't understand where k=0 is supposed to be implied.Petergans (talk) 12:40, 5 April 2014 (UTC)
- I mean, using this article's definition: k = polynomial degree. Using de Boor's definition: k = polynomial degree + 1. However, the derivative section uses the definition used by de Boor in contrast to the rest of the article, which is confusing. Is it now clear what I meant? Ossi (talk) 15:18, 5 April 2014 (UTC)
- I'll go ahead and change the formulae. Ossi (talk) 19:39, 10 April 2014 (UTC)
I've reverted the edit. You can't change one k into k-1 and leave others unchanged.
before your edit -
after your edit - :
Petergans (talk) 11:46, 11 April 2014 (UTC)
- One can and should change it, because without the change k means a different thing in these expressions and the rest of the article. I don't have the book by de Boor, but in these lecture notes he defines B-spline base case (formula 2.1 on page 2):
- In this Wikipedia article's definition section the base case is defined as:
- As you can see, these are slightly discrepant. The problem is that the derivative expression are correct for B-splines as defined by de Boor but incorrect for B-splines as defined in this article. Ossi (talk) 11:27, 12 April 2014 (UTC)
- Actually it was the definition section that was wrong. I have de Boor's book and have made the necessary corrections, copying directly from the book. Thank you for bringing the errors to my attention. Petergans (talk) 12:55, 14 April 2014 (UTC)
- I think the definition was an alternative convention (possibly used by some other author), rather than being just wrong. But it doesn't matter. After your changes the article is now consistent and the issue with the derivative expressions is resolved. Ossi (talk) 15:28, 15 April 2014 (UTC)
- Actually it was the definition section that was wrong. I have de Boor's book and have made the necessary corrections, copying directly from the book. Thank you for bringing the errors to my attention. Petergans (talk) 12:55, 14 April 2014 (UTC)
- My two cents: I found the current version (with being piecewise constant) confusing since it talks about "degree k" yet piecewise constant is degree 0 not degree 1. The current version is also different from Non-uniform_rational_B-spline#Construction_of_the_basis_functions which is similar, of course, and also says the second subscript (n) "corresponds with the degree of the basis function". Regardless of de Boor's nomenclature, 0 seems clearer. —Ben FrantzDale (talk) 13:26, 29 April 2014 (UTC)
- It seems that in de Boor's nomenclature Bj,k is a spline of order k, not degree. Using de Boor's definition the polynomial degree of the spline is k-1. Ossi (talk) 15:01, 29 April 2014 (UTC)
- Looking at order of a polynomial and degree of a polynomial, I'm not sure I follow. It appears true that the order of a polynomial can be larger than the largest exponent if you have defined a basis that goes higher, but in this case, isn't the piecewise constant function still order 0? Either way, I'd argue that "degree" gives a clearer explanation with fewer chances for confusion: are the functions that have terms, have terms, etc. —Ben FrantzDale (talk) 15:43, 29 April 2014 (UTC)
- It seems de Boor uses a slightly different definition for order (offset of 1) compared to the Wikipedia article. You can see this in his textbook. Look at page 1 in the free preview. Ossi (talk) 21:35, 29 April 2014 (UTC)
- Looking at order of a polynomial and degree of a polynomial, I'm not sure I follow. It appears true that the order of a polynomial can be larger than the largest exponent if you have defined a basis that goes higher, but in this case, isn't the piecewise constant function still order 0? Either way, I'd argue that "degree" gives a clearer explanation with fewer chances for confusion: are the functions that have terms, have terms, etc. —Ben FrantzDale (talk) 15:43, 29 April 2014 (UTC)
Total number of knots
The total number of knots is not k+2. At both ends there are are k knots because the function and all its derivatives are discontinuous at the limits of definition. Stricly speaking, therefore, the total is 3k, but this would need explanation, so giving the number of internal knots as k is simpler, and is also correct. The multiplicity of the knots at the ends is a technicality of no practical importance. Petergans (talk) 08:47, 18 April 2014 (UTC)
- The minimum number of knots is k+1. You get this when you have only one spline, which is non zero in k intervals and thus needs k+1 knots. Ossi (talk) 21:20, 18 April 2014 (UTC)
- Not so. Look at the diagrams. The number of internal knots is equal to the order of the polynomial. Petergans (talk) 08:31, 19 April 2014 (UTC)
- Yes, that's true. But the degree of the polynomial is k-1 so you get k+1 knots, if you add the knots at the both ends. Ossi (talk) 09:46, 19 April 2014 (UTC)
- In fact, let me add a reference, so that you'll believe me. Look at the page 4 in de Boor's lecture notes. It says: "In fact, all Bj,k are of exact degree k-1." Ossi (talk) 10:10, 19 April 2014 (UTC)
- Let's not get confused. I have a personal copy of de Boor's book and have strictly followed the conventions in it. The degree of the polynomial is k. This is clearly stated in the Definitions section and this convention is followed throughout this article. Petergans (talk) 22:57, 19 April 2014 (UTC)
- If you look at de Boor's definition, it's clear that a linear B-spline has k=2 and a cubic B-spline has k=3 etc. Are you sure you are not confusing the degree of a polynomial and the order of a polynomial as defined by de Boor? I looked at a preview of de Boor's book here. On page 1 he defines that a polynomial of order n is a polynomial of degree < n. Ossi (talk) 23:53, 19 April 2014 (UTC)
- Let's not get confused. I have a personal copy of de Boor's book and have strictly followed the conventions in it. The degree of the polynomial is k. This is clearly stated in the Definitions section and this convention is followed throughout this article. Petergans (talk) 22:57, 19 April 2014 (UTC)
- In fact, let me add a reference, so that you'll believe me. Look at the page 4 in de Boor's lecture notes. It says: "In fact, all Bj,k are of exact degree k-1." Ossi (talk) 10:10, 19 April 2014 (UTC)
- Yes, that's true. But the degree of the polynomial is k-1 so you get k+1 knots, if you add the knots at the both ends. Ossi (talk) 09:46, 19 April 2014 (UTC)
- Not so. Look at the diagrams. The number of internal knots is equal to the order of the polynomial. Petergans (talk) 08:31, 19 April 2014 (UTC)
The definition
is quite clear - when k=1 the spline function has degree 1 and is a constant. Unless you can demonstrate an inconsistency within the article, this discussion is closed. Petergans (talk) 08:49, 20 April 2014 (UTC)
- I can demonstrate an inconsistency within the article. Take the spline with k=1 you just defined above. It is a piecewise constant function and, as you can see, is non zero in exactly 1 interval. It has 0 internal knots and 2 knots in total when you add the knots at the ends. Since k=1 and thus k+1=2, it is the formula k+1 which gives the correct number of knots (not k+2).
- Similarly Bj,2 has k=2 and is a piecewise linear function. It has 1 internal knot and 3 knots in total. Correct number of knots is given by k+1=3.
- Bj,3 has k=3 and is a piecewise quadratic polynomial. It has 2 internal knots and 4 knots in total (as you can see from the first figure in the article). Correct number of knots is given by k+1=4.
- Etc. for higher degree splines. Is this enough to convince you? (If necessary, I can type out the actual expressions for the splines.) Ossi (talk) 11:55, 20 April 2014 (UTC)
- Edited my comment to correct a minor error. Ossi (talk) 22:56, 20 April 2014 (UTC)
- Petergans, are you still following this discussion? There's no hurry, but I want to make sure that I don't have to wait indefinately, if you no longer follow this issue. Ossi (talk) 09:51, 25 April 2014 (UTC)
- You don't have a case. Are you making a distinction between order and degree? Petergans (talk) 09:09, 26 April 2014 (UTC)
- I do have a case. Consider the base case B-spline:
- For this spline k=1. The non zero part touches exactly 2 knots, namely tj and tj+1. Thus the number of knots needed is k+1=2 (not k+2, as the article currently states). Do you disagree? If you are not convinced, could specify in which part you think there is an error, so I can either respond or be convinced by your argument. (I didn't use the words degree or order in this comment nor my previous one, so my argument doesn't depend on, how those terms are defined.) Ossi (talk) 15:05, 26 April 2014 (UTC)
- I looked into de Boor's textbook. It says on page 101: "a spline function of order k may have as few as k+1 knots (but not fewer)". Is this enough to convince you? Ossi (talk) 18:56, 26 April 2014 (UTC)
- I do have a case. Consider the base case B-spline:
- You don't have a case. Are you making a distinction between order and degree? Petergans (talk) 09:09, 26 April 2014 (UTC)
- Petergans, are you still following this discussion? There's no hurry, but I want to make sure that I don't have to wait indefinately, if you no longer follow this issue. Ossi (talk) 09:51, 25 April 2014 (UTC)
- Edited my comment to correct a minor error. Ossi (talk) 22:56, 20 April 2014 (UTC)
I've now changed the article to be in accordance with de Boor. Ossi (talk) 14:31, 1 May 2014 (UTC)
Avoiding division by zero
I see this topic mentioned a bit here, but it needs to be addressed: If knots are repeated, which is a common case, the ramp functions,
and
may go to infinity, which isn't well-behaved. I'm trying to figure out what the right behavior is: It seems like if the ramp function is infinite then the corresponding B may be zero, so we could wave our hands and make that "correction", but that's not exactly elegant. Conceptually those ramp functions are just trying to indicate how far along each knot span x is, so it's probably safe to clamp the ramp functions to the range [0, 1]. Of course, for a knot that appears thee times, that might get weird since the two ramp functions together wouldn't be a partition of unity. What's the Right Way to deal with this? —Ben FrantzDale (talk) 13:18, 29 April 2014 (UTC)
- The ramp functions don't exactly go to infinity because for repeated knots the numerator also goes to zero, although the expression is of course still undefined. B's whose support is entirely between repeated knots are identically zero. I don't see any problem with knots repeated thrice or more. Ossi (talk) 14:31, 29 April 2014 (UTC)
- Sure, by l'Hôpital's rule the limit is well-defined as adjacent knots come together. However, coming at this as someone thinking "I think this makes sense, I'll hack it in Python and see if I get pretty curves", it's not obvious what the correct implementation is, since writing what's written mean the fractions can go to infinity which then gets multiplied by either zero or one which gives either nan or infinity. It sounds like I should be able to replace those fractions with a check for the denominator being zero in which case return 1.0 (which will get canceled out by the B. (Although I'm not 100% sure of that: If I replace
- and
- with
- and
- respectively, then when the first would go to 1.0 while the second would go to 0.0...
- I may have to play with it, but either way, the explanation should touch on the Right Way to deal with this singularity. Cheers. —Ben FrantzDale (talk) 13:52, 30 April 2014 (UTC)
- It looks like those have to be symmetric: that is, if you replace the first with a function that returns 1 if the ends are equal, then the second should return 0 if the ends are equal. That is, you can replace the first with:
- if else 1.0
- then replace the second with 1-f(x,t_i,t_j), that seems to work. —Ben FrantzDale (talk) 15:38, 30 April 2014 (UTC)
- I think when the knots coincide, any finite value should produce a correct result, since then the B you are multiplying is identically zero. Ossi (talk) 14:17, 1 May 2014 (UTC)
- Cool. The other issue I ran into in a naive implementation was that (at least with repeated knots at the end of the spline) was that the basis functions all went to zero. That is, if the last knot, k, has value , then equals zero since . Experimentally, it looks like the solution is to close all spans that end at the end (or just to close the last finite span). That is, if then return 1 if (note the second "" rather than just "<".—Ben FrantzDale (talk) 17:01, 1 May 2014 (UTC)
- From The NURBS Book by Piegl and Tiller, when they get 0/0 they evaluate it to zero. They also have a concise algorithm for computing the Ns. —Ben FrantzDale (talk) 13:43, 6 May 2014 (UTC)
- Is the algorithm same as de Boor's algorithm? Ossi (talk) 23:34, 6 May 2014 (UTC)
- I think so. —Ben FrantzDale (talk) 13:06, 16 May 2014 (UTC)
- Is the algorithm same as de Boor's algorithm? Ossi (talk) 23:34, 6 May 2014 (UTC)
- From The NURBS Book by Piegl and Tiller, when they get 0/0 they evaluate it to zero. They also have a concise algorithm for computing the Ns. —Ben FrantzDale (talk) 13:43, 6 May 2014 (UTC)
- Cool. The other issue I ran into in a naive implementation was that (at least with repeated knots at the end of the spline) was that the basis functions all went to zero. That is, if the last knot, k, has value , then equals zero since . Experimentally, it looks like the solution is to close all spans that end at the end (or just to close the last finite span). That is, if then return 1 if (note the second "" rather than just "<".—Ben FrantzDale (talk) 17:01, 1 May 2014 (UTC)
- I think when the knots coincide, any finite value should produce a correct result, since then the B you are multiplying is identically zero. Ossi (talk) 14:17, 1 May 2014 (UTC)
- It looks like those have to be symmetric: that is, if you replace the first with a function that returns 1 if the ends are equal, then the second should return 0 if the ends are equal. That is, you can replace the first with:
- Sure, by l'Hôpital's rule the limit is well-defined as adjacent knots come together. However, coming at this as someone thinking "I think this makes sense, I'll hack it in Python and see if I get pretty curves", it's not obvious what the correct implementation is, since writing what's written mean the fractions can go to infinity which then gets multiplied by either zero or one which gives either nan or infinity. It sounds like I should be able to replace those fractions with a check for the denominator being zero in which case return 1.0 (which will get canceled out by the B. (Although I'm not 100% sure of that: If I replace
- Below are the two key functions from The NURBS Book by Piegl and Tiller, translated into Python. They seem to be well-behaved at double knots and the like. —Ben FrantzDale (talk) 14:26, 16 September 2014 (UTC)
import numpy as np
def FindSpan(p,u,U):
"""
Determine the knot span index
"""
if u < U[0] or u > U[-1]:
raise IndexError("u == {} out of range: [{}, {}]".format(u, U[0], U[-1]))
m = len(U) - 1
n = m - p - 1
assert n + p + 1 == m, "Invalid n. Should be: {} not {}".format(m - p - 1, n)
if u == U[n+1]: return n # Special case
# Do binary search (could use np.searchsorted(U, u, side='right')-1 here)
low = p
high = n+1
mid = (low + high) // 2
while u < U[mid] or u >= U[mid+1]:
if u < U[mid]:
high = mid
else:
low = mid
mid = (low + high) // 2
return mid
def BasisFuns(i,u,p,U):
"""
Compute the nonvanishing basis functions
Algorithm A2.2 on p. 70
"""
N = np.nan * np.ones(p+1)
N[0] = 1.0
left = np.nan * np.ones_like(N)
right = np.nan * np.ones_like(N)
for j in range(1, p+1):
left[j] = u-U[i+1-j]
right[j] = U[i+j]-u
saved = 0.0
for r in range(j):
temp = N[r] / (right[r+1] + left[j-r])
N[r] = saved + right[r+1] * temp
saved = left[j-r] * temp
N[j] = saved
return N
Dubious: number of parametric directions
The article says "Whereas Bézier curves evolve into only one parametric direction, usually called s or u, NURBS surfaces evolve into two parametric directions, called s and t or u and v." This sounds like it's making the distinction between curves and surfaces. But this isn't fundamental to NURBS versus B-splines. Am I misunderstanding? You can certainly take the tensor product of B-splines or Bézier curves to get surfaces. —Ben FrantzDale (talk) 17:28, 7 May 2014 (UTC)
- I think you are right. Ossi (talk) 00:50, 10 May 2014 (UTC)
Lead and "introduction"
The WP:LEAD of this article is basically incomprehensible unless you read the "introduction" first, even though it's basically the same material and the definitions aren't that complicated. I suggest replacing most of the current lead with the material from the section called "introduction" and abolishing the latter. JMP EAX (talk) 11:58, 15 August 2014 (UTC)
Duplication & confusion elsewhere, lack of info here
The much more confused article Bézier spline duplicates some of this, although this (B-spline) article isn't exactly peachy either for it fails to explain how B-splines relate to piecewise/composite Bézier curves. JMP EAX (talk) 15:06, 15 August 2014 (UTC)
- Agreed. There needs to be a combined effort on Bézier spline, Composite Bézier curve, Bézier surface, B-spline, and NURBS. —Ben FrantzDale (talk) 14:39, 16 September 2014 (UTC)
Assessment comment
The comment(s) below were originally left at Talk:B-spline/Comments, and are posted here for posterity. Following several discussions in past years, these subpages are now deprecated. The comments may be irrelevant or outdated; if so, please feel free to remove this section.
Please add useful comments here--Cronholm144 07:26, 24 May 2007 (UTC)
There seems to be a notational inconsistency. Under "Definition", the degree of a spline is defined to be its polynomial degree plus one, whereas under "Examples", the degree is identified with the degree of the polynomial. This makes one suspicious of indexing. —Preceding unsigned comment added by Myblueface (talk • contribs) 13:26, 18 April 2010 (UTC) |
Last edited at 13:26, 18 April 2010 (UTC). Substituted at 08:45, 29 April 2016 (UTC)
Lack of notation explanation in Cardinal Spline section
The Cardinal Spline section uses the function
but that subscript plus symbol is certainly not conventional notation, and needs explaining, or better: this function needs rewriting to a more conventional notation so that the majority of readers can understand it without needing to leave wikipedia to find out what the actual meaning of the notation is. Pomax (talk) 17:41, 23 July 2016 (UTC) — Preceding unsigned comment added by 76.10.187.132 (talk)
Uniqueness of B-splines does not follow from definition
Currently, the Definition section's first paragraph gives a definition of a B-spline. The second paragraph goes on to claim that For any given set of knots, the B-spline is unique, hence the name, B being short for Basis. However, a (non-zero) multiple of a B-spline is again a B-spline for the same knots with the current definition, so uniqueness does not hold. -- 66.253.183.240 (talk) 17:54, 9 October 2016 (UTC)