提交 5d5b19a9 编写于 作者: 三月三net's avatar 三月三net

Python超人-宇宙模拟器

上级 9b7c53b5
......@@ -8,9 +8,11 @@
# ==============================================================================
from bodies import Sun, Earth
from common.consts import SECONDS_PER_WEEK, SECONDS_PER_YEAR, SECONDS_PER_DAY, AU, G
from sim_scenes.func import mayavi_run, mpl_run, ursina_run
from sim_scenes.func import mayavi_run, mpl_run, ursina_run, create_sphere_sky
import math
from simulators.ursina.ursina_event import UrsinaEvent
if __name__ == '__main__':
r2 = 0.02 * AU
r1 = 2 * r2
......@@ -28,7 +30,9 @@ if __name__ == '__main__':
vyA = -math.sqrt((G * mA * mB) / math.pow(r1 * 1000 + r2 * 1000, 2) * r1 * 1000 / mA)
# 万有引力常量 *mA * mB/ math.pow(r1+r2,2) = mB*math.pow(vyB,2)/r2
vyB = math.sqrt((G * mA * mB) / math.pow(r1 * 1000 + r2 * 1000, 2) * r2 * 1000 / mB)
vA, vB = [vxA, vyA / 1000, 0], [vxB, vyB / 1000, 0]
vz = 0.02
vz= 0
vA, vB = [vxA, vyA / 1000, vz], [vxB, vyB / 1000, vz]
# vA, vB = [0,0,0],[0,0,0]
bodies = [
Earth(name="A", rotation_speed=1, mass=mA,
......@@ -37,7 +41,30 @@ if __name__ == '__main__':
init_position=pB, init_velocity=vB, size_scale=5e1, distance_scale=1)
]
def on_ready():
"""
事件绑定后,模拟器运行前会触发
@return:
"""
# 创建天空
# camera.clip_plane_near = 0.1
from ursina import camera, application
camera.clip_plane_far = 1000000
create_sphere_sky(scale=200000)
application.time_scale = 5
UrsinaEvent.on_ready_subscription(on_ready)
# 使用 ursina 查看的运行效果
# 常用快捷键: P:运行和暂停 O:重新开始 I:显示天体轨迹
# position = 左-右+、上+下-、前+后-
ursina_run(bodies, SECONDS_PER_YEAR, position=(r1, r1, -7 * r2), show_trail=True)
ursina_run(bodies,
SECONDS_PER_YEAR,
cosmic_bg='',
# show_grid=False,
position=(r1, r1, -7 * r2),
show_camera_info=False,
show_control_info=False,
timer_enabled=True,
show_trail=True)
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册