Home > matGeom > geom2d > polarPoint.m

polarPoint

PURPOSE ^

POLARPOINT Create a point from polar coordinates (rho + theta).

SYNOPSIS ^

function point = polarPoint(varargin)

DESCRIPTION ^

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

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

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 % Author: David Legland
0025 % E-mail: david.legland@inrae.fr
0026 % Created: 2004-05-03
0027 % Copyright 2004-2024 INRA - TPV URPOI - BIA IMASTE
0028 
0029 % default values
0030 x0 = 0; y0=0;
0031 rho = 1;
0032 theta =0;
0033 
0034 % process input parameters
0035 if isscalar(varargin)
0036     theta = varargin{1};
0037 elseif length(varargin)==2
0038     rho = varargin{1};
0039     theta = varargin{2};
0040 elseif length(varargin)==3
0041     var = varargin{1};
0042     x0 = var(:,1);
0043     y0 = var(:,2);
0044     rho = varargin{2};
0045     theta = varargin{3};
0046 elseif length(varargin)==4
0047     x0 = varargin{1};
0048     y0 = varargin{2};
0049     rho = varargin{3};
0050     theta = varargin{4};
0051 end
0052 
0053 
0054 point = [x0 + rho.*cos(theta) , y0+rho.*sin(theta)];

Generated on Thu 21-Nov-2024 11:30:22 by m2html © 2003-2022