Sketcher: Bezier curves

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
abdullah
Posts: 1607
Joined: Sun May 04, 2014 3:16 pm

Re: Sketcher: Bezier curves

Postby abdullah » Sun Feb 12, 2017 9:46 pm

For no reason I was obfuscated that the bspline comb shall be centripetal, instead of centrifugal. Not even Chris_G's screenshot, or MicroElly's comment made me realize that actually, it should be done the other way around...

well, thanks guys for bearing with me. I fixed it:

centripetal_combs.png
centripetal_combs.png (52.9 KiB) Viewed 253 times
triplus
Posts: 4993
Joined: Mon Dec 12, 2011 4:45 pm

Re: Sketcher: Bezier curves

Postby triplus » Sun Feb 12, 2017 10:08 pm

Looking good.
abdullah
Posts: 1607
Joined: Sun May 04, 2014 3:16 pm

Re: Sketcher: Bezier curves

Postby abdullah » Sun Feb 12, 2017 11:13 pm

Today's experiment is the bspline converter:

bspline_converter.png
bspline_converter.png (29.02 KiB) Viewed 244 times


Not sure what for it will be useful, but you wanted it ;)

A side problem appears because of the different determination of the show/restore unused internal alignment geometry behaviour. If it were like in the other geometric shapes, that circle would not have converted into an aberration... but enforcing constraints on it that should not be there creates a problem.

Some time for reflexion. Do you think such a conversion to NURB is useful? What do you think you could do with it?

I need some user input. As I am undecided whether to scrap this NURB convertion feature, or change the implementation of the show/restore internal alignment geometry...
triplus
Posts: 4993
Joined: Mon Dec 12, 2011 4:45 pm

Re: Sketcher: Bezier curves

Postby triplus » Sun Feb 12, 2017 11:19 pm

What you implemented is curvature comb with bounding curve. Without this feature it would be really hard to inspect the curvature.

P.S. It makes perfect sense and thanks for adding the feature.
User avatar
yorik
Site Admin
Posts: 8661
Joined: Tue Feb 17, 2009 9:16 pm
Location: São Paulo, Brazil
Contact:

Re: Sketcher: Bezier curves

Postby yorik » Sun Feb 12, 2017 11:31 pm

FreeCAD is getting the most gorgeous curve editor out there!
emills2
Posts: 202
Joined: Tue Apr 28, 2015 11:23 pm

Re: Sketcher: Bezier curves

Postby emills2 » Mon Feb 13, 2017 4:17 am

SInce Werner mentioned combs external to the sketcher, just wanted to point out that Chris_G's macro, as written way back, could be assigned outside of the sketch, and still show during sketch editing. I haven't updated it since last august.

Bezier primary Surface Volume 68-01.png
Bezier primary Surface Volume 68-01.png (209.04 KiB) Viewed 227 times


It's really handy outside of sketcher because you can use it on 3D curves. there's nothing wrong with having the option directly in the sketcher too.

The use case is to manually adjust the control points across a joint to maintain curvature flow:
if the combs touch at the end, you have G2 continuity
if the comb tangents are aligned, you have G3 continuity (more better)

The physical world impact is highlight flow: if you look at a modern car, the reflections have no 'breaks' in them. The tangents join, the curvature joins, and the derivative of curvature with respect to arclength joins.

This addition to sketcher looks awesome! Thanks Abdullah. I hope someone makes a windows build soon!
Last edited by emills2 on Mon Feb 13, 2017 4:54 am, edited 1 time in total.
emills2
Posts: 202
Joined: Tue Apr 28, 2015 11:23 pm

Re: Sketcher: Bezier curves

Postby emills2 » Mon Feb 13, 2017 4:37 am

abdullah wrote:Today's experiment is the bspline converter:

Not sure what for it will be useful, but you wanted it ;)


NURBS surfaces in FreeCAD and basically every CAD package use the tensor product scheme, which is a bi-directional curve scheme. And all that means is that the surfaces have two main directions, typically called u and v. the knot vector and order CANNOT change along one parameter.

so if you want to have a cubic on the left side and a straight line on the right side, before you can sweep over, you will have to raise the order of the line to match cubic.

if you have a quadratic of 10 points on the left and a cubic of 4 points on the right, first you have to raise the quadratic to cubic, which will add knots and control points. now that they have the same order, you have to force them to have the same knot vector! so you insert every knot from one into the other and vice versa. Every time you insert a knot, all the control points shift to accommodate it (if you want the curve to stay the same, that is).

in my case, i always grab the nurbs of an arc or ellipse directly from the sketch object, raise the degree to 3 and now i can use it right alongside my other cubic bezier. If i want to use in a 6 point cubic curve or a 6X6 cubic surface, or a 6X4 cubic surface, i then insert he knots 0.3333 and 0.6666

The upshot is that we will often want to raise degrees and insert knot into curves without changing the way they currently look.
wmayer
Site Admin
Posts: 11342
Joined: Thu Feb 19, 2009 10:32 am

Re: Sketcher: Bezier curves

Postby wmayer » Mon Feb 13, 2017 9:46 am

Some time for reflexion. Do you think such a conversion to NURB is useful? What do you think you could do with it?

This will be useful. I just have pushed a commit to master to convert an arbitrary curve to a B-Spline or NURBS. The default implementation of toNurbs does the same as toBSpline but for the conics it can be re-implemented to return a real NURBS.

Since we don't have a GUI tool to change the knot vector this would be a good way to bring a real NURBS of a circle into a sketch.
User avatar
microelly2
Posts: 2441
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

Re: Sketcher: Bezier curves

Postby microelly2 » Mon Feb 13, 2017 6:14 pm

I have created coincident triples of poles to get hard edges for my pad.
Is it possible to force a real edge creation on padding for this case?

For one edge I can use the starting point of the bspline but for the other not.
Attachments
spline_edge.fcstd
(9.94 KiB) Downloaded 2 times
bp_367.png
bp_367.png (17 KiB) Viewed 138 times
emills2
Posts: 202
Joined: Tue Apr 28, 2015 11:23 pm

Re: Sketcher: Bezier curves

Postby emills2 » Mon Feb 13, 2017 7:07 pm

microelly2 wrote:I have created coincident triples of poles to get hard edges for my pad.
Is it possible to force a real edge creation on padding for this case?

For one edge I can use the starting point of the bspline but for the other not.


I don't know the full rationale perfectly, but i remember reading that this is generally recommended against.

The preferred method is to raise the multiplicity of the knot at that location. Each multiplicity reduces continuity by one. When multplicity reach the order, you get continuity 0. A hard corner.