Curves workbench

Post here for help on using FreeCAD's graphical user interface (GUI).
Forum rules
and Helpful information
IMPORTANT: Please click here and read this first, before asking for help

Also, be nice to others! Read the FreeCAD code of conduct!
drmacro
Veteran
Posts: 8978
Joined: Sun Mar 02, 2014 4:35 pm

Re: Curves workbench

Post by drmacro »

drmacro wrote: Wed Nov 09, 2022 7:37 pm I was able to complete the surfaces and convert to para solid.

But, Surface and Surface004 fail geo check. Any tips on getting them corrected?
I would like to understand, if possible, why 3 out of 4 of these surfaces are valid. (3 out 4 counting around the, not the bottom and two circles.)
Star Trek II: The Wrath of Khan: Spock: "...His pattern indicates two-dimensional thinking."
User avatar
Vincent B
Veteran
Posts: 4731
Joined: Sun Apr 05, 2015 9:02 am
Location: La Rochelle, France

Re: Curves workbench

Post by Vincent B »

using parametric curve.
...
maybe one day this macro will be embedded in Curves Wb? :D
Attachments
sinus.FCStd
(25.17 KiB) Downloaded 21 times
Capture.JPG
Capture.JPG (17.98 KiB) Viewed 1309 times
bleber
Posts: 259
Joined: Thu Jun 30, 2016 5:12 pm

Re: Curves workbench

Post by bleber »

My goal is obtain periodic b-spline whiout matematics and parametric.

I can control and maybe can obtain the correct tangency of the first-last knot with parameter "t" (tangent to currant view, I aply with lateral right view)vin edit mode and it apears correct. But there are some other parameter of the knot that controls other things that I not have access.
Screenshot_20221113_032041.png
Screenshot_20221113_032041.png (17.97 KiB) Viewed 1264 times
Screenshot_20221113_032744-1.png
Screenshot_20221113_032744-1.png (29.52 KiB) Viewed 1264 times
Screenshot_20221113_033141-2.png
Screenshot_20221113_033141-2.png (15.04 KiB) Viewed 1264 times
User avatar
hammax
Veteran
Posts: 1991
Joined: Thu Jan 19, 2017 5:03 pm
Location: Ammersee DE

Re: Curves workbench

Post by hammax »

... i/insert and s/snap work good,
but t/tangent doesn't
and activating p/periodic destroys it
Attachments
pBSpl_2.PNG
pBSpl_2.PNG (29.07 KiB) Viewed 1236 times
pBSpl_2.FCStd
FC.20.1
(12.73 KiB) Downloaded 21 times
bleber
Posts: 259
Joined: Thu Jun 30, 2016 5:12 pm

Re: Curves workbench

Post by bleber »

A screen captures and file.

1 the original curve
2 After apply periodic
3 Side view
4 Apply tangent with view direction (if wrong tangent, try the other side), see the curve symmetry seems correct on these side.
5 result, the tangency appear seems correct, but definitely not.
Screenshot_20221113_103150-2.png
Screenshot_20221113_103150-2.png (136.61 KiB) Viewed 1209 times
Attachments
knot_problem.FCStd
(12.6 KiB) Downloaded 25 times
User avatar
Chris_G
Veteran
Posts: 2596
Joined: Tue Dec 31, 2013 4:10 pm
Location: France
Contact:

Re: Curves workbench

Post by Chris_G »

bleber wrote: Fri Nov 11, 2022 11:10 pm How to make periodic regular b-spline like the screenshot.
I can build the basic shape but the end and the star joint is not regular as other points.
I have found a workaround.
Select the vertexes you want to interpolate and run the following script :

Code: Select all

"""Part.BSplineCurve.interpolate() doesn't generate fully periodic curves.
The start/end point has a multiplicity 2 while inner points have a multiplicity 1.
This macro is a workaround.
It duplicates the points we want to interpolate, in order to generate a multi-turn curve
and extracts a one turn BSpline curve in the middle.
"""

