Sketcher: B-Spline pages

Discussions about the wiki documentation of FreeCAD and its translation.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
User avatar
uwestoehr
Veteran
Posts: 4961
Joined: Sun Jan 27, 2019 3:21 am
Location: Germany
Contact:

Re: Sketcher: B-Spline pages

Post by uwestoehr »

jnxd wrote: Mon Mar 21, 2022 9:57 pm I do not have an authoritative book with me to give an exact definition, but there are multiple places that imply this:

In Wikipedia B-Spline Properties section
I think I understand now the confusion. Non-uniform B-spline can but must not have equal-length base functions. As I explained in my previous post with the image, it is clear that just the weight alone makes it non-uniforum, independent of the knot vector.

For NURBS however, there is a definition: https://en.wikipedia.org/wiki/B-spline#NURBS and it does not tell anything about the knot vector. You can use a base as you like (the base consists of B-Splines), you only have to introduce weights. So your are free in your implementation on what splines you use as base for NURBS. I cannot see a definition where the base of NURBS are defined. It seems that different programs create NURBS in different way, however I am no expert in this regards.
User avatar
jnxd
Posts: 951
Joined: Mon Mar 30, 2015 2:30 pm
Contact:

Re: Sketcher: B-Spline pages

Post by jnxd »

My latest (or last) project: B-spline Construction Project.
User avatar
jnxd
Posts: 951
Joined: Mon Mar 30, 2015 2:30 pm
Contact:

Re: Sketcher: B-Spline pages

Post by jnxd »

uwestoehr wrote: Mon Mar 21, 2022 10:15 pm As I explained in my previous post with the image, it is clear that just the weight alone makes it non-uniforum, independent of the knot vector.
It's the other way round: the knot vector alone makes it non-uniform, independent of weights. The weights alone make it rational, independent of the knot vector.
uwestoehr wrote: Mon Mar 21, 2022 10:15 pm For NURBS however, there is a definition: https://en.wikipedia.org/wiki/B-spline#NURBS and it does not tell anything about the knot vector.
It does: non-uniform rational b-spline implies that both the knot spacings and weights can be different. However I do see that the wikipedia text here is wrong (or at least appears to be from the WPI and OCC doc) in saying that just removing the weights makes it a "simple" b-spline. This does place me at a disadvantage in this little argument we're having since I have already cited wikipedia from somewhere else :?.
My latest (or last) project: B-spline Construction Project.
User avatar
uwestoehr
Veteran
Posts: 4961
Joined: Sun Jan 27, 2019 3:21 am
Location: Germany
Contact:

Re: Sketcher: B-Spline pages

Post by uwestoehr »

jnxd wrote: Mon Mar 21, 2022 10:39 pm
uwestoehr wrote: Mon Mar 21, 2022 10:15 pm As I explained in my previous post with the image, it is clear that just the weight alone makes it non-uniforum, independent of the knot vector.
It's the other way round: the knot vector alone makes it non-uniform, independent of weights. The weights alone make it rational, independent of the knot vector.
You are ignoring my example with the image in my Wiki page. Where do you see a changed knot vector? Remember: the knot vector is the definition interval of the different used base functions.
And why does a factor like the weight makes something rational?
jnxd wrote: Mon Mar 21, 2022 10:39 pm
uwestoehr wrote: Mon Mar 21, 2022 10:15 pm For NURBS however, there is a definition: https://en.wikipedia.org/wiki/B-spline#NURBS and it does not tell anything about the knot vector.
It does: non-uniform rational b-spline implies that both the knot spacings and weights can be different.
But this is what I wrote. Looking just at the definition, noting is said about the base functions. Neither what splines you use as base nor about the definition interval. All the definition says is that there are weights making it non-uniform and there is a fraction making it a rational function.
jnxd wrote: Mon Mar 21, 2022 10:39 pm However I do see that the wikipedia text here is wrong (or at least appears to be from the WPI and OCC doc) in saying that just removing the weights makes it a "simple" b-spline.
But this is correct. If all weights are equal, the fraction vanishes and you end up with a normal B-spline.
User avatar
jnxd
Posts: 951
Joined: Mon Mar 30, 2015 2:30 pm
Contact:

Re: Sketcher: B-Spline pages

Post by jnxd »

uwestoehr wrote: Mon Mar 21, 2022 11:15 pm You are ignoring my example with the image in my Wiki page. Where do you see a changed knot vector? Remember: the knot vector is the definition interval of the different used base functions.
And why does a factor like the weight makes something rational?
If you are talking about the gif where you change weights, that's still a rational but uniform b-spline. We do not have a functionality to change the knot vector, but you can do a certain exercise:
1) make a cubic spline with at least two b-splines. Do not change any weights.
2) insert a knot somewhere in the middle of a segment. Note that now we still have a cubic b-spline with curvature continuity throughout. The knot vector will look like (0, 0.25, 0.5, 1).
3) create a bspline with exactly the same poles (just keep clicking on the old poles one after another). The knot vector will look like (0, 0.33, 0.67, 1).

You'lll see that the curves are both different. The first curve is a non-uniform b-spline, while the second is a uniform b-spline with the same poles and weights. They both have the same "remain within bounding box" property however much you change the poles.
Looking just at the definition, noting is said about the base functions.
I have already said that this definition is wrong, or incomplete at best. I have provided the best resources I can find to back this up (especially the bsplines.org one).
My latest (or last) project: B-spline Construction Project.
User avatar
uwestoehr
Veteran
Posts: 4961
Joined: Sun Jan 27, 2019 3:21 am
Location: Germany
Contact:

