]> Creatis software - CreaPhase.git/blob - octave_packages/nurbs-1.3.6/nrbrect.m
Add a useful package (from Source forge) for octave
[CreaPhase.git] / octave_packages / nurbs-1.3.6 / nrbrect.m
1 function curve = nrbrect(w,h)
2
3 % NRBRECT: Construct NURBS representation of a rectangular curve.
4
5 % Calling Sequence:
6
7 %   crv = nrbrect()
8 %   crv = nrbrect(size)
9 %   crv = nrbrect(width, height)
10
11 % INPUT:
12
13 %   size        : Size of the square (width = height).
14
15 %   width       : Width of the rectangle (along x-axis).
16
17 %   height      : Height of the rectangle (along y-axis).
18 %
19 % OUTPUT:
20 %
21 %   crv         : NURBS curve, see nrbmak. 
22 %  
23
24 % Description:
25
26 %   Construct a rectangle or square in the x-y plane with the bottom
27 %   lhs corner at (0,0,0). If no rhs arguments provided the function
28 %   constructs a unit square.
29 %
30 %    Copyright (C) 2000 Mark Spink
31 %
32 %    This program is free software: you can redistribute it and/or modify
33 %    it under the terms of the GNU General Public License as published by
34 %    the Free Software Foundation, either version 2 of the License, or
35 %    (at your option) any later version.
36
37 %    This program is distributed in the hope that it will be useful,
38 %    but WITHOUT ANY WARRANTY; without even the implied warranty of
39 %    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
40 %    GNU General Public License for more details.
41 %
42 %    You should have received a copy of the GNU General Public License
43 %    along with this program.  If not, see <http://www.gnu.org/licenses/>.
44
45 if nargin < 1
46    w = 1;
47    h = 1;
48 end
49
50 if nargin < 2
51    h = w;
52 end
53
54 coefs  = [0 w w w w 0 0 0;
55           0 0 0 h h h h 0;
56           0 0 0 0 0 0 0 0;
57           1 1 1 1 1 1 1 1];
58
59 knots  = [0 0 0.25 0.25 0.5 0.5 0.75 0.75 1 1];
60
61 curve = nrbmak(coefs, knots);
62
63 end
64
65 %!demo
66 %! crv = nrbtform(nrbrect(2,1), vecrotz(deg2rad(35)));
67 %! nrbplot(crv,4);
68 %! axis equal
69 %! title('Construction and rotation of a rectangular curve.');
70 %! hold off