0

I'm doing a small drawing-test program and I'm drawing curves.

While it has been pretty easy with Beziers, I'm stuck with Splines. Like with first, when I click in the window, I add a knot, but honestly I don't get how to draw my curve from here: how do I compute values like I do with Beziers (see below)?

///> Coefficient calc in algorithm
///> dT Sampled in [0,1]
///> bla bla bla
vdCoeff[0] = ( 1 - dT ) * ( 1 - dT ) * ( 1 - dT );
vdCoeff[1] = dT *( 1 - dT ) * ( 1 - dT );
vdCoeff[2] = dT * dT * ( 1 - dT );
vdCoeff[3] = dT * dT * dT;
///> bla bla bla
IssamTP
  • 2,408
  • 1
  • 25
  • 48
  • You've left some assumptions in your question: we have no idea which language you're using, or which flavour of spline you're talking about. Also usually a good idea not to leave code that does not contribute to your problem in what you're showing, like the "blah" lines. No reasons to include those. – Mike 'Pomax' Kamermans Nov 08 '15 at 14:27
  • 1
    I'm using C++, but I don't care, you can answer me in Java or "pseudocode". I'm looking for BSplines. – IssamTP Nov 08 '15 at 14:52
  • in that case, [you forgot to search](http://stackoverflow.com/help/how-to-ask). http://stackoverflow.com/questions/25379422/b-spline-curves's got you covered, as do several other answers for other languages. (and if you did search SO first, and found several potential questions, but none of them addressed your problem, please explain that in your question) – Mike 'Pomax' Kamermans Nov 08 '15 at 15:09
  • Google "Cox DeBoor algorithm" for B-spline curve evaluation. – fang Nov 09 '15 at 01:07
  • I have implemented my own B-Spline/NURBS library: [TinySpline](https://github.com/retuxx/tinyspline). It provides spline evaluation using DeBoor's algorithm. If you want to implement it on you own, have a look at the function `ts_bspline_evaluate`. Maybe it helps you to understand what you need to do. Furthermore, you will find a very good explanation of DeBoor's algorithm at: http://www.cs.mtu.edu/~shene/COURSES/cs3621/NOTES/spline/B-spline/de-Boor.html – Marcel Nov 15 '15 at 14:20

0 Answers0