1 function srf = nrbruled (crv1, crv2)
3 % NRBRULED: Construct a ruled surface between two NURBS curves.
7 % srf = nrbruled(crv1, crv2)
11 % crv1 : First NURBS curve, see nrbmak.
13 % crv2 : Second NURBS curve, see nrbmak.
17 % srf : Ruled NURBS surface.
21 % Constructs a ruled surface between two NURBS curves. The ruled surface is
22 % ruled along the V direction.
26 % Construct a ruled surface between a semicircle and a straight line.
28 % cir = nrbcirc(1,[0 0 0],0,pi);
29 % line = nrbline([-1 0.5 1],[1 0.5 1]);
30 % srf = nrbruled(cir,line);
31 % nrbplot(srf,[20 20]);
33 % Copyright (C) 2000 Mark Spink
35 % This program is free software: you can redistribute it and/or modify
36 % it under the terms of the GNU General Public License as published by
37 % the Free Software Foundation, either version 2 of the License, or
38 % (at your option) any later version.
40 % This program is distributed in the hope that it will be useful,
41 % but WITHOUT ANY WARRANTY; without even the implied warranty of
42 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
43 % GNU General Public License for more details.
45 % You should have received a copy of the GNU General Public License
46 % along with this program. If not, see <http://www.gnu.org/licenses/>.
48 if (iscell(crv1.knots) || iscell(crv2.knots))
49 error ('Both NURBS must be curves');
52 % ensure both curves have a common degree
53 d = max ([crv1.order, crv2.order]);
54 crv1 = nrbdegelev (crv1, d - crv1.order);
55 crv2 = nrbdegelev (crv2, d - crv2.order);
57 % merge the knot vectors, to obtain a common knot vector
60 ku = unique ([k1 k2]);
65 i1 = length (find (k1 == ku(i)));
66 i2 = length (find (k2 == ku(i)));
68 ka = [ka ku(i)*ones(1,m-i1)];
69 kb = [kb ku(i)*ones(1,m-i2)];
71 crv1 = nrbkntins (crv1, ka);
72 crv2 = nrbkntins (crv2, kb);
74 coefs(:,:,1) = crv1.coefs;
75 coefs(:,:,2) = crv2.coefs;
76 srf = nrbmak (coefs, {crv1.knots, [0 0 1 1]});
81 %! pnts = [0.5 1.5 4.5 3.0 7.5 6.0 8.5;
82 %! 3.0 5.5 5.5 1.5 1.5 4.0 4.5;
83 %! 0.0 0.0 0.0 0.0 0.0 0.0 0.0];
84 %! crv1 = nrbmak (pnts,[0 0 0 1/4 1/2 3/4 3/4 1 1 1]);
85 %! crv2 = nrbtform (nrbcirc (4,[4.5;0],pi,0.0),vectrans([0.0 4.0 -4.0]));
86 %! srf = nrbruled (crv1,crv2);
87 %! nrbplot (srf,[40 20]);
88 %! title ('Ruled surface construction from two NURBS curves.');