Sign up ×
Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute:

I have a B-Spline curve. I have all the knots, and the x,y coordinates of the Control Points.

I need to convert the B-Spline curve into Bezier curves.

My end goal is to be able to draw the shape on an html5 canvas element. The B-Spline is coming from a dxf file which doesn't support Beziers, while a canvas only supports Beziers.

I've found several articles which attempt to explain the process, however they are quite a bit over my head and really seem to be very theory intensive. I really need an example or step by step help.

Here's what I've found: (Explains B-Splines),(Converting to Beziers),(Javascript Example)

The last link is nice because it contains actual code, however it doesn't seem to take into account the weight assigned by the nodes. I think this is kind of important as it seems to influence whether the curve passes through a control point.

I can share my Nodes or Control Points if that would be useful. If someone would point me to a step-by-step procedure or help me with some psuedo(or actual)code, I would be so grateful.

share|improve this question
    
It would be helpful if you posted some of the information you have about the control points. For example, are your points [x, y], [x, y, w], [xw, yw, zw, w], or something else? Just post a small example of everything that defines a spline, that would help a lot. – tfinniga Jul 19 '13 at 10:23

2 Answers 2

I wrote a simple Javascript implementation of Boehm's algorithm for cubic B-Splines a while back. It's a fairly straightforward implementation involving polar values, described here in section 6.3: Computer Aided Geometric Design- Sederberg

If you're just interested in the implementation, I've linked the classes I wrote here: bsplines.js

share|improve this answer
5  
The link to your bsplines.js is no longer working. Any chance you could reinstate it? – pancake Feb 3 '14 at 5:22

This could be helpful - https://github.com/Tagussan/BSpline

My project has moved on and I no longer need it, but this seems to be a pretty useful way to feed control points and have a curve drawn.

share|improve this answer
    
Also see cardinal splines for a simple way to draw smooth curves – K3N Apr 23 at 17:28
    
@TimSum The referenced GitHub project seems to render splines using raster technique. I suspect it is not converting to Bézier curve. I am still looking for a solution for me too. – Igor Kondrasovas Sep 28 at 10:45

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.