[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Help-gsl] Using GSL to draw a 2D B-Spline path using unevenly spaced po
From: |
Michael Petrie |
Subject: |
[Help-gsl] Using GSL to draw a 2D B-Spline path using unevenly spaced points |
Date: |
Fri, 13 Jun 2014 10:56:36 +1200 |
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
- [Help-gsl] Using GSL to draw a 2D B-Spline path using unevenly spaced points,
Michael Petrie <=