我正在编写一个程序,允许在极坐标和笛卡尔坐标/直角坐标之间进行转换。该代码适用于单个r和θ值,但我希望能够为r和θ输入包含多个值(且长度相同)的向量。谢谢你的帮助
import numpy as np
r=float(input('Enter a value for r:'))
theta=float(input('Enter a theta value in radians:'))
def polar2cart(r,theta):
x=r*(np.cos(theta))
y=r*(np.sin(theta))
return x,y
x,y= polar2cart(r,theta)
目前没有回答
相关问题 更多 >
编程相关推荐