Tomas, That's exactly I was after, thanks!
Kaj On Sunday, March 20, 2016 at 6:55:19 PM UTC+2, Tomas Lycken wrote: > > I tried googling for “parametric splines” but didn’t end up with a concise > definition of what they are. If B-splines fit your needs (and it seems from > the SciPy documentation that it might do), maybe Interpolations.jl > <https://github.com/tlycken/Interpolations.jl> would be useful enough? > The API is a little different, but I think this does what you’re after: > > using Interpolations > > t = 0:.1:.9 > x = sin(2π*t) > y = cos(2π*t) > A = hcat(x,y) > > itp = scale(interpolate(A, (BSpline(Cubic(Periodic())), NoInterp()), > OnGrid()), t, 1:2) > > tfine = 0:.01:1 > xs, ys = [itp[t,1] for t in tfine], [itp[t,2] for t in tfine] > > using Gadfly > plot(layer(x=x,y=y,Geom.point),layer(x=xs,y=ys,Geom.path)) > > Results on my machine: > > > <https://lh3.googleusercontent.com/-caXHox7rTE4/Vu7V6Ad2ePI/AAAAAAAABIE/j22VyECSoGkeGaIQaXX_kNOgIzY-FR0Mg/s1600/parametric-spline.png> > > // T > > On Sunday, March 20, 2016 at 3:04:12 AM UTC+1, Kyle Barbary wrote: > > Hi Kaj, >> >> A pull request adding a wrapper for this to Dierckx.jl would be most >> welcome. This would be a matter of reading the docstring for the parcur >> function here >> <https://github.com/kbarbary/Dierckx.jl/blob/master/deps/src/ddierckx/parcur.f> >> >> and then writing a wrapper function that sets up the arguments correctly >> and calls the Fortran function with ccall. There are a lot of examples >> in Dierckx.jl. It’s a bit tedious but mostly straight forward. Fortunately >> (for me anyway) knowing Fortran is not a requirement. I usually consult the >> relevant scipy.interpolate wrapper (e.g., this one for splprep >> <https://github.com/scipy/scipy/blob/05dc7b8b0662c9c973203b36044458ca35084833/scipy/interpolate/fitpack.py#L107>) >> >> to see how they handled things, and look at the tests in that package as >> well. >> >> You can construct an array of vectors by prepending the element type, >> which in your example would be Vector{Float64}. For example: >> >> julia> a = [1., 2.]; >> >> julia> b = [3., 4.]; >> >> julia> Vector{Float64}[a, b] >> 2-element Array{Array{Float64,1},1}: >> [1.0,2.0] >> [3.0,4.0] >> >> The plan for Julia 0.5, is that you won’t need to prepend the element >> type: just [a, b] will do. >> >> By the way, collect is often not necessary. For example: >> >> julia> t = 0.0:0.1:0.5 >> 0.0:0.1:0.5 >> >> julia> sin(2*pi*t) >> 6-element Array{Float64,1}: >> 0.0 >> 0.587785 >> 0.951057 >> 0.951057 >> 0.587785 >> 1.22465e-16 >> >> Best, >> — Kyle >> >> >> On Sat, Mar 19, 2016 at 3:24 PM, Kaj Wiik <kaj....@gmail.com> wrote: >> >>> Replying to myself...sorry. >>> >>> It seems that the easiest way for now is to call SciPy: >>> >>> using PyCall >>> @pyimport scipy.interpolate as interpolate >>> t = collect(0:.1:1) >>> x = sin(2π*t) >>> y = cos(2π*t) >>> p = Array[] >>> push!(p, x) >>> push!(p, y) >>> tck, u = interpolate.splprep(p, s=0) >>> unew = collect(0:0.01:1) >>> out = interpolate.splev(unew, tck) >>> >>> using Winston >>> plot(x, y, "o", out[1], out[2], "-r") >>> >>> BTW, is there an easier way to create an array of vectors? >>> >>> Cheers, >>> Kaj >>> >>> >>> On Saturday, March 19, 2016 at 4:13:19 PM UTC+2, Kaj Wiik wrote: >>>> >>>> >>>> Is there a Julia package that implements parametric splines? >>>> >>>> I noticed that the Dierckx Fortran library has an implementation but >>>> the corresponding Julia package does not does not have bindings for it. >>>> >>>> Thanks, >>>> Kaj >>>> >>> >> >