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: Tue Mar 22, 2022 5:41 am And I feel you're mixing up some things yourself :mrgreen:.
Can you please argument according to my arguments please.

I explained you what makes a function rational. Your argumentation was that e.g. 5*x^2 is a ration function compared to x^2 and this is wrong.
As we agree now what a rational spline is, what makes it non-uniform? The weights.
Here another derivation: https://www.cl.cam.ac.uk/teaching/2000/ ... node5.html

And since you are free to choose the basis function, your are free to choose the knot vector. The forumula is completely independent on the knot vector. The vector is however important to determine the spline propertied (derivatives knot positions etc.).
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 »

In this video they explain it nicely: https://www.youtube.com/watch?v=w-l5R70y6u0
They move the slider for h2, meaning, they change this weight. The changing knot vector is the result. However, as you can see at the beginning of the video, the base N1,3 has the same definition range, but is only changed by a factor. But this in turn results in a change of the definition range for N0,3.

I think it should be more clear now.
User avatar
jnxd
Posts: 951
Joined: Mon Mar 30, 2015 2:30 pm
Contact:

Re: Sketcher: B-Spline pages

Post by jnxd »

Hi @uwestoehr. Just wanted to let you know I'm trying to formulate something coherent about your argument, and I'll probably take a few days before replying, if at all. Replying too early is only taking this conversation nowhere fast.

However, one quick nit-pick before the break.
uwestoehr wrote: Tue Mar 22, 2022 3:37 pm In this video they explain it nicely: https://www.youtube.com/watch?v=w-l5R70y6u0
They move the slider for h2, meaning, they change this weight.
Please note that h2 here is the distance between knots and not a weight of a control point. Note how decreasing h2 brings the curve closer to the control points, whereas increasing weights makes the curve closer to that one control point.
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: 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.
Hello Uwe. Now that we have a bit more time after the release, let's try to get this clarified. I'm still not being too mathematically rigorous here, so excuse the broad strokes.

Thing is, it seems you're mixing up the concepts of "Bezier curves" and "B-Splines". Bernstein polynomials form the basis for Bezier curves only. When weights are applied, we get what is called a rational Bezier curve. The rational part comes from the fact that certain normalization has to be done, as you wrote in the wiki (note the function is now a rational function in the parameter, which is t in the case of the previous link). Uniform or non-uniform does not come into picture yet. That comes into picture for splines.

Now, a spline is a combination of Bezier curves. B-splines are basis functions for a general spline that respect the continuity, but let us set that aside for now, and look at the spline in terms of the bases of the constituent Bezier curves. In that case, the basis functions look something like these (sorry for the transparent background, you can open these in a new tab if they're not clear):
first bezier curve bases
first bezier curve bases
Bernstein_Polynomials_1.png (35.87 KiB) Viewed 1640 times
second bezier curve bases
second bezier curve bases
Bernstein_Polynomials_2.png (37.71 KiB) Viewed 1640 times

In this case, the first curve spans a 0<=t<0.5, and the second spans 0.5<=t<=1.0. We define the functions to be zero outside of their respective ranges. Now, if we consider the pole at t = 0.5 to be the same for both curves, we have 7 poles, and this is equivalent to a cubic spline with a 3-multiplicity knot at t=0.5. However, if we want continuity at higher derivatives, we have to impose more restrictions on these poles. This effectively reduces the number of poles, since one new point dictates two other points at every derivative continuity imposed. I will not go into the details of how, but the lectures we have been discussing can shed some light on that.

Finally, we come to the "non-uniform" part: instead of doing the split at 0.5, if we did the split at, say 0.6 (so the first curve spans a 0<=t<0.6, and the second spans 0.6<=t<=1.0), that is an example of a "non-uniform" spline. I cannot properly explain what difference it makes with the present "broad strokes" explanation, but that is exactly what is being done in this video that you previously shared: https://www.youtube.com/watch?v=w-l5R70y6u0.
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: Fri Jun 24, 2022 9:29 pm Hello Uwe. Now that we have a bit more time after the release
:shock: It is much, much more work than before the release, I get tons of mails and citations in the forum. However, I also have a private life and simply cannot reply to all nor work on all topics.

Here in short, I think your analysis is correct - like in the video. For me the point is, what in the Wiki page is wrong in your opinion and what needs to be changed.

A friend of mine ins a Ph.D. mathematician and I will then ask him to review your suggestions.
User avatar
jnxd
Posts: 951
Joined: Mon Mar 30, 2015 2:30 pm
Contact:

Re: Sketcher: B-Spline pages

Post by jnxd »

uwestoehr wrote: Sat Jun 25, 2022 12:08 pm
jnxd wrote: Fri Jun 24, 2022 9:29 pm Hello Uwe. Now that we have a bit more time after the release
:shock: It is much, much more work than before the release, I get tons of mails and citations in the forum. However, I also have a private life and simply cannot reply to all nor work on all topics.
Sorry, didn't meant to undermine the amount of work you have with that statement, not your personal life. I shouldn't have made assumptions.
uwestoehr wrote: Sat Jun 25, 2022 12:08 pm For me the point is, what in the Wiki page is wrong in your opinion and what needs to be changed.

A friend of mine ins a Ph.D. mathematician and I will then ask him to review your suggestions.
I'll get back to you with a better write-up. I think it is a good idea to simply reference some other more rigorous literature about these topics.
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: Sat Jun 25, 2022 12:08 pm Here in short, I think your analysis is correct - like in the video. For me the point is, what in the Wiki page is wrong in your opinion and what needs to be changed.

A friend of mine ins a Ph.D. mathematician and I will then ask him to review your suggestions.
I have been sitting on an incomplete re-write of the page for 2 months now, so probably it's best to open it up and then try to get the missing pieces filled, either by other people or myself by pressure from other people. I copied the page onto a text file and edited it locally, which is attached. Please let me know if there is an equivalent of a "PR" in the wiki because I don't want to make sweeping changes just like that.
bspline-page.txt
(23.18 KiB) Downloaded 51 times
My main complaint with the page has been the definition of "non uniform" and "rational", which I have explained multiple times in this thread already. I have modified the page in the following way: "Rational B-splines" has been moved to Bezier curves section and renamed to "Rational Bezier Curves"; in it's place .

Once Bezier curves are completely introduced, I introduce the concept of splines, and then B-splines, and then eventually non uniform and rational B-splines. Other splines exist (for example Hermite splines) and I have plans to introduce them into FreeCAD, so I feel it's important to define "spline" and "b-spline" separately.

There are a few other relatively minor details, which I have left as a "TODO" in my document for now.
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 Oct 17, 2022 5:30 pm I have been sitting on an incomplete re-write of the page for 2 months now, so probably it's best to open it up and then try to get the missing pieces filled,
let's do it this way:
- you change the Wiki page directly as you think it is correct. You invested now many hours and I am sure you became a master. Therefore just put it in.
- the Wiki has a the nice timeline feature, so I can ask my math Ph.D. friend to look at both versions and judge (however he is getting a father soon, so I don't know if he will have time)
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 Oct 17, 2022 7:48 pm - ...(however he is getting a father soon, so I don't know if he will have time)
Nice of him to be finally getting adopted :D. Jokes aside I get your point. The way I did the rewrite it'll take me a bit of time to write it over to wiki, but I'll get it done.
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 Oct 17, 2022 7:57 pm Nice of him to be finally getting adopted :D.
Yes, one of the 3 ways to get rich:
- marry a rich woman
- inherit from your parents
- being adopted -> he is a clever guy :D
Post Reply