提交 1147b3b1 编写于 作者: 三月三net's avatar 三月三net

Python超人-宇宙模拟器

上级 9baff751
......@@ -13,8 +13,9 @@ from ursina import camera, application
from bodies import Sun, Mercury, Venus, Earth, Mars, Jupiter, Saturn, Uranus, Neptune, Pluto
from common.celestial_data_service import get_init_pos_vels, init_bodies_pos_vels
from common.consts import SECONDS_PER_YEAR, AU
from common.func import calculate_distance
from objs import HalleComet, Obj
from sim_scenes.func import camera_look_at, two_bodies_colliding
from sim_scenes.func import camera_look_at, two_bodies_colliding, create_text_panel
from sim_scenes.func import ursina_run, create_sphere_sky
from simulators.ursina.ursina_event import UrsinaEvent
......@@ -34,7 +35,7 @@ class HalleyCometSim:
self.sun, # 太阳放大 80 倍
# Mercury(size_scale=4e3, distance_scale=1.3), # 水星放大 4000 倍,距离放大 1.3 倍
# Venus(size_scale=4e3, distance_scale=1.3), # 金星放大 4000 倍,距离放大 1.3 倍
# Earth(size_scale=4e3, distance_scale=1.3, rotate_angle=0), # 地球放大 4000 倍,距离放大 1.3 倍
Earth(size_scale=4e3, distance_scale=1.3, rotate_angle=0), # 地球放大 4000 倍,距离放大 1.3 倍
# Mars(size_scale=4e3, distance_scale=1.2), # 火星放大 4000 倍,距离放大 1.2 倍
Jupiter(size_scale=1.68e3, distance_scale=1), # 木星放大 680 倍,距离缩小到真实距离的 0.72
Saturn(size_scale=1.68e3, distance_scale=1), # 土星放大 680 倍,距离缩小到真实距离的 0.52
......@@ -55,16 +56,17 @@ class HalleyCometSim:
# 每76.1年环绕太阳一周的周期彗星
# 3.335, 0, 10.7 73
# 3.33, 0, 10.7 73
self.halley_comet = HalleComet(# size_scale=4e7,
size_scale=1e8,
init_velocity=[3.33, 0, 10.65], # [3.33, 0, 10.6] < ? <[3.34, 0, 10.7]
init_position=[0, 0.5 * AU, -10 * AU]) \
# [3.33, 0, 10.65] 71
# [3.33, 0, 10.655] 68
# [3.33, 0, 10.66] 69
self.halley_comet = HalleComet( # size_scale=4e7,
size_scale=1e8,
init_velocity=[3.33, 0, 10.699], # [3.33, 0, 10.6] < ? <[3.34, 0, 10.7]
init_position=[0, 0.5 * AU, -10 * AU]) \
.set_light_disable(True)
self.bodies.append(self.halley_comet)
def build(self):
self.build_solar_system()
self.build_halley_comet()
......@@ -80,7 +82,7 @@ class HalleyCometSim:
create_sphere_sky(scale=200000)
application.time_scale = 5
self.text_panel = create_text_panel()
def on_timer_changed(self, time_data):
"""
......@@ -94,7 +96,8 @@ class HalleyCometSim:
self.halley_comet.planet.rotation_y += 1
# 摄像机始终看向二向箔
# camera_look_at(self.halley_comet)
d = calculate_distance(self.halley_comet.position, self.sun.position)
self.text_panel.text = "哈雷彗星距离太阳:%.3f AU" % (d / AU)
if __name__ == '__main__':
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册