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 in the following picture:
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 shown here 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.