]> Creatis software - CreaPhase.git/blob - octave_packages/nurbs-1.3.6/nrbtestsrf.m
Add a useful package (from Source forge) for octave
[CreaPhase.git] / octave_packages / nurbs-1.3.6 / nrbtestsrf.m
1 function srf = nrbtestsrf
2 % NRBTESTSRF: Constructs a simple test surface.
3 %
4 %    Copyright (C) 2000 Mark Spink
5 %
6 %    This program is free software: you can redistribute it and/or modify
7 %    it under the terms of the GNU General Public License as published by
8 %    the Free Software Foundation, either version 2 of the License, or
9 %    (at your option) any later version.
10
11 %    This program is distributed in the hope that it will be useful,
12 %    but WITHOUT ANY WARRANTY; without even the implied warranty of
13 %    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 %    GNU General Public License for more details.
15 %
16 %    You should have received a copy of the GNU General Public License
17 %    along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
19 % allocate multi-dimensional array of control points
20 pnts = zeros(3,5,5);
21
22 % define a grid of control points
23 % in this case a regular grid of u,v points
24 % pnts(3,u,v)
25 %
26
27 pnts(:,:,1) = [ 0.0  3.0  5.0  8.0 10.0;     % w*x
28                 0.0  0.0  0.0  0.0  0.0;     % w*y
29                 2.0  2.0  7.0  7.0  8.0];    % w*z
30
31 pnts(:,:,2) = [ 0.0  3.0  5.0  8.0 10.0;
32                 3.0  3.0  3.0  3.0  3.0;
33                 0.0  0.0  5.0  5.0  7.0];
34
35 pnts(:,:,3) = [ 0.0  3.0  5.0  8.0 10.0;
36                 5.0  5.0  5.0  5.0  5.0;
37                 0.0  0.0  5.0  5.0  7.0];
38
39 pnts(:,:,4) = [ 0.0  3.0  5.0  8.0 10.0;
40                 8.0  8.0  8.0  8.0  8.0;
41                 5.0  5.0  8.0  8.0 10.0];
42
43 pnts(:,:,5) = [ 0.0  3.0  5.0  8.0 10.0;
44                10.0 10.0 10.0 10.0 10.0;
45                 5.0  5.0  8.0  8.0 10.0];
46
47 % knots
48 knots{1} = [0 0 0 1/3 2/3 1 1 1]; % knots along u
49 knots{2} = [0 0 0 1/3 2/3 1 1 1]; % knots along v
50
51 % make and draw nurbs surface
52 srf = nrbmak(pnts,knots);
53
54 end
55
56 %!demo
57 %! srf = nrbtestsrf;
58 %! nrbplot(srf,[20 30])
59 %! title('Test surface')
60 %! hold off
61