No BSD License  

Highlights from
NURBS

4.5

4.5 | 8 ratings Rate this file 46 Downloads (last 30 days) File Size: 7.67 KB File ID: #14247

NURBS

by Daniel Claxton

 

12 Mar 2007 (Updated 14 Mar 2007)

Converted NURBS toolbox

| Watch this File

File Information
Description

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.

MATLAB release MATLAB 7.3 (R2006b)
Other requirements NURBS Toolbox http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=312&objectType=file
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (20)
20 Mar 2007 Aslak Grinsted

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

01 Jun 2007 Van Brackin

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.

03 Dec 2007 Andre Lutz

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

29 Apr 2008 Martin Lo

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!

17 Jul 2008 Richard li

great job! Thanks

28 Mar 2009 sheethal

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.

14 Apr 2009 Jesper

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

24 Aug 2009 haidi

The 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

01 Sep 2009 Di Xiao

Cannot find the original NURBS Toolbox

07 Oct 2009 Eric Trautmann

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

06 Nov 2009 Ocean Yang

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

15 Dec 2009 Michele Martinelli

do I need spline toolbox to run this?
and is there any tutorial or something like that to learn how to use it?

THANKS

17 Dec 2009 Michele Martinelli

Hello 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

27 Jun 2010 Evgeny Pr

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

Thanks.

27 Jun 2010 Evgeny Pr

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

23 Dec 2010 Luigi Giaccari

Hello The Toolbox is not working for CATIA, any idea?

26 Mar 2011 Sven Holcombe

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?

24 Jun 2011 Matthew Schroeder

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

31 Jan 2012 TCH

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

31 Jan 2012 TCH

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
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 ? ? :-]

Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
approximation Daniel Claxton 22 Oct 2008 09:04:02
interpolation Daniel Claxton 22 Oct 2008 09:04:02
non uniform ration bsplines Daniel Claxton 22 Oct 2008 09:04:02
bspline Daniel Claxton 22 Oct 2008 09:04:02
nurbs Daniel Claxton 22 Oct 2008 09:04:02

Contact us at files@mathworks.com