B-Spline Constraints: Looking for Crowdfunding

Info about new community or project announcements, implemented features, classes, modules or APIs. Might get technical!
PLEASE DO NOT POST HELP REQUESTS OR OTHER DISCUSSIONS HERE!
jnxd
Posts: 662
Joined: Mon Mar 30, 2015 2:30 pm
Contact:

Re: B-Spline Constraints: Looking for Crowdfunding

Post by jnxd »

FUNDING UPDATE: 21 September 2022

There's some steady progress both for funding and coding.

Since the release of the fundraiser, I have received:

Github:
One time: $435
Monthly: $7

Liberapay:
Directly to me: $89 + €155 = ~$244
As part of FreeCAD Liberapay team: $74 + €110 + NZ$156 = ~$276

Additional:
Pledged: $40 + €250

All in all, this amounts to up to ~$1266/$3000 towards this project, assuming it takes 3 months to complete.

CODING UPDATE: 21 September 2022

As I mentioned earlier, programming of the "tangent at knot" constraint is going steadily. However, there's nothing to show right now. I'm just figuring out how to set up the constraint on the "sketch" side (as opposed to the "solver" side, refer to abdullah's document on this topic).
jnxd
Posts: 662
Joined: Mon Mar 30, 2015 2:30 pm
Contact:

Re: B-Spline Constraints: Looking for Crowdfunding

Post by jnxd »

CODING UPDATE: 22 September 2022

This one's just one day after the previous one, but felt necessary because I managed to fix the "tangent at knot" constraint for B-splines.

phpBB [video]


As with the position constraints, this currently only supports non-rational N-splines (so weights should be the same). To make the constraint, select a B-spline, a line and a knot on the B-spline [EDIT 1 October 2022: only the knot and line need to be selected, but also selecting B-spline may be faster].

This one took a good bit of bug-fixing, so intuition says there are still a large amount of bugs left. Please help me find and squash them by testing. As usual, you can build from source or get the snap [EDIT 25 September 2022: this link is recently changed to a new snap].

Known issues:
1. B-spline should be at least C2 continuous at the knot (so for example, a knot on a cubic B-spline with multiplicity 2 won't work). This limit should be C1 since the slope is still continuous at that point.
2. Applying this constraint on a C0 knot (multiplicity = degree) will result in a segmentation fault. This should be simply disallowed. [EDIT 1 October 2022: this now results in a malformed constraint]
3. [EDIT] First/last knots of periodic b-splines are not selectable (hidden behind start/end).
Last edited by jnxd on Sun Oct 02, 2022 10:47 am, edited 6 times in total.
User avatar
Kunda1
Veteran
Posts: 13037
Joined: Thu Jan 05, 2017 9:03 pm

Re: B-Spline Constraints: Looking for Crowdfunding

Post by Kunda1 »

+1 Congrats on the milestone!

FYI, the snap link just links directly to your branch
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
#lowhangingfruit | Use the Source, Luke. | How to Help FreeCAD | How to report FC bugs and features
jnxd
Posts: 662
Joined: Mon Mar 30, 2015 2:30 pm
Contact:

Re: B-Spline Constraints: Looking for Crowdfunding

Post by jnxd »

Kunda1 wrote: Fri Sep 23, 2022 1:16 pm +1 Congrats on the milestone!

FYI, the snap link just links directly to your branch
Oops. Fixing right after typing this message.

EDIT: Just did. I had just interchanged the links.
jnxd
Posts: 662
Joined: Mon Mar 30, 2015 2:30 pm
Contact:

Re: B-Spline Constraints: Looking for Crowdfunding

Post by jnxd »

PLANNING UPDATE: 25 September 2022

I'm still in the process of fixing known issues in the tangent at knot constraint. But I wanted to quickly talk about a case where the constraint does work, yet does not give us the results we need. This in turn can shed some light on what the next steps should be for better B-spline support. NOTE: this post is very much on the technical side.

The case is this: Let's say we want to make a vase with a given maximum and minimum diameter, and say we also constrain the heights where we want these diameters. Let us say the base should be a certain diameter and the side should be C1-continuous at that, and the mouth should have a certain angle. Let's still further say we want the side of the vase to be C2-smooth from the base to mouth. We can make a B-spline like shown below, with knots at those positions, and set tangent to the vertical.
vase-planned-cross-section.png
vase-planned-cross-section.png (14.89 KiB) Viewed 789 times
This is a schematic I drew in Inkscape, but it is possible to represent the side as a Hermite spline, which is just another way to represent a spline, like B-spline is.

Let us also restrict ourselves to non-rational B-splines. So we start with a B-spline and start constraining the knots as described.
vase-base-sketch-with-bspline.png
vase-base-sketch-with-bspline.png (35.73 KiB) Viewed 789 times
Right now, The exact values are not very important (apart from the fact they should work well with each other). We built this and are at the last stage: 2 DOFs left, which will go away when we apply tangent constraint at the free knot (select spline, knot and line and press tangent). However, we see that this doesn't work well (go ahead, try with the following file).
vase-with-knot-tangent-constraints.FCStd
(95.54 KiB) Downloaded 5 times
<technical part begins here>
Now, there are a number of ways this issue can be solved, say by inserting a knot. But let's try a method that does not involve that.

Let's try building something with joining "Bezier Curves" (the value of the minimum diameter is different, but this is the value I prefer and in the previous case if I enter this value the result is horrible).
Screenshot from 2022-09-25 13-42-07.png
Screenshot from 2022-09-25 13-42-07.png (29.89 KiB) Viewed 789 times
vase-with-knot-tangent-constraints-2.FCStd
(79.77 KiB) Downloaded 6 times
Now, provided we choose the right shapes to ensure proper continuity, this gives us a solution to our case. However, this is not complete because we want a B-spline and we have a set of Bezier curves, so let us start joining them. After ensuring the curves are continuous, we have 6 remaining degrees of freedom (compare this with the zero in the first case). Of these, 2 have to be to ensure curvature continuity at the middle knots. I don't really have an answer right now for how to restrict the last four, but I have an idea for two of them.

Basically what might be happening is that the "non-uniform" part of "NURBS" may be coming into picture. Every knot point has a parameter value associated with it (that is, technically, what is called the knot), and the difference between these can change the shape of the spline. If we restrict the first and last knots to be 0 and 1(for scaling), we have the freedom to choose the values at the remaining knots, here 2. There is some precedence to this, for example the centripetal Catmull-Rom splines. Currently the knots are hardcoded, but if we are able to make that as another variable as well, this example could become possible.

This actually also gives one possibility of implementing point-on-B-spline: create a "zero multiplicity knot" constraint (I don't believe such a concept exists, so perhaps a better terminology should be used). This constraint will say that the point should remain on the curve, but the parameter where it sits can change. Then, follow the same routine as with the previous knot constraints, and in theory we are done. I also imagine that the math might be slightly simpler here as compared to the possibility of changing "non-zero multiplicity knots" (I still owe people an explanation of what the math really is :oops: ). If it works it would also be significantly simpler than the previous idea I had, which would involve numerical methods to compute the minimum distance from a the spline and how it changes with change in every relevant variable.

<technical part ends here>

So I think that would be my next step once I finish what I have on my table right now (which may take slightly longer because of IRL stuff). Once knot tangency is completed, I will start on the "curve at parameter" constraint, and look at the possibility to make that parameter itself variable.
Last edited by jnxd on Sun Sep 25, 2022 1:51 pm, edited 2 times in total.
jnxd
Posts: 662
Joined: Mon Mar 30, 2015 2:30 pm
Contact:

Re: B-Spline Constraints: Looking for Crowdfunding

Post by jnxd »

Some better results we obtain for the above example by having the second knot at ~0.19 instead of 0.33, all others remaining equal. This does indicate the usefulness of non-uniform B-splines. For some reason I can't add these files to the above post.
Screenshot from 2022-09-25 16-38-09.png
Screenshot from 2022-09-25 16-38-09.png (37.96 KiB) Viewed 756 times
Attachments
vase-with-knot-tangent-constraints-nonuniform.FCStd
(69.88 KiB) Downloaded 3 times
User avatar
chennes
Veteran
Posts: 2433
Joined: Fri Dec 23, 2016 3:38 pm
Location: Norman, OK, USA
Contact:

Re: B-Spline Constraints: Looking for Crowdfunding

Post by chennes »

Chris Hennes
Pioneer Library System
jnxd
Posts: 662
Joined: Mon Mar 30, 2015 2:30 pm
Contact:

Re: B-Spline Constraints: Looking for Crowdfunding

Post by jnxd »

Great development! Thank you all so much!
User avatar
Kunda1
Veteran
Posts: 13037
Joined: Thu Jan 05, 2017 9:03 pm

Re: B-Spline Constraints: Looking for Crowdfunding

Post by Kunda1 »

woot!
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
#lowhangingfruit | Use the Source, Luke. | How to Help FreeCAD | How to report FC bugs and features
Post Reply