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

Python超人-宇宙模拟器

上级 2285f601
......@@ -17,22 +17,24 @@ if __name__ == '__main__':
"""
# 地球在中心位置
earth = Earth(init_position=[0, 0, 0], size_scale=1, texture="earth_hd.jpg", init_velocity=[0, 0, 0])
# e.raduis = 6373.22
# math.sqrt(pow(6373.22 + 500, 2) + pow(500, 2))-6373.22
# math.sqrt(pow(6373.22 + 1000, 2) + pow(500, 2))-6373.22
# 创建的3个不同质量,不同高度的物体,观察地球表面上的加速度
bodies = [
earth,
Football(mass=500, size_scale=3e2, trail_color=[255, 0, 0],
init_position=[-500, earth.raduis + 500, 0], # 球在地面上 518 多公里(向左偏移500公里)
init_velocity=[0, 0, 0], gravity_only_for=[earth]),
Football(mass=1000, size_scale=3e2, trail_color=[0, 255, 0],
init_position=[0, earth.raduis + 800, 0], # 球在地面上 800 多公里
init_velocity=[0, 0, 0], gravity_only_for=[earth]),
Football(mass=5000, size_scale=3.8e2, trail_color=[0, 0, 255],
init_position=[500, earth.raduis + 1000, 0], # 球在地面上 1016 多公里(向右偏移500公里)
init_velocity=[0, 0, 0], gravity_only_for=[earth]),
]
# earth.raduis = 6373.22
# 创建的3个不同质量,不同高度的球,观察这3个球打到地球表面上的加速度
ball_1 = Football(mass=500, size_scale=3e2, trail_color=[255, 0, 0],
# 球在地面上 518 多公里处
# 518 = sqrt[(earth.raduis + 500)² + (-500)²] - earth.raduis
init_position=[-500, earth.raduis + 500, 0],
init_velocity=[0, 0, 0], gravity_only_for=[earth])
ball_2 = Football(mass=1000, size_scale=3e2, trail_color=[0, 255, 0],
# 球在地面上 800 多公里处
init_position=[0, earth.raduis + 800, 0],
init_velocity=[0, 0, 0], gravity_only_for=[earth])
ball_3 = Football(mass=5000, size_scale=3.8e2, trail_color=[0, 0, 255],
# 球在地面上 1016 多公里处
# 1016 = sqrt[(earth.raduis + 1000)² + 500²] - earth.raduis
init_position=[500, earth.raduis + 1000, 0],
init_velocity=[0, 0, 0], gravity_only_for=[earth])
bodies = [earth, ball_1, ball_2, ball_3]
# 使用 ursina 查看的运行效果
# 常用快捷键: P:运行和暂停 O:重新开始 I:显示天体轨迹
......
......@@ -295,4 +295,3 @@ def create_trail_info(body, trail):
if trail is not None:
trail.entity_infos = {"velocity": [vel_value, vel_direction, vel_position],
"acceleration": [acc_value, acc_direction, acc_position]}
......@@ -100,6 +100,7 @@ class Planet(Entity):
)
if hasattr(self.body, "rotate_angle"):
if self.body.rotate_angle != 0:
# 为了给天体增加一个倾斜角,增加了一个Entity
self.rotate_angle = self.body.rotate_angle
self.main_entity = Entity()
self.main_entity.rotation_x = self.rotate_angle
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册