Re: Sketcher: B-Spline pages

Post by uwestoehr »

jnxd wrote: Tue Mar 22, 2022 12:02 am If you are talking about the gif where you change weights,
You confuse me. Do you see there an orange line I was referring to? I mean this image:
https://wiki.freecadweb.org/File:Bernst ... omials.svg
Apply there only a weight of 10 for the second base function, the yellow one. What do you get as result? - no longer a straight line but almost the yellow curve.
jnxd wrote: Tue Mar 22, 2022 12:02 am 1) make a cubic spline with at least two b-splines. Do not change any weights.
2) insert a knot somewhere in the middle of a segment. Note that now we still have a cubic b-spline with curvature continuity throughout. The knot vector will look like (0, 0.25, 0.5, 1).
3) create a bspline with exactly the same poles (just keep clicking on the old poles one after another). The knot vector will look like (0, 0.33, 0.67, 1).
Sure because you changed the definition range of the base functions by adding the knot. This must be the case to fulfill your will to have a knot at the position you like.
in 3) you get equally distanced base function definition ranges because this is the default method splines are created.
jnxd wrote: Tue Mar 22, 2022 12:02 am I have already said that this definition is wrong, or incomplete at best. I have provided the best resources I can find to back this up (especially the bsplines.org one).
What does your definition says about the basis functions? What order must they have, what are in turn their base functions? Are these Bernstein polynoms? I don't see there a definition about this.
User avatar
jnxd
Posts: 951
Joined: Mon Mar 30, 2015 2:30 pm
Contact:

Re: Sketcher: B-Spline pages

Post by jnxd »

uwestoehr wrote: Tue Mar 22, 2022 1:14 am You confuse me. Do you see there an orange line I was referring to? I mean this image:
https://wiki.freecadweb.org/File:Bernst ... omials.svg
Apply there only a weight of 10 for the second base function, the yellow one. What do you get as result? - no longer a straight line but almost the yellow curve.
OK looking at Bernstein polynomials, it seems they are relevant to just Bezier curves, especially because they are polynomials throughout the domain. B-splines are inherently piecewise polynomial. In fact, in the video itself the basis functions are different than the Bernstein polynomials: note that none of the Bernstein polynomials are zero in the range (0, max_param) (i.e. both ends excluded), but some of the basis functions in the video are. This will be true even if you try to make a plot of the Bernstein polynomials with order 5 (6 polynomials).

Coming back to moving the weight of any basis function (in your case second), whatever changes you do will give a rational Bezier curve, as opposed to a non-uniform B-spline.
uwestoehr wrote: Tue Mar 22, 2022 1:14 am What does your definition says about the basis functions? What order must they have, what are in turn their base functions? Are these Bernstein polynoms? I don't see there a definition about this.
Not entirely certain of this, but you can get an idea of a basis function in this image: https://en.wikipedia.org/wiki/Non-unifo ... struct.svg. Note how it is different than what it would be if the knots were equally spaced (in this case {0,1,2,3}).
My latest (or last) project: B-spline Construction Project.
User avatar
jnxd
Posts: 951
Joined: Mon Mar 30, 2015 2:30 pm
Contact:

Re: Sketcher: B-Spline pages

Post by jnxd »

uwestoehr wrote: Hi again.
I came across this video from the same MOOC on non-uniform b-splines: https://www.youtube.com/watch?v=w-l5R70y6u0 (note there is no mention of "weight": I imagine this is covered in another video in that series). Hopefully this may shed some light on the basis functions.
My latest (or last) project: B-spline Construction Project.
User avatar
uwestoehr
Veteran
Posts: 4961
Joined: Sun Jan 27, 2019 3:21 am
Location: Germany
Contact:

Re: Sketcher: B-Spline pages

Post by uwestoehr »

jnxd wrote: Tue Mar 22, 2022 2:47 am OK looking at Bernstein polynomials, it seems they are relevant to just Bezier curves,
Sorry, I really don't get your point. You mix up things all the time and I still don't see where you want to go.
B-splines are "just" base splines, you can use a suitable base. And that is what I meant with there is no definition telling you what base function to use. And no matter what base function you use, setting a different weight to one of them of course distorts the resulting curve. And since you can choose your base functions, you can choose their definition ranges and thus the knot vector
jnxd wrote: Tue Mar 22, 2022 2:47 am Coming back to moving the weight of any basis function (in your case second), whatever changes you do will give a rational Bezier curve, as opposed to a non-uniform B-spline.
Again, who says a weighted-base spline is uniform? And who says a weighted-base spline is "rational"?
https://en.wikipedia.org/wiki/Rational_function
So to have a rational function, you need a fraction. And as you see in the NURBS formula, there is a fraction. OK. And what makes this rational function non-niform? The weights, because when you use equal weights in the formula, your get a simple spline.

And what exactly is now the issue?
User avatar
jnxd
Posts: 951
Joined: Mon Mar 30, 2015 2:30 pm
Contact:

Re: Sketcher: B-Spline pages

Post by jnxd »

uwestoehr wrote: Tue Mar 22, 2022 4:36 am Sorry, I really don't get your point. You mix up things all the time and I still don't see where you want to go.
And I feel you're mixing up some things yourself :mrgreen:. I really think it'd help to have some third party input, by someone better versed with splines than us.
My latest (or last) project: B-spline Construction Project.
Post Reply