Home > custom > conversion > rad2xy.m

rad2xy

PURPOSE ^

converts angle in radians to XY cartesian coordinates

SYNOPSIS ^

function [x,y] = rad2xy(theta,r);

DESCRIPTION ^

 converts angle in radians to XY cartesian coordinates
 Usage: [x,y] = rad2xy(theta,r);
 needs four-quadrant inverse tangent format (-pi<theta<pi)
 Note: 0 is North equalling x=0,y=1

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [x,y] = rad2xy(theta,r);
0002 % converts angle in radians to XY cartesian coordinates
0003 % Usage: [x,y] = rad2xy(theta,r);
0004 % needs four-quadrant inverse tangent format (-pi<theta<pi)
0005 % Note: 0 is North equalling x=0,y=1
0006 
0007 if ~exist('r','var');
0008     r=1;
0009 end
0010 
0011 %if(theta>0 && theta<pi/2) % first quadrant NE
0012     %theta=theta-pi/2;
0013 %elseif(theta>pi/2 && theta<pi) % NW
0014     %theta=theta+pi/2;
0015 %elseif(theta<0 && theta>-pi/2)  % SE
0016     %
0017 %end
0018 
0019 y=r*sin(theta);
0020 x=r*cos(theta);

Generated on Tue 24-Feb-2009 19:14:50 by m2html © 2003