【发布时间】:2021-01-03 13:57:29
【问题描述】:
希望你能帮上忙!我需要显示在g = -9.81 m/s2 的重力和dt = 0.05 sec 的时间步长下的粒子的轨迹,其中粒子的位置和速度为:
x_1 = x_0 + v_x1 * dty_1 = y_0 + v_y1 * dtv_x1 = v_x0v_y1 = v_y0 + g * dt
import numpy as np
import matplotlib.pyplot as plt
plt.figure(1, figsize=(12,12))
ax = plt.subplot(111, aspect='equal')
ax.set_ylim(0,50)
ax.set_title('Boom --- Weeee! --- Ooof')
r = np.array([0.,0.,15.,30.])
g = -9.81
dt = 0.05
y = 0
x = 0
while y > 0:
plt.plot(x_1,y_2,':', ms=2)
x_1 = v_x1 * dt
y_1 = v_y1 * dt
v_x1 = v_x0
v_y1 = v_y0 + g * dt
这不会只生成开头提到的plt.figure 的图像,我尝试将r 向量集成到循环中,但我不知道如何。
谢谢。
【问题讨论】:
标签: python simulation physics particles