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;
#### 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;
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;
కామెంట్లు లేవు:
కామెంట్ను పోస్ట్ చేయండి