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

Python超人-宇宙模拟器

上级 7914cb07
### 数字 0-9 上标小数字特殊符号
```python
# ⁰ ¹ ² ³ ⁴ ⁵ ⁶ ⁷ ⁸ ⁹
#  逃逸速度:
#  公转速度:
#  天体质量:
#  平均密度:
```
参考:
https://www.explanet.info/Chapter09.htm
...@@ -26,12 +26,12 @@ class Callisto(Body): ...@@ -26,12 +26,12 @@ class Callisto(Body):
 逃逸速度:  逃逸速度:
 天体质量: 1.08 x 10²³ kg  天体质量: 1.08 x 10²³ kg
 平均密度: g/cm³ -> ✕10³ kg/m³  平均密度: 1.83 g/cm³ -> 1.83✕10³ kg/m³
""" """
def __init__(self, name="木卫四", mass=1.08e23, def __init__(self, name="木卫四", mass=1.08e23,
init_position=[0, 0, 1880000], init_position=[0, 0, 1880000],
init_velocity=[8.15, 0, 0], init_velocity=[-8.15, 0, 0],
texture="jupiter_callisto.jpg", size_scale=1.0, distance_scale=1.0, texture="jupiter_callisto.jpg", size_scale=1.0, distance_scale=1.0,
rotation_speed=0.25, ignore_mass=False, rotation_speed=0.25, ignore_mass=False,
trail_color=None, show_name=False, trail_color=None, show_name=False,
...@@ -56,7 +56,7 @@ class Callisto(Body): ...@@ -56,7 +56,7 @@ class Callisto(Body):
"mass": mass, "mass": mass,
"init_position": init_position, "init_position": init_position,
"init_velocity": init_velocity, "init_velocity": init_velocity,
"density": 3.014e3, "density": 1.83e3,
"color": (162, 162, 162), "color": (162, 162, 162),
"texture": texture, "texture": texture,
"size_scale": size_scale, "size_scale": size_scale,
......
...@@ -82,7 +82,7 @@ zero ...@@ -82,7 +82,7 @@ zero
def __init__(self, name="木卫二", mass=4.80e22, def __init__(self, name="木卫二", mass=4.80e22,
init_position=[0, 0, 670900], init_position=[0, 0, 670900],
init_velocity=[13.741, 0, 0], init_velocity=[-13.741, 0, 0],
texture="jupiter_europa.jpg", size_scale=1.0, distance_scale=1.0, texture="jupiter_europa.jpg", size_scale=1.0, distance_scale=1.0,
rotation_speed=0.25, ignore_mass=False, rotation_speed=0.25, ignore_mass=False,
trail_color=None, show_name=False, trail_color=None, show_name=False,
......
...@@ -59,7 +59,7 @@ class Ganymede(Body): ...@@ -59,7 +59,7 @@ class Ganymede(Body):
def __init__(self, name="木卫三", mass=1.4819e23, def __init__(self, name="木卫三", mass=1.4819e23,
init_position=[0, 0, 1069200], init_position=[0, 0, 1069200],
init_velocity=[10.880, 0, 0], init_velocity=[-10.880, 0, 0],
texture="jupiter_ganymede.jpg", size_scale=1.0, distance_scale=1.0, texture="jupiter_ganymede.jpg", size_scale=1.0, distance_scale=1.0,
rotation_speed=0.25, ignore_mass=False, rotation_speed=0.25, ignore_mass=False,
trail_color=None, show_name=False, trail_color=None, show_name=False,
......
...@@ -50,7 +50,7 @@ class Io(Body): ...@@ -50,7 +50,7 @@ class Io(Body):
def __init__(self, name="木卫一", mass=8.9319e22, def __init__(self, name="木卫一", mass=8.9319e22,
init_position=[0, 0, 420000], init_position=[0, 0, 420000],
init_velocity=[17.334, 0, 0], init_velocity=[-17.334, 0, 0],
texture="jupiter_io.jpg", size_scale=1.0, distance_scale=1.0, texture="jupiter_io.jpg", size_scale=1.0, distance_scale=1.0,
rotation_speed=0.25, ignore_mass=False, rotation_speed=0.25, ignore_mass=False,
trail_color=None, show_name=False, trail_color=None, show_name=False,
......
...@@ -9,24 +9,34 @@ ...@@ -9,24 +9,34 @@
from bodies import Sun, Earth, Jupiter from bodies import Sun, Earth, Jupiter
from bodies.jupiter_system import Io, Europa, Ganymede, Callisto from bodies.jupiter_system import Io, Europa, Ganymede, Callisto
from common.consts import SECONDS_PER_HOUR, SECONDS_PER_DAY, AU from common.consts import SECONDS_PER_HOUR, SECONDS_PER_DAY, AU
from sim_scenes.func import mayavi_run, ursina_run from sim_scenes.func import mayavi_run, ursina_run, camera_look_at
from simulators.ursina.ursina_event import UrsinaEvent
if __name__ == '__main__': if __name__ == '__main__':
""" """
太阳、地球、木星 太阳、地球、木星
""" """
bodies = [ bodies = [
Jupiter(size_scale=1, init_velocity=[0, 0, 0], init_position=[0, 0, 0]),
Io(size_scale=1e1), Io(size_scale=1e1),
Europa(size_scale=1e1), Europa(size_scale=1e1),
Ganymede(size_scale=1e1), Ganymede(size_scale=1e1),
Callisto(size_scale=1e1), Callisto(size_scale=1e1),
Jupiter(size_scale=1, init_velocity=[0, 0, 0], init_position=[0, 0, 0]), # 木星放大 500 倍,距离保持不变
] ]
jupiter = bodies[0]
# 使用 mayavi 查看的运行效果
# mayavi_run(bodies, SECONDS_PER_WEEK, view_azimuth=-45) def on_ready():
camera_look_at(jupiter)
pass
UrsinaEvent.on_ready_subscription(on_ready)
# 使用 ursina 查看的运行效果 # 使用 ursina 查看的运行效果
# 常用快捷键: P:运行和暂停 O:重新开始 I:显示天体轨迹 # 常用快捷键: P:运行和暂停 O:重新开始 I:显示天体轨迹
# position = 左-右+、上+下-、前+后- # position = 左-右+、上+下-、前+后-
ursina_run(bodies, SECONDS_PER_HOUR, position=(0, 0, -AU/100), show_trail=True, view_closely=True) ursina_run(bodies, SECONDS_PER_DAY,
position=(0, AU / 25, 0),
show_trail=True,
view_closely=True)
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册