绘制迫击炮弹运行轨迹

########## Begin ##########
import numpy as np
import matplotlib.pyplot as plt
def calBombTrace(d, v0=50, n=30):
    g = 9.8
    tmax = 2*v0*np.sin(np.radians(d))/g
    t = np.linspace(0, tmax, n)
    xt = v0*t*np.cos(np.radians(d))
    yt = v0*t*np.sin(np.radians(d))-1/2*g*t**2
    return xt, yt
D = [30, 45, 60, 75]
for d in D:
    xt,yt = calBombTrace(d)
    plt.plot(xt,yt,'r-')
plt.grid('on')
plt.axis([0, 260, 0, 120])
plt.show()
########## End ##########
plt.savefig( 'src/step6/student/pic.png' )
plt.close()
上一篇:闰年判断(基于mips汇编语言)


下一篇:educoder:第2关:顺序结构-无输入求平抛小球与抛出点之间的距离