提交 2a9b4b79 编写于 作者: 三月三net's avatar 三月三net

太阳系三体模拟器

上级 08c58515
...@@ -41,17 +41,17 @@ class Moon(Body): ...@@ -41,17 +41,17 @@ class Moon(Body):
} }
super().__init__(**params) super().__init__(**params)
def ignore_gravity(self, body): # def ignore_gravity(self, body):
""" # """
是否忽略引力 # 是否忽略引力
:param body: # :param body:
:return: # :return:
""" # """
# 月球只对地球有引力,忽略其他的引力 # # 月球只对地球有引力,忽略其他的引力
if isinstance(body, Earth): # if isinstance(body, Earth):
return False # return False
#
return True # return True
if __name__ == '__main__': if __name__ == '__main__':
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
# python_version :3.8 # python_version :3.8
# ============================================================================== # ==============================================================================
from bodies import Sun, Earth, Moon from bodies import Sun, Earth, Moon
from common.consts import SECONDS_PER_HOUR, SECONDS_PER_HALF_DAY, SECONDS_PER_DAY, SECONDS_PER_WEEK from common.consts import SECONDS_PER_HOUR, SECONDS_PER_HALF_DAY, SECONDS_PER_DAY, SECONDS_PER_WEEK, SECONDS_PER_MONTH
from scenes.func import mayavi_run, ursina_run from scenes.func import mayavi_run, ursina_run
from bodies.body import AU from bodies.body import AU
...@@ -16,17 +16,20 @@ if __name__ == '__main__': ...@@ -16,17 +16,20 @@ if __name__ == '__main__':
地球、月球 地球、月球
""" """
# 地球的Y方向初始速度 # 地球的Y方向初始速度
EARTH_INIT_VELOCITY = 29.79 # 200m/s EARTH_INIT_VELOCITY = 0 # 0km/s
sun = Sun(init_position=[0, AU, 0], init_velocity=[0, 0, 0], size_scale=1e1) sun = Sun(init_position=[AU, 0, 0], size_scale=2e1) # 太阳放大 20 倍
# sun.ignore_mass = True # 忽略质量的引力
sun.ignore_mass = True
bodies = [ bodies = [
sun, sun,
Earth(init_position=[0, 0, 0], Earth(init_position=[0, 0, 0],
init_velocity=[0, EARTH_INIT_VELOCITY, 0], size_scale=1e1), # 地球放大 10 倍,距离保持不变 init_velocity=[0, EARTH_INIT_VELOCITY, 0],
Moon(init_position=[363104, 0, 0], # 距地距离约: 363104 至 405696 km size_scale=1e1), # 地球放大 10 倍,距离保持不变
init_velocity=[0, EARTH_INIT_VELOCITY + 1.023, 0], size_scale=1e1) # 月球放大 10 倍,距离保持不变 Moon(init_position=[0, 384400, 0], # 距地距离约: 363104 至 405696 km
init_velocity=[-1.023, EARTH_INIT_VELOCITY, 0],
size_scale=2e1) # 月球放大 20 倍,距离保持不变
] ]
# mayavi_run(bodies, SECONDS_PER_HALF_DAY / 2, view_azimuth=-45) # mayavi_run(bodies, SECONDS_PER_HALF_DAY / 2, view_azimuth=-45)
# 使用 ursina 查看的运行效果 # 使用 ursina 查看的运行效果
ursina_run(bodies, SECONDS_PER_DAY, position=(0, 0, 0)) ursina_run(bodies, SECONDS_PER_DAY, position=(AU, 0, 0))
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册