LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

B-Spline Fit Control Points - What is the function to generate a curve base on the control points?

Hello,

I'm using the b-spline fit function to fit a unique curve.  For a first order fit, I can use the control points as parts of a piecewise function.  I'd like to use a second order fit, but I'm not sure what function to use the control points with in order to generate the citted curve.  Can anyone shed any light on this?

 

Thanks,
Bill

0 Kudos
Message 1 of 6
(5,683 Views)
Are you using 2009?
0 Kudos
Message 2 of 6
(5,665 Views)

Yep, I'm using 2009.

I found a couple websites explaining the b-spline fit routine to some degree.  Wolfram has an equation for the Curve C(t) which seems to be what I'm looking for but I don't quite understand the notation...I've been looking into it on and off during "free" time.  Ibiblio.org also has a good explanation.

The labview routine outputs the control points used, but not the knot vector.  In the labview bspline fit algorithms case, is the knot vector composed of the x coordinates of the control points?

I'd like to be able to generate the spline fit curve that the labview function outputs using the control points and the order of the polynomial.  I think I'll be able to get it after banging my head against it for a while, but I figured that I'd post it here in case anyone had some tips.

Thanks for looking!

0 Kudos
Message 3 of 6
(5,655 Views)

Hey Bill,

 

After looking at the B-spline function in LabVIEW, there is an input called degree which seems to be the order of the B-spline function. The help file states degree specifies the order of polynomials that form the B-spline curve and fit to the data set. The default value is 3.  It seems that if you set this to 2nd order, it would solve this issue for you. I have the link to the help file about it below:

 

http://zone.ni.com/reference/en-XX/help/371361F-01/gmath/bspline_fit/

 

JimS


Jim St
National Instruments
RF Product Support Engineer
0 Kudos
Message 4 of 6
(5,642 Views)

Thanks Jim

 

That's actually the workaround I ended up using in the mean time.  With the 2nd order polynomial, the control point output is simply the x and y coordinates of the piece-wise fit to the curve.  What I'd like to do is use a 3rd order polynomial fit (it works with the data much better), and be able to calculate intermediate points using only the control points.  The issue I was running into is what function to run the control points through in order to get the x,y coordinates of the fitted line. 
I think I've just about got the theory but I need to get it into code.

 

This is the equation for finding the point from one of the links above.  Pi is one of our control points, and P(t) is the desired point on the fitted line between control points.  Ni,k(t) is our basis spline (function is below, again from ibiblio.org).  These functions spell out how to calculate our poly fit furve with only the control points, but I've messed up implementing it somewhere along the lines.  I'll spend some more time on it and post some code snippets for anyone curious

 

 

P(t) = ∑i=0,n Ni,k(t) Pi

 

Ni,k(t) = Ni,k-1(t) (t - ti)/(ti+k-1 - ti) + Ni+1,k-1(t) (ti+k - t)/(ti+k - ti+1) ,
    Ni,1 = {1   if   ti <= t <= ti+1 ,    0   otherwise }

 

Message 5 of 6
(5,634 Views)

Hello Bill,

 

In order to implement this equation, I would create two arrays (N and P) that have length of N. From here you can use the Add Array Elements under Programming >> Numeric. As for creating the N function, I don't know the equation well enough in order to implement this. If this requires some complex pieces of code, it might be better suited for the MathScipt node which I have added a link below for.

 

MathScript Node Help

http://zone.ni.com/reference/en-XX/help/371361F-01/gmath/mathscript_node/

 

JimS


Jim St
National Instruments
RF Product Support Engineer
0 Kudos
Message 6 of 6
(5,603 Views)