linechk

PURPOSE ^

LINECHK - input checking for line segments

SYNOPSIS ^

function [x1,y1,x2,y2] = linechk(x1,y1,x2,y2)

DESCRIPTION ^

 LINECHK - input checking for line segments

  Copyright (c) 1995 by Kirill K. Pankratov
       kirill@plume.mit.edu
       08/22/95,

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [x1,y1,x2,y2] = linechk(x1,y1,x2,y2)
0002 % LINECHK - input checking for line segments
0003 %
0004 %  Copyright (c) 1995 by Kirill K. Pankratov
0005 %       kirill@plume.mit.edu
0006 %       08/22/95,
0007 
0008  % String for transposing
0009 str = ['x1=x1'';'; 'y1=y1'';'; 'x2=x2'';'; 'y2=y2'';'];
0010 
0011  % Sizes
0012 sz = [size(x1); size(y1); size(x2); size(y2)]';
0013 psz = prod(sz);
0014 
0015  % Check x1, y1
0016 if psz(1)~=psz(2)
0017   error('  Arguments  x1 and y1 must have the same size')
0018 end
0019 
0020  % Check x2, y2
0021 if psz(3)~=psz(3)
0022   error('  Arguments  x2 and y2 must have the same size')
0023 end
0024 
0025  % Check if any arguments are less than 2 by 1
0026 if any(max(sz)<2)
0027   error('  Arguments  x1, y1, x2, y2 must be at least 2 by 1 vectors')
0028 end
0029 
0030  % Check if no size is equal to 2
0031 if any(all(sz~=2))
0032   error('  Arguments  x1, y1, x2, y2 must be 2 by 1 vectors')
0033 end
0034 
0035  % Find aruments to be transposed .............................
0036 ii = find(sz(1,:)~=2);
0037 for jj = 1:length(ii)
0038   eval(str(ii(jj),:)); % Transpose if neccessary
0039 end
0040 sz(:,ii) = flipud(sz(:,ii));
0041 
0042  % If vectors, extend to 2 by n matrices ......................
0043 n = max(sz(2,:));
0044 on = ones(1,n);
0045 if sz(2,1)<n, x1 = x1(:,on); end
0046 if sz(2,2)<n, y1 = y1(:,on); end
0047 if sz(2,3)<n, x2 = x2(:,on); end
0048 if sz(2,4)<n, y2 = y2(:,on); end
0049

Generated on Sun 29-Mar-2009 20:22:55 by m2html © 2003