help-gsl
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-gsl] Using GSL to draw a 2D B-Spline path using unevenly space


From: Michael Petrie
Subject: Re: [Help-gsl] Using GSL to draw a 2D B-Spline path using unevenly spaced points
Date: Mon, 16 Jun 2014 09:15:03 +1200

Hi Patrick,

Thank you very much for your answer. Knowing that I could use uniform
breakpoints has gone someway to increasing my understanding of B-Splines.

I think I'll give openNURBS a go first, as it seems more suited to what I'm
trying to achieve.

Many thanks,

Michael




2014-06-13 19:28 GMT+12:00 Patrick Alken <address@hidden>:

> The basic idea behind breakpoints is you want to have a sufficient
> amount of data in between your breakpoints to properly constrain the
> B-spline coefficients during the least-squares inversion. Also if you
> know your function changes rapidly in some regions and not others, you
> can add more knots to those areas.
>
> If you have lots of (scattered) data in the whole interval, you can
> start with uniform knots and see how it goes. If, however, your function
> is sparsely sampled in some places you'll want to pick your breakpoints
> to have enough data in each interval.
>
> GSL does not currently support 2D B-splines. For 2D scattered data
> interpolation, one method which isn't too difficult to code is radial
> basis functions (see Numerical Recipes for an introduction). I know
> someone is working on a GSL extension for RBFs but its not ready yet.
>
> Patrick
>
> On 06/13/2014 12:56 AM, Michael Petrie wrote:
> > Hi, my name's Michael, and I'm new to the mailing list, so forgive me if
> > I'm asking this question in the wrong place.
> >
> > I'm trying to using the GNU Scientific Library (GSL) to draw a smooth
> path
> > from A to B. I'm using an API that returns a small number (8 in this
> case)
> > of irregularly spaced points (in red), that you can see picture [1].
> >
> > The purple points represent the points that I would like to see returned
> > from GSL.
> >
> > Firstly, is this kind of 2D B-Spline shape obtainable by using GSL? I
> don't
> > know much about B-Splines, let alone 2D B-Splines. I was able to get the
> > B-Splines example at link [2] running and creating a smooth .ps file
> > without problem, but that example uses uniform breakpoints with the
> > following code:
> >
> >     /* use uniform breakpoints on [0, 15] */
> >     gsl_bspline_knots_uniform(0.0, 15.0, bw);
> >
> > In my case, given that the data I'm given is erratic and not evenly
> spaced,
> > would I have to use non-uniform knots? I tried using
> `gsl_bspline_knots()`,
> > in order to use non uniform breakpoints within the following test code,
> but
> > I'm really not sure if this is the right direction or not.
> >
> >     #define NCOEFFS 8 // not sure what this number should be - number of
> > data points?
> >     #define NBREAK   (NCOEFFS - 2)
> >     const size_t nbreak = NBREAK;
> >
> >     int main (void) {
> >
> >         // (example code)...
> >
> >         gsl_vector *non_uniform = gsl_vector_alloc(nbreak);
> >
> >         // create some random breakpoint values
> >         for (i=0; i<nbreak; i++) {
> >             double val = gsl_ran_gaussian(r, 2.0);
> >             printf("val: %f\n", val);
> >             gsl_vector_set(non_uniform, i, val);
> >         }
> >
> >         gsl_bspline_knots(non_uniform, bw);
> >
> >         // (more example code)...
> >     }
> >
> > Further more, how would I translate the above example for drawing
> B-Splines
> > in a 2D x/y coordinate space? If GNU Scientific Library is not suitable
> for
> > this, could someone make a recommendation for a more suitable C/C++
> library?
> >
> > Any help or pointers in the direction would be much appreciated.
> >
> >   [1]: http://i.stack.imgur.com/mpxbx.png
> >   [2]:
> >
> http://www.gnu.org/software/gsl/manual/html_node/Example-programs-for-B_002dsplines.html#Example-programs-for-B_002dsplines
> >
> > PS, I have also asked this question at Stack Overflow too:
> >
> http://stackoverflow.com/questions/24194909/using-gnu-scientific-library-gsl-to-draw-a-2d-b-spline-path-using-unevenly-spa
> >
>
>
>


-- 
Michael Petrie
Mobile Developer
+64 21 022 99121
address@hidden


*Get the STQRY *www.stqry.com


reply via email to

[Prev in Thread] Current Thread [Next in Thread]