MATLAB program for B-spline surface

In summary, the conversation was about a program that calculates basis functions and plots b-spline curves given a set of points. The speaker also mentioned wanting to develop it further for b-spline surface generation and seeking guidance on how to do so. They also mentioned some issues with the program and asked for help. The expert explains that B-spline surfaces are machines that generate Bezier surface patches and suggests a paper for a simple method of extracting these patches. The speaker then asks for help with non-uniform b-spline representation and the expert suggests starting a new thread for that question.
  • #1
roldy
237
2
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.

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)PijNik(u)Njl(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.
 

Attachments

  • basisfuncbackup.txt
    3.3 KB · Views: 1,693
  • Bsplinesurface.txt
    1.3 KB · Views: 1,811
Physics news on Phys.org
  • #2
hi
the program of bspline dosent work
 
  • #3
Hello,
I would like to know if you have already solved this problem posted here as I have the same me too. thank you very much.
 
Last edited:
  • #5
Hi
please explain these program, and program of surface has problem, please help me because i need it
thanks
 
  • #6
Hi
please explain these program, and program of surface has problem, please help me because i need it
thanks
 
  • #7
mmmmm

mavadat said:
hi
the program of bspline dosent work

hi
please i need program for b-spline surface
can you help me
thank you
 
  • #8
What is it that you're trying to do with the B-spline surfaces: just render them or do some computations with them?

B-spline curves are nothing more than machines that generate Bezier curves with a certain degree of continuity, which is determined primarily by the multiplicity of knots in the knot vector. Thus, B-spline surfaces can be seen as machines that generate Bezier surface patches with a certain degree of continuity between them in the u- and v-parameter directions.

A simple way to interact with a B-spline surface is by extracting the Bezier surface patches that make up the B-spline surface. The paper "Isogeometric finite element data structures based on Bézier extraction of NURBS" deals with a simple method of getting those Bezier elements out of the B-spline definition without having to muck about with the recursive nature of the basis functions.
 
  • #9
What is it that you're trying to do with the B-spline surfaces: just render them or do some computations with them?

B-spline curves are nothing more than machines that generate Bezier curves with a certain degree of continuity, which is determined primarily by the multiplicity of knots in the knot vector. Thus, B-spline surfaces can be seen as machines that generate Bezier surface patches with a certain degree of continuity between them in the u- and v-parameter directions.

A simple way to interact with a B-spline surface is by extracting the Bezier surface patches that make up the B-spline surface. The paper "Isogeometric finite element data structures based on Bézier extraction of NURBS" deals with a simple method of getting those Bezier elements out of the B-spline definition without having to muck about with the recursive nature of the basis functions.
 
  • #10
thank you for explain
But I have a problem in non-uniform b-spline representation
can you help me in this field ?
 
  • #11
Sure, but make another thread with your question. This one needs to retire.
 

Related to MATLAB program for B-spline surface

1. What is a B-spline surface?

A B-spline surface is a mathematical representation of a three-dimensional surface composed of multiple B-spline curves. It is commonly used in computer graphics and CAD software for creating smooth and flexible surfaces.

2. What is the purpose of using MATLAB for B-spline surfaces?

MATLAB is a powerful programming language and software environment that allows for efficient and accurate calculations and visualization of B-spline surfaces. It has built-in functions for creating and manipulating B-spline curves and surfaces, making it a popular choice for researchers and engineers.

3. How do I create a B-spline surface in MATLAB?

To create a B-spline surface in MATLAB, you first need to define the control points, knot vectors, and degree of the surface. Then, you can use the built-in function "bsurf" to generate the surface using these inputs. You can also use other functions such as "nrbmak" and "nrbplot" for more flexibility and customization.

4. Can I change the shape or control points of a B-spline surface in MATLAB?

Yes, you can easily change the shape and control points of a B-spline surface in MATLAB by modifying the input parameters or using functions such as "nrbdeform" to deform the surface. This allows for quick and easy experimentation and adjustments to achieve the desired surface shape.

5. Are there any limitations to using MATLAB for B-spline surfaces?

While MATLAB is a powerful tool for creating B-spline surfaces, it does have some limitations. For example, it may not be suitable for very complex surfaces or situations where high precision is required. It is important to carefully consider the specific requirements and limitations of your project before using MATLAB for B-spline surfaces.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
373
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
8
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
18
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
979
Back
Top