POLARPOINT Create a point from polar coordinates (rho + theta). POINT = polarPoint(RHO, THETA); Creates a point using polar coordinate. THETA is angle with horizontal (counted counter-clockwise, and in radians), and RHO is the distance to origin. POINT = polarPoint(THETA) Specify angle, radius RHO is assumed to be 1. POINT = polarPoint(POINT, RHO, THETA) POINT = polarPoint(X0, Y0, RHO, THETA) Adds the coordinate of the point to the coordinate of the specified point. For example, creating a point with : P = polarPoint([10 20], 30, 2*pi); will give a result of [40 20]. See Also: points2d --------- author : David Legland INRA - TPV URPOI - BIA IMASTE created the 03/05/2004
0001 function point = polarPoint(varargin) 0002 %POLARPOINT Create a point from polar coordinates (rho + theta). 0003 % 0004 % POINT = polarPoint(RHO, THETA); 0005 % Creates a point using polar coordinate. THETA is angle with horizontal 0006 % (counted counter-clockwise, and in radians), and RHO is the distance to 0007 % origin. 0008 % 0009 % POINT = polarPoint(THETA) 0010 % Specify angle, radius RHO is assumed to be 1. 0011 % 0012 % POINT = polarPoint(POINT, RHO, THETA) 0013 % POINT = polarPoint(X0, Y0, RHO, THETA) 0014 % Adds the coordinate of the point to the coordinate of the specified 0015 % point. For example, creating a point with : 0016 % P = polarPoint([10 20], 30, 2*pi); 0017 % will give a result of [40 20]. 0018 % 0019 % 0020 % See Also: 0021 % points2d 0022 % 0023 % --------- 0024 % 0025 % author : David Legland 0026 % INRA - TPV URPOI - BIA IMASTE 0027 % created the 03/05/2004 0028 % 0029 0030 0031 % default values 0032 x0 = 0; y0=0; 0033 rho = 1; 0034 theta =0; 0035 0036 % process input parameters 0037 if length(varargin)==1 0038 theta = varargin{1}; 0039 elseif length(varargin)==2 0040 rho = varargin{1}; 0041 theta = varargin{2}; 0042 elseif length(varargin)==3 0043 var = varargin{1}; 0044 x0 = var(:,1); 0045 y0 = var(:,2); 0046 rho = varargin{2}; 0047 theta = varargin{3}; 0048 elseif length(varargin)==4 0049 x0 = varargin{1}; 0050 y0 = varargin{2}; 0051 rho = varargin{3}; 0052 theta = varargin{4}; 0053 end 0054 0055 0056 point = [x0 + rho.*cos(theta) , y0+rho.*sin(theta)];