1 function rnrb = nrbreverse(nrb)
3 % NRBREVERSE: Reverse the evaluation direction of a NURBS curve or surface.
7 % rnrb = nrbreverse(nrb);
11 % nrb : NURBS data structure, see nrbmak.
15 % rnrb : Reversed NURBS.
19 % Utility function to reverse the evaluation direction of a NURBS
22 % Copyright (C) 2000 Mark Spink
24 % This program is free software: you can redistribute it and/or modify
25 % it under the terms of the GNU General Public License as published by
26 % the Free Software Foundation, either version 2 of the License, or
27 % (at your option) any later version.
29 % This program is distributed in the hope that it will be useful,
30 % but WITHOUT ANY WARRANTY; without even the implied warranty of
31 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
32 % GNU General Public License for more details.
34 % You should have received a copy of the GNU General Public License
35 % along with this program. If not, see <http://www.gnu.org/licenses/>.
38 error('Incorrect number of input arguments');
42 if size(nrb.knots,2) == 3
43 error('The function nrbreverse is not yet ready for volumes')
45 % reverse a NURBS surface
46 coefs = nrb.coefs(:,:,end:-1:1);
47 rnrb = nrbmak(coefs(:,end:-1:1,:), {1.0-fliplr(nrb.knots{1}),...
48 1.0-fliplr(nrb.knots{2})});
53 % reverse a NURBS curve
54 rnrb = nrbmak(fliplr(nrb.coefs), 1.0-fliplr(nrb.knots));
61 %! pnts = [0.5 1.5 3.0 7.5 8.5;
62 %! 3.0 5.5 1.5 4.0 4.5;
63 %! 0.0 0.0 0.0 0.0 0.0];
64 %! crv1 = nrbmak(pnts,[0 0 0 1/2 3/4 1 1 1]);
65 %! crv2 = nrbreverse(crv1);
66 %! fprintf('Knots of the original curve\n')
68 %! fprintf('Knots of the reversed curve\n')
70 %! fprintf('Control points of the original curve\n')
71 %! disp(crv1.coefs(1:2,:))
72 %! fprintf('Control points of the reversed curve\n')
73 %! disp(crv2.coefs(1:2,:))
77 %! title('The curve and its reverse are the same')