About this blog

I feel this blog as a reflection of my thoughts to myself , and sometimes as a public diary, and the is my only friend to share my thoughts who says never a "oh no! ,you shouldn't....That is boring...."

mapping Arc Z=(x,y) using tan( inverse tangent) from [-pi/2, pi/2] to [0, 2pi]

octave code:

function Theta=tani(x,y)
#### To find 0, 2pi range arc tangent for given x,y

sx=sign(x+eps);sy=sign(y+eps);
Theta=(1+sx).*( pi*(1-sy)+atan(y./x));
Theta=Theta+ (1-sx).*( pi+atan(y./x));
Theta=Theta/2;

Sample Test code:


#### To find 0, 2pi range arc tangent for given x,y

theta=[0:0.1:2*pi]' ;
circle=[cos(theta), sin(theta)];
figure;hold on;
for t=1:length(theta)
  plot(circle(t,1),circle(t,2));pause(0.2);
  plot(circle(:,1),circle(:,2),'r');
end;
pause(1);
x=circle(:,1);
y=circle(:,2);

sx=sign(x+eps);sy=sign(y+eps);
Theta=(1+sx).*( pi*(1-sy)+atan(y./x));
Theta=Theta+ (1-sx).*( pi+atan(y./x));
Theta=Theta/2;

##plot( theta,Theta ); pause;

కామెంట్‌లు లేవు: