【发布时间】:2020-05-06 21:38:48
【问题描述】:
对于极坐标 (13, 22.6°),我应该得到 (12,5) 的笛卡尔坐标答案,但我没有。我的代码有什么问题?我知道角度 phi 应该以度数表示,我试图在代码中实现它,但它没有给我正确的答案。
import math
def pol2cart(rho, phi):
x = rho * math.cos(math.degrees(phi))
y = rho * math.sin(math.degrees(phi))
return(x, y)
rho=float(input("Enter the value of rho:"))
phi=float(input("Enter the value of phi in degrees:"))
print("For the polar coordinates x = ", rho, "and y = ", phi, "the cartesian coordinates are = ", pol2cart(rho, phi))
提前致谢。
【问题讨论】:
标签: python python-3.x