From ce911879c9a1005fcae8be20078381790d52bcd5 Mon Sep 17 00:00:00 2001 From: march3 Date: Sun, 16 Apr 2023 19:00:08 +0800 Subject: [PATCH] =?UTF-8?q?Python=E8=B6=85=E4=BA=BA-=E5=AE=87=E5=AE=99?= =?UTF-8?q?=E6=A8=A1=E6=8B=9F=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sim_scenes/science/free_fall_of_ball.py | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/sim_scenes/science/free_fall_of_ball.py b/sim_scenes/science/free_fall_of_ball.py index c38b53a..a4669c2 100644 --- a/sim_scenes/science/free_fall_of_ball.py +++ b/sim_scenes/science/free_fall_of_ball.py @@ -16,22 +16,29 @@ if __name__ == '__main__': 自由落地模拟 """ # 地球在中心位置 - e = Earth(init_position=[0, 0, 0], size_scale=1, texture="earth_hd.jpg", init_velocity=[0, 0, 0]) + 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 = [ - e, + earth, Football(mass=500, size_scale=3e2, trail_color=[255, 0, 0], - init_position=[-500, e.raduis + 500, 0], # 球在地面上 500km - init_velocity=[0, 0, 0]), - Football(mass=5000, size_scale=3.8e2, - init_position=[500, e.raduis + 1000, 0], # 球在地面上 500km - init_velocity=[0, 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]), ] # 使用 ursina 查看的运行效果 # 常用快捷键: P:运行和暂停 O:重新开始 I:显示天体轨迹 # position = 左-右+、上+下-、前+后- ursina_run(bodies, SECONDS_PER_MINUTE, # 一秒相当于一分钟 - position=(0, e.raduis + 500, -4500), + position=(0, earth.raduis + 500, -4500), show_trail=True, show_timer=True, view_closely=0.001) -- GitLab