]> Creatis software - CreaPhase.git/blob - octave_packages/nurbs-1.3.6/nrb4surf.m
Add a useful package (from Source forge) for octave
[CreaPhase.git] / octave_packages / nurbs-1.3.6 / nrb4surf.m
1 function srf = nrb4surf(p11,p12,p21,p22)
2
3 % NRB4SURF: Constructs a NURBS bilinear surface.
4
5 % Calling Sequence:
6
7 %   srf = nrb4surf(p11,p12,p21,p22)
8
9 % INPUT:
10
11 %   p11         : Cartesian coordinate of the lhs bottom corner point.
12
13 %   p12         : Cartesian coordinate of the rhs bottom corner point.
14
15 %   p21         : Cartesian coordinate of the lhs top corner point.
16 %  
17 %   p22         : Cartesian coordinate of the rhs top corner point.
18 %
19 % OUTPUT:
20
21 %   srf         : NURBS bilinear surface, see nrbmak. 
22
23 % Description:
24
25 %   Constructs a bilinear surface defined by four coordinates.
26
27 %   The position of the corner points
28
29 %          ^ V direction
30 %          |
31 %          ----------------
32 %          |p21        p22|
33 %          |              |
34 %          |    SRF       |
35 %          |              |
36 %          |p11        p12|
37 %          -------------------> U direction
38
39 %
40 %    Copyright (C) 2000 Mark Spink
41 %
42 %    This program is free software: you can redistribute it and/or modify
43 %    it under the terms of the GNU General Public License as published by
44 %    the Free Software Foundation, either version 2 of the License, or
45 %    (at your option) any later version.
46
47 %    This program is distributed in the hope that it will be useful,
48 %    but WITHOUT ANY WARRANTY; without even the implied warranty of
49 %    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
50 %    GNU General Public License for more details.
51 %
52 %    You should have received a copy of the GNU General Public License
53 %    along with this program.  If not, see <http://www.gnu.org/licenses/>.
54
55 if nargin ~= 4
56   error('Four corner points must be defined'); 
57 end
58
59 coefs = cat (1, zeros (3,2,2), ones (1,2,2));
60 coefs(1:length(p11),1,1) = p11(:);    
61 coefs(1:length(p12),2,1) = p12(:);
62 coefs(1:length(p21),1,2) = p21(:);
63 coefs(1:length(p22),2,2) = p22(:);
64              
65 knots  = {[0 0 1 1] [0 0 1 1]}; 
66 srf = nrbmak(coefs, knots);
67
68 end
69
70 %!demo
71 %! srf = nrb4surf([0.0 0.0 0.5],[1.0 0.0 -0.5],[0.0 1.0 -0.5],[1.0 1.0 0.5]);
72 %! nrbplot(srf,[10,10]);
73 %! title('Construction of a bilinear surface.');
74 %! hold off