Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Python_超人
宇宙模拟器
提交
6a737b91
宇宙模拟器
项目概览
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看板
提交
6a737b91
编写于
10月 25, 2023
作者:
三月三net
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Python超人-宇宙模拟器
上级
d2e2bc71
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
73 addition
and
42 deletion
+73
-42
common/celestial_data_service.py
common/celestial_data_service.py
+12
-0
sim_scenes/fiction/sirius_is_coming.py
sim_scenes/fiction/sirius_is_coming.py
+39
-22
sim_scenes/tri_bodies/two_way_foil.py
sim_scenes/tri_bodies/two_way_foil.py
+11
-10
sim_scenes/tri_bodies/two_way_foil_02.py
sim_scenes/tri_bodies/two_way_foil_02.py
+11
-10
未找到文件。
common/celestial_data_service.py
浏览文件 @
6a737b91
...
@@ -346,6 +346,18 @@ def get_init_pos_vels():
...
@@ -346,6 +346,18 @@ def get_init_pos_vels():
return
init_pos_vels
return
init_pos_vels
def
init_bodies_pos_vels
(
bodies
):
# 获取模拟的初始位置和速度
init_pos_vels
=
get_init_pos_vels
()
for
body
in
bodies
:
pos_vels
=
init_pos_vels
.
get
(
type
(
body
).
__name__
.
lower
(),
None
)
if
pos_vels
is
None
:
continue
body
.
init_position
=
pos_vels
[
'pos'
]
body
.
init_velocity
=
pos_vels
[
'vel'
]
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
from
astropy.time
import
Time
# 时间
from
astropy.time
import
Time
# 时间
...
...
sim_scenes/fiction/sirius_is_coming.py
浏览文件 @
6a737b91
# -*- coding:utf-8 -*-
# -*- coding:utf-8 -*-
# title :天狼星进入太阳系场景模拟
# title :天狼星进入太阳系场景模拟
# description :天狼星
进入太阳系场景模拟
# description :天狼星
把土星带走了
# author :Python超人
# author :Python超人
# date :2023-02-11
# date :2023-02-11
# link :https://gitcode.net/pythoncr/
# link :https://gitcode.net/pythoncr/
...
@@ -8,17 +8,14 @@
...
@@ -8,17 +8,14 @@
# ==============================================================================
# ==============================================================================
from
bodies
import
Sirius
,
Sun
,
Mercury
,
Venus
,
Earth
,
\
from
bodies
import
Sirius
,
Sun
,
Mercury
,
Venus
,
Earth
,
\
Mars
,
Jupiter
,
Saturn
,
Uranus
,
Neptune
,
Pluto
,
Moon
,
Asteroids
Mars
,
Jupiter
,
Saturn
,
Uranus
,
Neptune
,
Pluto
,
Moon
,
Asteroids
from
common.celestial_data_service
import
init_bodies_pos_vels
from
common.consts
import
SECONDS_PER_WEEK
,
SECONDS_PER_DAY
,
SECONDS_PER_MONTH
,
AU
from
common.consts
import
SECONDS_PER_WEEK
,
SECONDS_PER_DAY
,
SECONDS_PER_MONTH
,
AU
from
sim_scenes.func
import
mayavi_run
,
ursina_run
from
sim_scenes.func
import
ursina_run
,
create_sphere_sky
from
ursina
import
camera
,
application
from
simulators.ursina.ursina_event
import
UrsinaEvent
if
__name__
==
'__main__'
:
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
=
"太阳"
,
sun
=
Sun
(
name
=
"太阳"
,
init_velocity
=
[
0
,
2
,
0
],
init_velocity
=
[
0
,
2
,
0
],
...
@@ -43,9 +40,29 @@ if __name__ == '__main__':
...
@@ -43,9 +40,29 @@ if __name__ == '__main__':
Pluto
(
name
=
"冥王星"
,
size_scale
=
10e3
),
# 冥王星放大 10000 倍,距离保持不变(从太阳系的行星中排除)
Pluto
(
name
=
"冥王星"
,
size_scale
=
10e3
),
# 冥王星放大 10000 倍,距离保持不变(从太阳系的行星中排除)
]
]
init_bodies_pos_vels
(
bodies
)
def
on_ready
():
"""
事件绑定后,模拟器运行前会触发
@return:
"""
# 创建天空
# camera.clip_plane_near = 0.1
camera
.
clip_plane_far
=
1000000
create_sphere_sky
(
scale
=
200000
)
application
.
time_scale
=
5
# 运行前会触发 on_ready
UrsinaEvent
.
on_ready_subscription
(
on_ready
)
# 使用 ursina 查看的运行效果
# 使用 ursina 查看的运行效果
# 常用快捷键: P:运行和暂停 O:重新开始 I:显示天体轨迹
# 常用快捷键: P:运行和暂停 O:重新开始 I:显示天体轨迹
# position = 左-右+、上+下-、前+后-
# position = 左-右+、上+下-、前+后-
ursina_run
(
bodies
,
SECONDS_PER_MONTH
,
position
=
(
0
,
2
*
AU
,
-
11
*
AU
),
ursina_run
(
bodies
,
SECONDS_PER_MONTH
,
bg_music
=
"sounds/interstellar.mp3"
)
position
=
(
0
,
2
*
AU
,
-
11
*
AU
),
cosmic_bg
=
''
,
show_grid
=
False
,
# bg_music="sounds/interstellar.mp3"
bg_music
=
'sounds/no_glory.mp3'
,
)
sim_scenes/tri_bodies/two_way_foil.py
浏览文件 @
6a737b91
...
@@ -11,7 +11,7 @@ import time
...
@@ -11,7 +11,7 @@ import time
from
ursina
import
camera
,
application
from
ursina
import
camera
,
application
from
bodies
import
Sun
,
Mercury
,
Venus
,
Earth
,
Mars
,
Jupiter
,
Saturn
,
Uranus
,
Neptune
,
Pluto
from
bodies
import
Sun
,
Mercury
,
Venus
,
Earth
,
Mars
,
Jupiter
,
Saturn
,
Uranus
,
Neptune
,
Pluto
from
common.celestial_data_service
import
get_init_pos_vels
from
common.celestial_data_service
import
get_init_pos_vels
,
init_bodies_pos_vels
from
common.consts
import
SECONDS_PER_WEEK
,
AU
from
common.consts
import
SECONDS_PER_WEEK
,
AU
from
objs
import
QuadObj
,
CircleObj
,
Obj
from
objs
import
QuadObj
,
CircleObj
,
Obj
from
sim_scenes.func
import
camera_look_at
,
two_bodies_colliding
from
sim_scenes.func
import
camera_look_at
,
two_bodies_colliding
...
@@ -44,15 +44,16 @@ class TwoWayFoilSim:
...
@@ -44,15 +44,16 @@ class TwoWayFoilSim:
]
]
# endregion
# endregion
# 获取模拟的初始位置和速度
init_bodies_pos_vels
(
self
.
bodies
)
init_pos_vels
=
get_init_pos_vels
()
# # 获取模拟的初始位置和速度
# init_pos_vels = get_init_pos_vels()
for
body
in
self
.
bodies
:
#
pos_vels
=
init_pos_vels
.
get
(
type
(
body
).
__name__
.
lower
(),
None
)
# for body in self.bodies:
if
pos_vels
is
None
:
# pos_vels = init_pos_vels.get(type(body).__name__.lower(), None)
continue
# if pos_vels is None:
body
.
init_position
=
pos_vels
[
'pos'
]
# continue
body
.
init_velocity
=
pos_vels
[
'vel'
]
# body.init_position = pos_vels['pos']
# body.init_velocity = pos_vels['vel']
def
build_two_way_foil
(
self
):
def
build_two_way_foil
(
self
):
"""
"""
...
...
sim_scenes/tri_bodies/two_way_foil_02.py
浏览文件 @
6a737b91
...
@@ -11,7 +11,7 @@ import time
...
@@ -11,7 +11,7 @@ import time
from
ursina
import
camera
,
application
from
ursina
import
camera
,
application
from
bodies
import
Sun
,
Mercury
,
Venus
,
Earth
,
Mars
,
Jupiter
,
Saturn
,
Uranus
,
Neptune
,
Pluto
from
bodies
import
Sun
,
Mercury
,
Venus
,
Earth
,
Mars
,
Jupiter
,
Saturn
,
Uranus
,
Neptune
,
Pluto
from
common.celestial_data_service
import
get_init_pos_vels
from
common.celestial_data_service
import
get_init_pos_vels
,
init_bodies_pos_vels
from
common.consts
import
SECONDS_PER_WEEK
,
AU
from
common.consts
import
SECONDS_PER_WEEK
,
AU
from
objs
import
QuadObj
,
CircleObj
,
Obj
from
objs
import
QuadObj
,
CircleObj
,
Obj
from
sim_scenes.func
import
camera_look_at
,
two_bodies_colliding
from
sim_scenes.func
import
camera_look_at
,
two_bodies_colliding
...
@@ -44,15 +44,16 @@ class TwoWayFoilSim:
...
@@ -44,15 +44,16 @@ class TwoWayFoilSim:
]
]
# endregion
# endregion
# 获取模拟的初始位置和速度
init_bodies_pos_vels
(
self
.
bodies
)
init_pos_vels
=
get_init_pos_vels
()
# # 获取模拟的初始位置和速度
# init_pos_vels = get_init_pos_vels()
for
body
in
self
.
bodies
:
#
pos_vels
=
init_pos_vels
.
get
(
type
(
body
).
__name__
.
lower
(),
None
)
# for body in self.bodies:
if
pos_vels
is
None
:
# pos_vels = init_pos_vels.get(type(body).__name__.lower(), None)
continue
# if pos_vels is None:
body
.
init_position
=
pos_vels
[
'pos'
]
# continue
body
.
init_velocity
=
pos_vels
[
'vel'
]
# body.init_position = pos_vels['pos']
# body.init_velocity = pos_vels['vel']
def
build_two_way_foil
(
self
):
def
build_two_way_foil
(
self
):
"""
"""
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录