我正在try 使用matplotlib绘制该函数.
正如您在Desmos应用程序中看到的那样,公式正确地将函数绘制为圆,但当我try 将其移植到Python时,我得到了以下结果:
import numpy as np
import matplotlib.pyplot as plt
def fungsi_r4(theta, theta0, r0, a):
return r0 * np.cos(theta - theta0) + np.sqrt((a ** 2) - (r0 ** 2) * (np.sin(theta - theta0) ** 2))
theta = np.linspace(0, 2 * np.pi, 100)
r = fungsi_r4(theta, 2.4, 5.1, 2.6)
ax = plt.subplot(projection='polar')
ax.plot(theta, r)
我的感觉告诉我,这与函数返回的负值有关,但我不知道如何处理它.