There is also an in depth answer by Vinicius Miranda on Stack Overflow if anyone's interested for future reference.
http://stackoverflow.com/questions/24194909/using-gnu-scientific-library-gsl-to-draw-a-2d-b-spline-path-using-unevenly-spa Best, Michael 2014-06-16 9:31 GMT+12:00 Michael Petrie <[email protected]>: > Hi Foivos, > > Thank you very much for your in depth reply. It's great to have someone > who has some experience in this area point me in the right direction. Also, > the links you have provided look very helpful. It's clear that I need to do > some more learning before being able to exactly what I want with GSL. In > the mean time, I'll give openNURBS a go - it does seem more suited to what > I would like to achieve. > > Many thanks, > > Michael > > > 2014-06-13 19:47 GMT+12:00 Foivos Diakogiannis < > [email protected]>: > > Hi Michael and all, >> >> I am not a GSL software engineer, but I've been using heavily BSplines >> and GSL for scientific purposes. >> To your questions: >> >> It is possible to create any geometric shape with BSplines. The >> implementation in GSL has some limitations (with regards to knot >> distributions, multiplicity of knots, fixed multiplicity in first/last >> knots etc) but - at least for scientific applications - I have found all >> that I need. So your geometric shape (purple points) it is feasible to be >> constructed with a 2D BSpline representation. Unfortunately I don't think >> you can reconstruct the purple line with only the red points - >> statistically speaking you have very little information. By the way for 2D >> BSplines you'll have to do it "by hand" so you'll really need to study the >> theory of BSplines. Check this link for more info a d references therein: >> http://www.cs.mtu.edu/~shene/COURSES/cs3621/NOTES/ >> >> As for the appropriate knot distribution for this, in my experience there >> is no single choice and there is ongoing research int this direction. The >> best method seems to be be implementing Genetic Algorithms in order to find >> the best distribution of knots for a particular data set (am writing a >> codel for this, slowly ...) . See >> http://www.sciencedirect.com/science/article/pii/S001044850300006X >> >> If you need BSplines for scientific purposes I think GSL is great!! You >> may need to tweak it a bit, see the .h and .c files of the distribution, >> they have a lot of comments and you'll understand more the theory of >> BSplines. If you want for computer design and graphics, BSplines are not >> the standard any more, you'll have to pass to NURBS, and a nice library is >> this: >> >> http://www.rhino3d.com/opennurbs >> >> in general with a search for nurbs you'll find many more things for >> computer design. >> >> >> Hope the above help, >> Cheers, >> Foivos >> >> >> >> On Fri, Jun 13, 2014 at 6:56 AM, Michael Petrie <[email protected] >> > 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 >>> [email protected] >>> >>> >>> *Get the STQRY *www.stqry.com >>> >> >> > > > -- > Michael Petrie > Mobile Developer > +64 21 022 99121 > [email protected] > > > *Get the STQRY *www.stqry.com > -- Michael Petrie Mobile Developer +64 21 022 99121 [email protected] *Get the STQRY *www.stqry.com
