]> Creatis software - CreaPhase.git/blob - octave_packages/nurbs-1.3.6/nrbline.m
Add a useful package (from Source forge) for octave
[CreaPhase.git] / octave_packages / nurbs-1.3.6 / nrbline.m
1 function curve = nrbline(p1,p2)
2
3 % NRBLINE: Construct a straight line.
4
5 % Calling Sequence:
6
7 %   crv = nrbline()
8 %   crv = nrbline(p1,p2)
9
10 % INPUT:
11
12 % p1            : 2D or 3D cartesian coordinate of the start point.
13
14 % p2            : 2D or 3D cartesian coordinate of the end point.
15 %
16 % OUTPUT:
17
18 % crv           : NURBS curve for a straight line.
19
20 % Description:
21
22 %   Constructs NURBS data structure for a straight line. If no rhs 
23 %   coordinates are included the function returns a unit straight
24 %   line along the x-axis.
25 %
26 %    Copyright (C) 2000 Mark Spink
27 %
28 %    This program is free software: you can redistribute it and/or modify
29 %    it under the terms of the GNU General Public License as published by
30 %    the Free Software Foundation, either version 2 of the License, or
31 %    (at your option) any later version.
32
33 %    This program is distributed in the hope that it will be useful,
34 %    but WITHOUT ANY WARRANTY; without even the implied warranty of
35 %    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
36 %    GNU General Public License for more details.
37 %
38 %    You should have received a copy of the GNU General Public License
39 %    along with this program.  If not, see <http://www.gnu.org/licenses/>.
40
41 coefs = [zeros(3,2); ones(1,2)];
42
43 if nargin < 2
44   coefs(1,2) = 1.0;  
45 else
46   coefs(1:length(p1),1) = p1(:);    
47   coefs(1:length(p2),2) = p2(:);
48 end
49
50 curve = nrbmak(coefs, [0 0 1 1]);
51
52 end
53
54 %!demo
55 %! crv = nrbline([0.0 0.0 0.0]',[5.0 4.0 2.0]');
56 %! nrbplot(crv,1);
57 %! grid on;
58 %! title('3D straight line.');
59 %! hold off