fortran中直角坐标与柱坐标转化程序
直角坐标转化柱坐标。
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
本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!
