Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Python_超人
宇宙模拟器
提交
9a236fee
宇宙模拟器
项目概览
Python_超人
/
宇宙模拟器
通知
19
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
宇宙模拟器
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
9a236fee
编写于
4月 02, 2023
作者:
三月三net
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Python超人-宇宙模拟器
上级
e0e7539a
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
88 addition
and
2 deletion
+88
-2
sim_scenes/solar_system/earth_moon.py
sim_scenes/solar_system/earth_moon.py
+1
-1
sim_scenes/solar_system/hd_earth_at_night.py
sim_scenes/solar_system/hd_earth_at_night.py
+0
-0
sim_scenes/solar_system/solar_system_1.py
sim_scenes/solar_system/solar_system_1.py
+1
-1
sim_scenes/solar_system/solar_system_4.py
sim_scenes/solar_system/solar_system_4.py
+86
-0
未找到文件。
sim_scenes/solar_system/earth_moon.py
浏览文件 @
9a236fee
...
...
@@ -19,7 +19,7 @@ if __name__ == '__main__':
EARTH_INIT_VELOCITY
=
0
bodies
=
[
# sun,
Earth
(
init_position
=
[
0
,
0
,
0
],
Earth
(
init_position
=
[
0
,
0
,
0
],
texture
=
"earth_hd.jpg"
,
init_velocity
=
[
-
EARTH_INIT_VELOCITY
,
0
,
0
],
size_scale
=
0.5e1
),
# 地球放大 5 倍,距离保持不变
Moon
(
init_position
=
[
0
,
0
,
363104
],
# 距地距离约: 363104 至 405696 km
init_velocity
=
[
-
(
EARTH_INIT_VELOCITY
+
1.023
),
0
,
0
],
size_scale
=
1e1
)
# 月球放大 10 倍,距离保持不变
...
...
sim_scenes/solar_system/earth_at_night.py
→
sim_scenes/solar_system/
hd_
earth_at_night.py
浏览文件 @
9a236fee
文件已移动
sim_scenes/solar_system/solar_system_1.py
浏览文件 @
9a236fee
...
...
@@ -42,4 +42,4 @@ if __name__ == '__main__':
# 使用 ursina 查看的运行效果
# 常用快捷键: P:运行和暂停 O:重新开始 I:显示天体轨迹
# position = 左-右+、上+下-、前+后-
ursina_run
(
bodies
,
SECONDS_PER_YEAR
,
position
=
(
0
,
2
*
AU
,
-
11
*
AU
),
bg_music
=
"sounds/
universe_04
.mp3"
)
ursina_run
(
bodies
,
SECONDS_PER_YEAR
,
position
=
(
0
,
2
*
AU
,
-
11
*
AU
),
bg_music
=
"sounds/
interstellar
.mp3"
)
sim_scenes/solar_system/solar_system_4.py
0 → 100644
浏览文件 @
9a236fee
# -*- coding:utf-8 -*-
# title :太阳系场景模拟(展示用)
# description :太阳系场景模拟(为了更好的展示效果,对距离进行的调整,不是太阳系的真实距离)
# author :Python超人
# date :2023-02-11
# link :https://gitcode.net/pythoncr/
# python_version :3.8
# ==============================================================================
from
bodies
import
Sun
,
Mercury
,
Venus
,
Earth
,
Mars
,
Jupiter
,
Saturn
,
Uranus
,
Neptune
,
Pluto
,
Moon
,
Asteroids
from
common.consts
import
SECONDS_PER_WEEK
,
SECONDS_PER_DAY
,
SECONDS_PER_YEAR
,
AU
from
sim_scenes.func
import
mayavi_run
,
ursina_run
import
math
from
common.consts
import
G
def
get_velocity
(
mass
,
distance
,
velocity
,
target_distance
):
"""
根据天体的质量和天体原始距离、速度,计算出能稳定围绕太阳转的速度。
:param mass: 天体质量,单位 kg
:param distance: 天体原始距离,单位 km
:param velocity: 天体原始速度,单位 km/s
:param target_distance: 目标距离,即新轨道的距离,单位 km
:return: 稳定围绕太阳转的速度,单位 km/s
"""
v
=
velocity
*
pow
(
distance
/
target_distance
,
0.5
)
# # 计算原始速率
# v0 = math.sqrt(G * mass / distance * 1000)
# # 计算目标速率
# v_target = math.sqrt(G * mass / target_distance * 1000)
# # 计算需要调整的速率量
# dv = v_target - v0
# # 新速度等于原始速度加上调整速率量
# v = (velocity*1000 + dv)/1000
return
[
v
,
0
,
0
]
if
__name__
==
'__main__'
:
# 八大行星:木星(♃)、土星(♄)、天王星(♅)、海王星(♆)、地球(⊕)、金星(♀)、火星(♂)、水星(☿)
# 排列顺序
# 1、体积:(以地球为1)木星 :土星 :天王星 :海王星 :地球 :金星 :火星 :水星 = 1330:745:65:60:1:0.86:0.15:0.056
# 2、质量:(以地球为1)木星 :土星 :天王星 :海王星 :地球 :金星 :火星 :水星 = 318:95:14.53:17.15:1:0.8:0.11:0.0553
# 3、离太阳从近到远的顺序:水星、金星、地球、火星、木星、土星、天王星、海王星
# =====================================================================
# 以下展示的效果为太阳系真实的距离
# 由于宇宙空间尺度非常大,如果按照实际的天体大小,则无法看到天体,因此需要对天体的尺寸进行放大
sun
=
Sun
(
name
=
"太阳"
,
size_scale
=
1.4e2
)
# 太阳放大 80 倍,距离保持不变
sun
.
init_velocity
=
[
0
,
2
,
0
]
# 太阳带着其他行星一起跑
bodies
=
[
sun
,
Mercury
(
name
=
"水星"
,
size_scale
=
4e3
),
# 水星放大 4000 倍,距离保持不变
Venus
(
name
=
"金星"
,
size_scale
=
4e3
),
# 金星放大 4000 倍,距离保持不变
Earth
(
name
=
"地球"
,
size_scale
=
4e3
),
# 地球放大 4000 倍,距离保持不变
Mars
(
name
=
"火星"
,
size_scale
=
4e3
),
# 火星放大 4000 倍,距离保持不变
Asteroids
(
name
=
"小行星群"
,
size_scale
=
3.2e2
,
parent
=
sun
),
# 小行星群模拟(仅 ursina 模拟器支持)
Jupiter
(
name
=
"木星"
,
size_scale
=
0.6e3
),
# 木星放大 800 倍,距离保持不变
Saturn
(
name
=
"土星"
,
size_scale
=
0.6e3
),
# 土星放大 800 倍,距离保持不变
Uranus
(
name
=
"天王星"
,
size_scale
=
0.8e3
),
# 天王星放大 800 倍,距离保持不变
Neptune
(
name
=
"海王星"
,
size_scale
=
1e3
),
# 海王星放大 1000 倍,距离保持不变
Pluto
(
name
=
"冥王星"
,
size_scale
=
10e3
),
# 冥王星放大 10000 倍,距离保持不变(从太阳系的行星中排除)
]
# 使用 mayavi 查看的运行效果
# mayavi_run(bodies, SECONDS_PER_WEEK, view_azimuth=-45)
# 真实距离
# body_real_distances = [0.4 * AU, 0.72 * AU, AU, 1.5 * AU, 5.2 * AU, 10 * AU, 19 * AU, 30 * AU, 40 * AU]
# velocity_factors = [1, 1, 1, 1, 2, 2, 2, 2, 2]
# 调整距离
body_distances
=
[
1
*
AU
,
1.5
*
AU
,
1.8
*
AU
,
2.3
*
AU
,
3.6
*
AU
,
4.2
*
AU
,
5.3
*
AU
,
6
*
AU
,
7
*
AU
]
body_index
=
0
# 设置为行星距离
for
idx
,
body
in
enumerate
(
bodies
):
if
body
.
is_fixed_star
or
hasattr
(
body
,
"torus_stars"
):
continue
body_real_distance
=
body
.
init_position
[
2
]
# 格式:body.init_position=[0, 0, 1.12 * AU]
body_real_velocity
=
body
.
init_velocity
[
0
]
# 格式:body.init_velocity=body.[-29.79, 0, 0]
body
.
init_position
=
[
0
,
0
,
body_distances
[
body_index
]]
init_velocity
=
get_velocity
(
body
.
mass
,
body_real_distance
,
body_real_velocity
,
body_distances
[
body_index
])
body
.
init_velocity
=
init_velocity
body_index
+=
1
# 使用 ursina 查看的运行效果
# 常用快捷键: P:运行和暂停 O:重新开始 I:显示天体轨迹
# position = 左-右+、上+下-、前+后-
ursina_run
(
bodies
,
SECONDS_PER_YEAR
,
position
=
(
0
,
2
*
AU
,
-
11
*
AU
),
bg_music
=
"sounds/interstellar.mp3"
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录