14 Downloads

Updated 14 Mar 2007

No License

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

http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=312&objectType=file

The included files replace the following mex files with the m-file equivalent.

basisfun

bspeval

bspdegelev

bspderiv

bspkntins

findspan

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.

Daniel Claxton (2021). NURBS (https://www.mathworks.com/matlabcentral/fileexchange/14247-nurbs), MATLAB Central File Exchange. Retrieved .

Created with
R2006b

Compatible with any release

**Inspired:**
NURBS Toolbox by D.M. Spink

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!Create scripts with code, output, and formatted text in a single executable document.

Bradley RedlinIs anyone able to explain to me how to avoid the error of an infinite loop in FindSpan?

Jie HuangTo avoid the infinite loop, please make sure that the curve parameter u belongs to knot vector span. @Jeff@Junquan Peng

LiutongThe dependent NURBS Toolbox file has been removed from File Exchange.

Goitom tesfayhow can i use this toolbox any one help.

JeffJunquan Peng, I am also running into the infinite while loop within "findspan.m". Have you found a solution?

Junquan Pengwho knows how to avoid the infinite loop, always show busy.I am glad to hear your responce,thank you!

Junquan PengUniversityExcellent!

MAK PTCH 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);

plot(crv.coefs(1,:),crv.coefs(2,:),'bo')

title('Degree elevation of test curve by 1');

hold on;

plot(crv.coefs(1,:),crv.coefs(2,:),'b--');

% draw nurbs curve

nrbplot(crv,48);

Will be glad to see a quick response

TCHSven 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

crv.knots(1)=0.1;

crv.knots(2)=0.1;

crv.knots(3)=0.1;

crv.knots(end-2)=0.1;

crv.knots(end-1)=0.1;

crv.knots(end)=0.1;

@ forbidden code end

are all forbidden code lines,

crv.knots(4)=0.1;

crv.knots(5)=0.1;

crv.knots(6)=0.1;

... ...

crv.knots(end-5)=0.1;

crv.knots(end-4)=0.1;

crv.knots(end-3)=0.1;

are the permissive code lines. Am I clear ? ? :-]

TCHactually 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. *~*

Matthew SchroederI'm experiencing the same problem as Sven. Any idea what might be causing this?

SvenIs 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?

Luigi GiaccariHello The Toolbox is not working for CATIA, any idea?

Evgeny PrUPD:

http://www.phys.au.dk/~jvn/MatLab.htm

Evgeny PrHello!

Where can I get C-implementation (mex-functions) of this toolbox? All links not working.

Thanks.

Michele MartinelliHello everyone.

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:

-d=3 "degree"

- 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.

Thanks.

--

Michele Martinelli

Michele Martinellido I need spline toolbox to run this?

and is there any tutorial or something like that to learn how to use it?

THANKS

Ocean YangGreat work!

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.

Eric TrautmannI found a copy of the NURBS toolbox (for 2006b) here:

http://webscripts.softpedia.com/script/Scientific-Engineering-Ruby/Mathematics/nurbs-33691.html

Does anyone know if there's a newer version of this?

Di XiaoCannot find the original NURBS Toolbox

haidiThe link to the original NURBS library no longer works.

http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=312&objectType=file

Could anyone could upload it again? Thanks

JesperI'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:

for i=0:d

N(i+1) = N(i+1)*c(4,tmp1+i);

end

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));

to

[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.

sheethalI 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.

Richard ligreat job! Thanks

Martin LoThis 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!

Andre LutzVery good!

But there is a mistake in nrbcoons:

If you add

hold on

nrbplot(crv1,48);

nrbplot(crv2,48);

nrbplot(crv3,48);

nrbplot(crv4,48);

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));

Van BrackinTHANK 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.

Aslak GrinstedI was thinking of doing just what you have done only last friday.. Excellent to find that it already has been done. thanks