As a class assignment, we were required to write a program that calculated the basis functions and also plot the resulting b-spline given a set of x, y, z points. I have done this and the program works.(adsbygoogle = window.adsbygoogle || []).push({});

I would, however, like to develop this further for b-spline surface generation (not a class assignment). I know that I'm very close to figuring this out. If you would like to see the b-spline curve for the given points, in line 9 of Bsplinesurface.m make sure the order array has only one value and that line 30 is uncommented and line 32 and 33 is commented.

The b-spline surface:

S(u,v)=Ʃ(j=0,m)Ʃ(i=0,n)P_{ij}N_{ik}(u)N_{jl}(v)

S is of order k in the u direction and order l in the v direction.

The first summation is from j=0 to m. The second summation is from i=0 to n.

m and n = number of control points - 1

My understanding of the equation:

For each control point I calculate the basis function value for u for the last order using the recursive program I've developed (this works perfectly). I multiply this matrix by the control points. This results in a matrix where each row contains the x or y or z point for that basis function for each column u. I then sum this matrix column wise to arrive at an array containing a row of x or y or z points for each column u. I then take this array and multiply it by the basis function value matrix for v, of which the column are summed again.

Note:

The basis function value matrix for v is found the same way as the one for u except that I use the appropriate knot vector and order. My program returns these knot vectors as a check to make sure that when I change the order, the u and v knot vectors change.

What my code does is calculate N(u), then multiplies this by the x, y, and z array. Then sums up the columns and returns the result as the x, y and z points for the b-spline curve. Then N(v) is calculated (hence the loop where the function basisfuncbackup resides).

After this I'm not sure what to do. I know that there's a NURBS toolbox at mathworks but I would like to make this code work. Attached are the two .m files. If anyone could point me in the right direction it would be greatly appreciated.

Explanation of the code:

Bsplinesurface.m

lines 4-6: define my control points

line 9: define the order for u and v respectively

lines 13-26: calculate the basis function values for u and v (using their corresponding orders) and return this matrix. Also calculate and return the u and v knot vectors. Calculate the b-spline x,y,z points.

lines 32-40: plot the surface

basisfuncbackup:

Description of code is commented in file.

**Physics Forums - The Fusion of Science and Community**

Join Physics Forums Today!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# MATLAB program for B-spline surface

Loading...

Similar Threads - MATLAB program spline | Date |
---|---|

How to program this in Matlab | Feb 28, 2018 |

Does anyone had this plotting problem with MATLAB? | Dec 23, 2017 |

How do I extract elements of a random matrix masked by a circle with its center at A(15,26) | Sep 15, 2016 |

MATLAB how to automatically read a number of files | Oct 29, 2015 |

What is program is better mathematica or matlab? | Jun 14, 2015 |

**Physics Forums - The Fusion of Science and Community**