The NURBS toolbox, created by Mark Spink, is a very useful tool. However, some of the routines were written in C. This is not necessarily a bad thing as long as you know how to compile them to mex files for your machine. If you don't want to mess with mex files, or you want to be able to edit the code and don't know anything about C, I've rewritten the C code in MATLAB. You can find the original toolbox at
The included files replace the following mex files with the m-file equivalent.
In addition, I've included the translated C code in the comments, line for line.
This does not include every file in the NURBS toolbox, just the mex files. You will still want to download the toolbox and replace the mex files with the included files.
To avoid the infinite loop, please make sure that the curve parameter u belongs to knot vector span. @Jeff@Junquan Peng
The dependent NURBS Toolbox file has been removed from File Exchange.
how can i use this toolbox any one help.
Junquan Peng, I am also running into the infinite while loop within "findspan.m". Have you found a solution?
who knows how to avoid the infinite loop, always show busy.I am glad to hear your responce,thank you!
TCH Sven and Matthew, The Knot vector should have the property that if the NURB is of order n then the 1st n+1 should be 0 and the last n+1 should be 1.0
I am trying to implement using the cartesian coordinate as the control points and i am also facing the same problem of infinite loop
here is my code
x and y are control points
u = [0.0,0.0,0.0,0.0,0.10,.20,.30,.40,.50,.60,.70,.80,.90,1.0,1.0,1.0,1.0];
crv = nrbmak([x';y'],u);
title('Degree elevation of test curve by 1');
% draw nurbs curve
Will be glad to see a quick response
Sven and Matthew, I think I have got a solution to avoid the infinite loop but I don't know why:
NEVER modify the first three 0's and the last three 1's points, they have to be 0's and 1's.
in the democurve script, the last try of the demonstration intend to touch the third zero (which will cause the inifinite loop) so in the democurve.m file the code:
% @forbidden code start
@ forbidden code end
are all forbidden code lines,
are the permissive code lines. Am I clear ? ? :-]
actually the original findspan function seems to be stuck as well. the pure matlab version of the package is also stuck and dropped into the infinite loop, for the time I have got no ideas about the phenomenon. *~*
I'm experiencing the same problem as Sven. Any idea what might be causing this?
Is anyone else having fundamental problems with these .m files?
I've gotten the original toolbox, remove all mex/dll files from it, then put in the .m files here.
Anything (such as democurve, nrbplot, etc) gets stuck in an infinite loop inside findspan.m. Does anyone else get this?
I've tried twice downloading/running, and ensured that no other implementation shadows any nurbs toolbox files... Any ideas?
Hello The Toolbox is not working for CATIA, any idea?
Where can I get C-implementation (mex-functions) of this toolbox? All links not working.
I'm trying to learn to use the NURBS toolbox.
I need it to interpolate freeform 2Dcurves obtained through a simulation, not for surfaces.
I downloaded the converted NURBS toolbox from this page.
But I have some questions and doubts:
-are those files all what i need to generate NURBS?
- I expected to have the possibility to give a weight to each control point, but there isn't, or I didn't get how.
-i tried to generate a nurb with this inputs:
- c=[0 2 4 6 8; 0 6 2.5 6 6] "this is the control point matrix and I intended it as a two row matrix where the first one has the parametric coordinate and the second one the value of the point at that coordinate in a cartesian bi-dimensional space_Am I correct?"
- K= [0 0 0 1 2 3 3 3]; "Non uniform Knot vector".
-u= linspace(0,8); "parametric points where i want to evaluate the NURB"
I'm trying but it is not working. Would you be so kind to tell me what I m missing or I m doing wrong.
Then I see in the comments that there are comments about some functions that i don't have like nrbplot and nrbeval.
I am missing something.
Sorry for bothering but I really need to learn to use Nurbs with matlab.
do I need spline toolbox to run this?
and is there any tutorial or something like that to learn how to use it?
However, I find a problem in computing the first derivatives for B-spline curves/surfaces with inner multiple-knots, e.g., [0 0 0 0.5 0.5 1 1 1].
When I evaluate the first derivatives at u=0.5, it seems wrong.
I found a copy of the NURBS toolbox (for 2006b) here:
Does anyone know if there's a newer version of this?
Cannot find the original NURBS Toolbox
The link to the original NURBS library no longer works.
Could anyone could upload it again? Thanks
I've had the same problems with the weights and fixed it in this way:
In bspeval.m between line 45 and 46, I've inserted:
N(i+1) = N(i+1)*c(4,tmp1+i);
N = N / sum(N);
This code applies the weights, but there is still a problem with nrbplot.m, but this is fixed by changing line 101 from
p = nrbeval(nurbs,linspace(0.0,1.0,subd));
[p, ggg] = nrbeval(nurbs,linspace(0.0,1.0,subd));
Where ggg is some variable, which isnt used afterwards.
Besides these small errors, this code is great. Maybe there are more error, but this works for me for now.
I am finding several problems with this code:
1. When we increase the weights, the curve should get pulled toward the control point. But, it is moving away from the curve and vice versa
2. democurve.m hangs and MATLAB crashes. Just running it without any modification does so.
great job! Thanks
This is great! Thank you so much!!! I just wasted 3 hours trying to compile the c files to mex files. The Matlab mex function is very buggy. Thanks so much!
But there is a mistake in nrbcoons:
If you add
before the nrbcoons command in democoons, you will see that the coons surface does not match the curves.
Fix it with replacing line 82 in nrbcoons with:
t = nrb4surf(u1.coefs(:,1), u2.coefs(:,1), u1.coefs(:,end), u2.coefs(:,end));
THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU
I was having a conniption when I couldn't get Mark Spinks' programs to run compiled.
I was thinking of doing just what you have done only last friday.. Excellent to find that it already has been done. thanks