直角坐标转化柱坐标。
program translate
implicit none
real(8):: x ,y, r, p ,z,theta,pi,c,f
pi=dacos(-1d0)
read (,) x
read (,) y
c=abs(x)
f=abs(y)
p=xx+yy
r=sqrt§
if (x>=0.and.y>0) then
theta=(180/pi)datan(f/c)
else if (x<=0.and.y>0) then
theta=(pi/2)(180/pi)+(180/pi)datan(f/c)
else if (x<=0.and.y<0) then
theta=pi(180/pi)+(180/pi)datan(y/x)
else if (x>=0.and.y<0) then
theta=(3pi/2)(180/pi)+(180/pi)datan(f/c)
end if
write(,) r,theta
stop
end
柱坐标转化直角坐标。
program exa
implicit none
real(8)::x,y,r,theta,pi,z
pi=dacos(-1d0)
read(,) r
read(,) z
theta=(z/180)pi
x=rcos(theta)
y=rsin(theta)
write(,*)r,z,x,y
stop
end