Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Python_超人
宇宙模拟器
提交
464d2c88
宇宙模拟器
项目概览
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看板
提交
464d2c88
编写于
6月 24, 2023
作者:
三月三net
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Python超人-宇宙模拟器
上级
375f3cf0
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
13 addition
and
6 deletion
+13
-6
common/func.py
common/func.py
+7
-2
sim_scenes/fiction/earth_orbit_stopped.py
sim_scenes/fiction/earth_orbit_stopped.py
+6
-4
未找到文件。
common/func.py
浏览文件 @
464d2c88
...
@@ -109,12 +109,17 @@ def calculate_distance(pos1, pos2=[0, 0, 0]):
...
@@ -109,12 +109,17 @@ def calculate_distance(pos1, pos2=[0, 0, 0]):
return
d
return
d
def
get_acceleration_info
(
acc
_value
):
def
get_acceleration_info
(
acc
eleration
):
"""
"""
@param acc
_value
: 加速度的值(km/s²)
@param acc
eleration
: 加速度的值(km/s²)
@return:
@return:
"""
"""
if
isinstance
(
acceleration
,
list
)
or
isinstance
(
acceleration
,
np
.
ndarray
):
from
simulators.ursina.entities.entity_utils
import
get_value_direction_vectors
acc_value
,
direction
=
get_value_direction_vectors
(
acceleration
)
else
:
acc_value
=
acceleration
acc_m
=
acc_value
*
1000
# 加速度的值(m/s²)
acc_m
=
acc_value
*
1000
# 加速度的值(m/s²)
...
...
sim_scenes/fiction/earth_orbit_stopped.py
浏览文件 @
464d2c88
...
@@ -13,6 +13,7 @@ from sim_scenes.func import mayavi_run, ursina_run, camera_look_at, two_bodies_c
...
@@ -13,6 +13,7 @@ from sim_scenes.func import mayavi_run, ursina_run, camera_look_at, two_bodies_c
create_text_panel
create_text_panel
from
bodies.body
import
AU
from
bodies.body
import
AU
from
simulators.ursina.entities.body_timer
import
BodyTimer
,
TimeData
from
simulators.ursina.entities.body_timer
import
BodyTimer
,
TimeData
from
simulators.ursina.entities.entity_utils
import
get_value_direction_vectors
from
simulators.ursina.ui.control_ui
import
ControlUI
from
simulators.ursina.ui.control_ui
import
ControlUI
from
simulators.ursina.ursina_config
import
UrsinaConfig
from
simulators.ursina.ursina_config
import
UrsinaConfig
from
simulators.ursina.ursina_event
import
UrsinaEvent
from
simulators.ursina.ursina_event
import
UrsinaEvent
...
@@ -89,7 +90,8 @@ class EarthOrbitStoppedSim:
...
@@ -89,7 +90,8 @@ class EarthOrbitStoppedSim:
earth_pos
=
self
.
earth
.
planet
.
world_position
earth_pos
=
self
.
earth
.
planet
.
world_position
camera
.
world_position
=
Vec3
(
earth_pos
[
0
],
earth_pos
[
1
]
+
0.01
,
earth_pos
[
2
]
-
0.1
)
camera
.
world_position
=
Vec3
(
earth_pos
[
0
],
earth_pos
[
1
]
+
0.01
,
earth_pos
[
2
]
-
0.1
)
acceleration_info
=
get_acceleration_info
(
self
.
earth
.
acceleration
[
2
])
acceleration_info
=
get_acceleration_info
(
self
.
earth
.
acceleration
)
velocity
,
_
=
get_value_direction_vectors
(
self
.
earth
.
velocity
)
if
two_bodies_colliding
(
self
.
sun
,
self
.
earth
):
if
two_bodies_colliding
(
self
.
sun
,
self
.
earth
):
self
.
arrived_sun
=
True
self
.
arrived_sun
=
True
...
@@ -98,7 +100,7 @@ class EarthOrbitStoppedSim:
...
@@ -98,7 +100,7 @@ class EarthOrbitStoppedSim:
self
.
text_panel
.
text
=
self
.
arrived_info
.
\
self
.
text_panel
.
text
=
self
.
arrived_info
.
\
replace
(
"${distance}"
,
"0 km"
).
\
replace
(
"${distance}"
,
"0 km"
).
\
replace
(
"${acceleration}"
,
"%s"
%
acceleration_info
).
\
replace
(
"${acceleration}"
,
"%s"
%
acceleration_info
).
\
replace
(
"${speed}"
,
"%s km/s"
%
round
(
self
.
earth
.
velocity
[
2
]
,
2
))
\
replace
(
"${speed}"
,
"%s km/s"
%
round
(
velocity
,
2
))
\
+
"
\n\n
"
+
msg
+
"
\n\n
"
+
msg
ControlUI
.
current_ui
.
show_message
(
msg
,
close_time
=-
1
)
ControlUI
.
current_ui
.
show_message
(
msg
,
close_time
=-
1
)
application
.
pause
()
application
.
pause
()
...
@@ -146,7 +148,7 @@ class EarthOrbitStoppedSim:
...
@@ -146,7 +148,7 @@ class EarthOrbitStoppedSim:
self
.
text_panel
.
text
=
self
.
arrived_info
.
\
self
.
text_panel
.
text
=
self
.
arrived_info
.
\
replace
(
"${distance}"
,
"%s km"
%
distance_str
).
\
replace
(
"${distance}"
,
"%s km"
%
distance_str
).
\
replace
(
"${acceleration}"
,
"%s"
%
acceleration_info
).
\
replace
(
"${acceleration}"
,
"%s"
%
acceleration_info
).
\
replace
(
"${speed}"
,
"%s km/s"
%
round
(
self
.
earth
.
velocity
[
2
]
,
2
))
replace
(
"${speed}"
,
"%s km/s"
%
round
(
velocity
,
2
))
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
...
@@ -183,6 +185,6 @@ if __name__ == '__main__':
...
@@ -183,6 +185,6 @@ if __name__ == '__main__':
# 常用快捷键: P:运行和暂停 O:重新开始 I:显示天体轨迹
# 常用快捷键: P:运行和暂停 O:重新开始 I:显示天体轨迹
# position = 左-右+、上+下-、前+后-
# position = 左-右+、上+下-、前+后-
# position=(0, 0, 0) 的位置是站在地球视角,可以观看月相变化的过程
# position=(0, 0, 0) 的位置是站在地球视角,可以观看月相变化的过程
ursina_run
(
sim
.
bodies
,
SECONDS_PER_DAY
,
position
=
(
0
,
0.0001
*
AU
,
-
0.
0
2
*
AU
),
ursina_run
(
sim
.
bodies
,
SECONDS_PER_DAY
,
position
=
(
0
,
0.0001
*
AU
,
-
0.2
*
AU
),
show_timer
=
True
,
show_timer
=
True
,
show_grid
=
True
)
show_grid
=
True
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录