Question

I might need to visualize a B-Spline ( http://en.wikipedia.org/wiki/B-spline ) in .NET. I do not where to start. Is there any easy way or library to do it? I would prefer to do it in Silverlight but WPF and Win Forms is also fine. I imagine the software as a coordinate system with some control points that you can add, delete or move around causing the spline to be repainted. Note that I lack the mathematical background. I found some methods in GDI+ that seem to be intended for drawing splines but I am not sure if these are B-Splines.

Any advice would be appreciated. Libraries, code, links to guides or general suggestions are welcome.

Was it helpful?

Solution

I've written a very quick program quite awhile ago for some scientific code that utilized splines. In particular, these splines are NURBS (non-uniform rational basis splines). This is the most generalized form of the spline. All other splines are special cases of this type. The knot vector is used to generate the spline, and the recursive Cox de Boor algorithm is used to calculate the value of a point. The C# code is very poor, it was something I threw together quickly to solve a problem and before I was a more polished developer. If you google Cox de Boor, you will find many pages that discuss the theoretical underpinning of splines. Beware, most of them have some sort of error (some of them in their discussion of the knot vector)

http://stochfit.svn.sourceforge.net/viewvc/stochfit/trunk/NURBs/

I don't recall all of the mathematical details, but will try to help if I know the answer. Good luck, this was very difficult knowledge to acquire on my part!

EDIT - I believe you get a B-spline from these methods if you set the weight for a given point to 1.

OTHER TIPS

A B-Spline is a solution to a problem, maybe you should describe your problem and ask what the best solution is. GDI+ contains DrawBezier and DrawCurve for drawing splines, that might be a good point to start. Something like this:

Point p1 = new Point(10, 10);
Point p2 = new Point(50, 10);
Point p3 = new Point(10, 50);
Point p4 = new Point(50, 50);
e.Graphics.DrawBezier(Pens.Blue, p1, p2, p3, p4);

p2 and p3 are not part of the curve but 'control points', move them to see the effect.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top