import FreeCAD
import FreeCADGui
import Part


def parameterization(points, fac, force_closed=False):
    # Computes a knot Sequence for a set of points
    # fac (0-1) : parameterization factor
    # fac=0 -> Uniform / fac=0.5 -> Centripetal / fac=1.0 -> Chord-Length
    pts = points[:]
    if force_closed and pts[0].distanceToPoint(pts[-1]) > 1e-7:  # we need to add the first point as the end point
        pts.append(pts[0])
    params = [0]
    for i in range(1, len(pts)):
        p = pts[i] - pts[i - 1]
        if isinstance(p, FreeCAD.Vector):
            le = p.Length
        else:
            le = p.length()
        pl = pow(le, fac)
        params.append(params[-1] + pl)
    return params


# get the selected vertexes
vl = []
sel = Gui.Selection.getSelectionEx()
for so in sel:
    svl = []
    for sub in so.SubObjects:
        if isinstance(sub, Part.Vertex):
            svl.append(sub)
    if svl:
        vl.extend(svl)
        svl = []
    else:
        vl.extend(so.Object.Shape.Vertexes)

# extend the list of points
pts = [v.Point for v in vl]
nbp = len(pts)
n = 1
if nbp <= 4:
    n = 2

npts = pts
npts.extend(pts * (2 * n))
nbnp = len(npts)

# interpolate the extended list of points
bs = Part.BSplineCurve()
print(len(npts))
pars = parameterization(npts, 0.5, True)
print(len(npts))
print(len(pars))
bs.interpolate(Points=npts, Parameters=pars, PeriodicFlag=True)

# extract a one turn BSpline curve in the middle
offset = n * nbp
npoles = bs.getPoles()[offset:-offset - 1]
nmults = bs.getMultiplicities()[offset:-offset]
nknots = bs.getKnots()[offset:-offset]
nbs = Part.BSplineCurve()
nbs.buildFromPolesMultsKnots(npoles, nmults, nknots, True, 3)
Part.show(nbs.toShape())

bleber
Posts: 259
Joined: Thu Jun 30, 2016 5:12 pm

Re: Curves workbench

Post by bleber »

Chris_G wrote: Sun Nov 13, 2022 10:18 am Select the vertexes you want to interpolate and run the following script :
Thank you to make the script.
The scrips works very well !!, but loses the parametric essence.
In the he curve workbench I can attach the curve knots to vertex that I can manipulate. To adjust the curve shape.
User avatar
Chris_G
Veteran
Posts: 2596
Joined: Tue Dec 31, 2013 4:10 pm
Location: France
Contact:

Re: Curves workbench

Post by Chris_G »

bleber wrote: Sun Nov 13, 2022 3:45 pm The scrips works very well !!, but loses the parametric essence.
With latest commit of Curves WB (v0.5.14), interpolate tool should generate fully periodic curves.
bleber
Posts: 259
Joined: Thu Jun 30, 2016 5:12 pm

Re: Curves workbench

Post by bleber »

Chris_G, many thanks for your help, patience and response to my problem.
Final result (full parametric).
Screenshot_20221113_220724.png
Screenshot_20221113_220724.png (578.92 KiB) Viewed 1050 times
Attachments
b-spline periodic.FCStd
(834.85 KiB) Downloaded 33 times
User avatar
hammax
Veteran
Posts: 1991
Joined: Thu Jan 19, 2017 5:03 pm
Location: Ammersee DE

Re: Curves workbench

Post by hammax »

... I still have problems applying tangency at the "periodic_point".
The space curve is not fully symmetric.
Using a brute force design, to fix the "knot point" gives still some kind of distortion.
The mathematical curve is exact (parametric only by means of geometric construction ??)

pBSpl_4.PNG
pBSpl_4.PNG (46.72 KiB) Viewed 960 times
Attachments
pBSpl.FCStd
FC.20.1
(115.7 KiB) Downloaded 26 times
Post Reply