极坐标的Python库 [关闭]

问题描述 投票:0回答:0

我目前正在用python进行球面光学计算,宁可不要转换到笛卡尔,因为计算会变得复杂。在python中是否有以极坐标创建向量并进行向量运算(交叉、点、卷曲)的库?

python python-3.x physics
0
投票

我建议使用复数。它使极坐标的操作变得更加简单。例如,你可以在不部署任何三角的情况下在单位圈内移动。

import matplotlib.pyplot as plt
plt.style.use('seaborn-whitegrid')
import numpy as np

rot = 5
ang = 70

x = []
y = []
rotator = np.exp(1j*np.deg2rad(ang))
location = rotator
for i in range(int(rot * 365/ang)):
    location *= rotator
    x.append(location.real)
    y.append(location.imag)

fig = plt.figure()
ax = plt.axes()
ax.plot(x,y,marker='o');
© www.soinside.com 2019 - 2024. All rights reserved.