Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Python_超人
宇宙模拟器
提交
a46ef7fa
宇宙模拟器
项目概览
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看板
提交
a46ef7fa
编写于
6月 24, 2023
作者:
三月三net
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Python超人-宇宙模拟器
上级
fa73092d
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
33 addition
and
4 deletion
+33
-4
sim_scenes/fiction/earth_orbit_stopped.py
sim_scenes/fiction/earth_orbit_stopped.py
+33
-4
未找到文件。
sim_scenes/fiction/earth_orbit_stopped.py
浏览文件 @
a46ef7fa
...
@@ -8,7 +8,9 @@
...
@@ -8,7 +8,9 @@
# ==============================================================================
# ==============================================================================
from
bodies
import
Sun
,
Earth
,
Mercury
,
Venus
from
bodies
import
Sun
,
Earth
,
Mercury
,
Venus
from
common.consts
import
SECONDS_PER_HOUR
,
SECONDS_PER_HALF_DAY
,
SECONDS_PER_DAY
,
SECONDS_PER_WEEK
,
SECONDS_PER_MONTH
from
common.consts
import
SECONDS_PER_HOUR
,
SECONDS_PER_HALF_DAY
,
SECONDS_PER_DAY
,
SECONDS_PER_WEEK
,
SECONDS_PER_MONTH
from
sim_scenes.func
import
mayavi_run
,
ursina_run
,
camera_look_at
,
two_bodies_colliding
,
set_camera_parent
from
common.func
import
calculate_distance
from
sim_scenes.func
import
mayavi_run
,
ursina_run
,
camera_look_at
,
two_bodies_colliding
,
set_camera_parent
,
\
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.ui.control_ui
import
ControlUI
from
simulators.ursina.ui.control_ui
import
ControlUI
...
@@ -57,6 +59,7 @@ class EarthOrbitStoppedSim:
...
@@ -57,6 +59,7 @@ class EarthOrbitStoppedSim:
self
.
arrived_sun
=
None
self
.
arrived_sun
=
None
self
.
arrived_mercury_orbit_line
=
None
self
.
arrived_mercury_orbit_line
=
None
self
.
arrived_venus_orbit_line
=
None
self
.
arrived_venus_orbit_line
=
None
self
.
arrived_info
=
"距离太阳表面:${distance}
\n\n
地球当前速度:${speed}"
def
create_orbit_line
(
self
,
radius
,
color
):
def
create_orbit_line
(
self
,
radius
,
color
):
orbit_line
=
create_circle_line
(
parent
=
self
.
sun
,
radius
=
radius
,
thickness
=
5
,
color
=
color
,
alpha
=
0.3
)
orbit_line
=
create_circle_line
(
parent
=
self
.
sun
,
radius
=
radius
,
thickness
=
5
,
color
=
color
,
alpha
=
0.3
)
...
@@ -68,6 +71,8 @@ class EarthOrbitStoppedSim:
...
@@ -68,6 +71,8 @@ class EarthOrbitStoppedSim:
# 运行前触发
# 运行前触发
application
.
time_scale
=
0.00001
application
.
time_scale
=
0.00001
camera
.
fov
=
50
camera
.
fov
=
50
self
.
text_panel
=
create_text_panel
()
self
.
text_panel
.
text
=
self
.
arrived_info
.
replace
(
"${distance}"
,
"1 AU"
).
replace
(
"${speed}"
,
"0"
)
# 创建水星轨道线
# 创建水星轨道线
self
.
mercury_orbit_line
=
self
.
create_orbit_line
(
self
.
mercury_orbit_line
=
self
.
create_orbit_line
(
radius
=
self
.
mercury_radius
*
UrsinaConfig
.
SCALE_FACTOR
,
radius
=
self
.
mercury_radius
*
UrsinaConfig
.
SCALE_FACTOR
,
...
@@ -92,10 +97,15 @@ class EarthOrbitStoppedSim:
...
@@ -92,10 +97,15 @@ class EarthOrbitStoppedSim:
if
two_bodies_colliding
(
self
.
sun
,
self
.
earth
):
if
two_bodies_colliding
(
self
.
sun
,
self
.
earth
):
self
.
arrived_sun
=
True
self
.
arrived_sun
=
True
msg
=
"地球[%s]到达太阳表面"
%
time_data
.
time_text
msg
=
"地球
在
[%s]到达太阳表面"
%
time_data
.
time_text
print
(
msg
)
print
(
msg
)
self
.
text_panel
.
text
=
self
.
arrived_info
.
\
replace
(
"${distance}"
,
"0 公里"
).
\
replace
(
"${speed}"
,
"%s 公里/秒"
%
round
(
self
.
earth
.
velocity
[
2
],
2
))
\
+
"
\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
()
return
if
time_data
.
days
in
[
40
,
41
]:
if
time_data
.
days
in
[
40
,
41
]:
self
.
venus_orbit_line
.
enabled
=
True
self
.
venus_orbit_line
.
enabled
=
True
...
@@ -114,18 +124,37 @@ class EarthOrbitStoppedSim:
...
@@ -114,18 +124,37 @@ class EarthOrbitStoppedSim:
if
abs
(
self
.
earth
.
position
[
2
])
<
0.721
*
AU
and
not
self
.
arrived_venus_orbit_line
:
if
abs
(
self
.
earth
.
position
[
2
])
<
0.721
*
AU
and
not
self
.
arrived_venus_orbit_line
:
self
.
arrived_venus_orbit_line
=
True
self
.
arrived_venus_orbit_line
=
True
msg
=
"地球
[%s]到达
金星轨道"
%
time_data
.
time_text
msg
=
"地球
在[%s]穿过
金星轨道"
%
time_data
.
time_text
print
(
msg
)
print
(
msg
)
self
.
arrived_info
=
self
.
arrived_info
+
"
\n\n
"
+
msg
print
(
"金星:"
,
self
.
venus
.
position
,
self
.
venus
.
velocity
)
print
(
"金星:"
,
self
.
venus
.
position
,
self
.
venus
.
velocity
)
ControlUI
.
current_ui
.
show_message
(
msg
,
close_time
=
5
)
ControlUI
.
current_ui
.
show_message
(
msg
,
close_time
=
5
)
if
abs
(
self
.
earth
.
position
[
2
])
<
0.384
*
AU
and
not
self
.
arrived_mercury_orbit_line
:
if
abs
(
self
.
earth
.
position
[
2
])
<
0.384
*
AU
and
not
self
.
arrived_mercury_orbit_line
:
self
.
arrived_mercury_orbit_line
=
True
self
.
arrived_mercury_orbit_line
=
True
msg
=
"地球
[%s]到达
水星轨道"
%
time_data
.
time_text
msg
=
"地球
在[%s]穿过
水星轨道"
%
time_data
.
time_text
print
(
msg
)
print
(
msg
)
self
.
arrived_info
=
self
.
arrived_info
+
"
\n\n
"
+
msg
print
(
"水星:"
,
self
.
mercury
.
position
,
self
.
mercury
.
velocity
)
print
(
"水星:"
,
self
.
mercury
.
position
,
self
.
mercury
.
velocity
)
ControlUI
.
current_ui
.
show_message
(
msg
,
close_time
=
5
)
ControlUI
.
current_ui
.
show_message
(
msg
,
close_time
=
5
)
distance
=
calculate_distance
(
self
.
earth
.
position
,
self
.
sun
.
position
)
distance
=
distance
-
self
.
sun
.
raduis
-
self
.
earth
.
raduis
if
distance
>
10000000
:
distance_str
=
"%s 千万"
%
round
(
distance
/
10000000.0
,
3
)
elif
distance
>
1000000
:
distance_str
=
"%s 百万"
%
round
(
distance
/
1000000.0
,
2
)
elif
distance
>
10000
:
distance_str
=
"%s 万"
%
round
(
distance
/
10000.0
,
2
)
else
:
distance_str
=
round
(
distance
,
2
)
self
.
text_panel
.
text
=
self
.
arrived_info
.
\
replace
(
"${distance}"
,
"%s公里"
%
distance_str
).
\
replace
(
"${speed}"
,
"%s 公里/秒"
%
round
(
self
.
earth
.
velocity
[
2
],
2
))
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
"""
"""
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录