]> Creatis software - CreaPhase.git/blob - octave_packages/nurbs-1.3.6/nrbtransp.m
Add a useful package (from Source forge) for octave
[CreaPhase.git] / octave_packages / nurbs-1.3.6 / nrbtransp.m
1 function tsrf = nrbtransp(srf)
2
3 % NRBTRANSP: Transpose a NURBS surface, by swapping U and V directions.
4
5 % Calling Sequence:
6
7 %   tsrf = nrbtransp(srf)
8 %
9 % INPUT:
10
11 %   srf         : NURBS surface, see nrbmak.
12 %
13 % OUTPUT:
14
15 %   tsrf        : NURBS surface with U and V diretions transposed.
16
17 % Description:
18
19 %   Utility function that transposes a NURBS surface, by swapping U and
20 %   V directions. NURBS curves cannot be transposed.
21 %
22 %    Copyright (C) 2000 Mark Spink
23 %
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.
28
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.
33 %
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/>.
36
37 if ~iscell(srf.knots)
38   error(' A NURBS curve cannot be transposed.');
39 elseif size(srf.knots,2) == 3
40   error('The transposition of NURBS volumes has not been implemented.');
41 end  
42
43 tsrf = nrbmak(permute(srf.coefs,[1 3 2]), fliplr(srf.knots));
44
45 end
46
47 %!demo
48 %! srf = nrb4surf([0 0 0], [1 0 1], [0 1 1], [1 1 2]);
49 %! nrbplot(srf,[20 5]);
50 %! title('Plane surface and its transposed (translated)')
51 %! hold on
52 %! srf.coefs(3,:,:) = srf.coefs(3,:,:) + 10;
53 %! srf = nrbtransp(srf);
54 %! nrbplot(srf,[20 5]);
55 %! hold off