Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Python_超人
宇宙模拟器
提交
09cb9f75
宇宙模拟器
项目概览
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看板
提交
09cb9f75
编写于
3月 16, 2024
作者:
三月三net
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Python超人-宇宙模拟器
上级
b6ceb267
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
24 addition
and
15 deletion
+24
-15
sim_scenes/sci_pop/sun_earth_moon.py
sim_scenes/sci_pop/sun_earth_moon.py
+24
-15
未找到文件。
sim_scenes/sci_pop/sun_earth_moon.py
浏览文件 @
09cb9f75
...
@@ -20,7 +20,7 @@ from simulators.ursina.entities.entity_utils import create_directional_light
...
@@ -20,7 +20,7 @@ from simulators.ursina.entities.entity_utils import create_directional_light
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
from
simulators.ursina.ursina_mesh
import
create_orbit_by_points
from
simulators.ursina.ursina_mesh
import
create_orbit_by_points
,
create_circle_line
class
SunEarthMoonSim
(
UniverseSimScenes
):
class
SunEarthMoonSim
(
UniverseSimScenes
):
...
@@ -43,10 +43,10 @@ class SunEarthMoonSim(UniverseSimScenes):
...
@@ -43,10 +43,10 @@ class SunEarthMoonSim(UniverseSimScenes):
self
.
earth_start
=
Earth
(
size_scale
=
9.5e2
,
show_trail
=
False
,
rotation_speed
=
0
)
self
.
earth_start
=
Earth
(
size_scale
=
9.5e2
,
show_trail
=
False
,
rotation_speed
=
0
)
self
.
camera_look
=
CoreValagaClas
(
name
=
"摄像机镜头"
,
mass
=
1e30
,
color
=
(
111
,
140
,
255
),
self
.
camera_look
=
CoreValagaClas
(
name
=
"摄像机镜头"
,
mass
=
1e30
,
color
=
(
111
,
140
,
255
),
init_position
=
[
0
,
0
,
0
],
init_position
=
[
0
,
0
,
0
],
# init_position=[0, 3.3 * AU, -AU],
# init_position=[0, 3.3 * AU, -AU],
init_velocity
=
[
0
,
0
,
0
],
init_velocity
=
[
0
,
0
,
0
],
size_scale
=
1e4
).
set_ignore_gravity
(
True
)
size_scale
=
1e4
).
set_ignore_gravity
(
True
)
self
.
camera_target
=
CoreValagaClas
(
name
=
"摄像机目的"
,
mass
=
1e30
,
color
=
(
111
,
140
,
255
),
self
.
camera_target
=
CoreValagaClas
(
name
=
"摄像机目的"
,
mass
=
1e30
,
color
=
(
111
,
140
,
255
),
# init_position=[0, 0, 0],
# init_position=[0, 0, 0],
...
@@ -54,7 +54,10 @@ class SunEarthMoonSim(UniverseSimScenes):
...
@@ -54,7 +54,10 @@ class SunEarthMoonSim(UniverseSimScenes):
init_velocity
=
[
0
,
0
,
0
],
init_velocity
=
[
0
,
0
,
0
],
size_scale
=
1e4
).
set_ignore_gravity
(
True
)
size_scale
=
1e4
).
set_ignore_gravity
(
True
)
self
.
bodies
=
[
self
.
sun
,
self
.
earth
,
self
.
moon
,
self
.
earth_start
,
self
.
camera_look
,
self
.
camera_target
]
self
.
bodies
=
[
self
.
sun
,
self
.
earth
,
self
.
moon
,
self
.
earth_start
,
# self.camera_look,
# self.camera_target
]
for
body
in
self
.
bodies
:
for
body
in
self
.
bodies
:
body
.
init_velocity
=
[
0
,
0
,
0
]
body
.
init_velocity
=
[
0
,
0
,
0
]
...
@@ -102,9 +105,10 @@ class SunEarthMoonSim(UniverseSimScenes):
...
@@ -102,9 +105,10 @@ class SunEarthMoonSim(UniverseSimScenes):
# TODO: 调试用
# TODO: 调试用
if
dt
.
month
<
12
:
if
dt
.
month
<
12
:
UrsinaConfig
.
run_speed_factor
=
20
0
*
24
UrsinaConfig
.
run_speed_factor
=
5
0
*
24
elif
UrsinaConfig
.
run_speed_factor
>
20
*
24
:
elif
UrsinaConfig
.
run_speed_factor
>
20
*
24
:
UrsinaConfig
.
run_speed_factor
=
20
*
24
UrsinaConfig
.
run_speed_factor
=
20
*
24
# TODO: 调试用
if
dt
.
month
>=
12
and
dt
.
day
>=
31
:
if
dt
.
month
>=
12
and
dt
.
day
>=
31
:
if
dt
.
hour
>
20
:
if
dt
.
hour
>
20
:
...
@@ -153,7 +157,12 @@ class SunEarthMoonSim(UniverseSimScenes):
...
@@ -153,7 +157,12 @@ class SunEarthMoonSim(UniverseSimScenes):
创建太阳系天体的真实轨迹(太阳和哈雷彗星除外)
创建太阳系天体的真实轨迹(太阳和哈雷彗星除外)
@return:
@return:
"""
"""
self
.
create_orbit_line
(
self
.
sun
,
self
.
earth
,
self
.
start_time
,
alpha
=
0.5
)
# self.moon.orbital_days=27.5
self
.
create_orbit_line
(
self
.
sun
,
self
.
earth
,
self
.
start_time
,
alpha
=
1
)
# self.create_orbit_line(self.sun, self.moon, self.start_time, alpha=0.5)
orbit_line
=
create_circle_line
(
parent
=
self
.
earth
.
planet
.
main_entity
,
radius
=
10
,
thickness
=
2
,
color
=
self
.
moon
.
trail_color
,
alpha
=
1
)
orbit_line
.
rotation_x
=
40
# for body in self.bodies[1:]:
# for body in self.bodies[1:]:
# if isinstance(body, Earth):
# if isinstance(body, Earth):
...
@@ -211,7 +220,6 @@ class SunEarthMoonSim(UniverseSimScenes):
...
@@ -211,7 +220,6 @@ class SunEarthMoonSim(UniverseSimScenes):
# 月球围绕地球转一圈的时间,即月球真正的公转周期是一个恒星月,时间是27.5天 。
# 月球围绕地球转一圈的时间,即月球真正的公转周期是一个恒星月,时间是27.5天 。
# 而我们一般用从地球上看,月球完成一次朔望更替为一个月,叫一个朔望月,时间是29.5天。
# 而我们一般用从地球上看,月球完成一次朔望更替为一个月,叫一个朔望月,时间是29.5天。
aspect_ratio
=
window
.
aspect_ratio
aspect_ratio
=
window
.
aspect_ratio
position
,
origin
=
(
0.5
*
aspect_ratio
-
0.15
,
-
0.45
),
(
-
0.05
,
0.1
),
position
,
origin
=
(
0.5
*
aspect_ratio
-
0.15
,
-
0.45
),
(
-
0.05
,
0.1
),
# ControlUI.current_ui.show_message(dt.strftime('%Y-%m-%d'),
# ControlUI.current_ui.show_message(dt.strftime('%Y-%m-%d'),
...
@@ -224,10 +232,10 @@ class SunEarthMoonSim(UniverseSimScenes):
...
@@ -224,10 +232,10 @@ class SunEarthMoonSim(UniverseSimScenes):
# close_time=-1)
# close_time=-1)
self
.
text_panel
.
text
=
"
\n
日期时间:
\n
"
+
dt
.
strftime
(
'%Y-%m-%d %H:%M'
)
+
"
\n\n
"
+
\
self
.
text_panel
.
text
=
"
\n
日期时间:
\n
"
+
dt
.
strftime
(
'%Y-%m-%d %H:%M'
)
+
"
\n\n
"
+
\
"天数:"
+
str
(
round
(
total_days
,
2
))
+
"
\n\n
"
+
\
"天数:"
+
str
(
round
(
total_days
,
2
))
+
"
\n\n
"
+
\
"月数:"
+
str
(
round
(
total_days
/
29.5
,
2
))
"月数:"
+
str
(
round
(
total_days
/
29.5
,
2
))
# "运行速度:" + str(UrsinaConfig.run_speed_factor) + "\n" + \
# "运行速度:" + str(UrsinaConfig.run_speed_factor) + "\n" + \
# "天数:" + str(round(total_days, 3))
# "天数:" + str(round(total_days, 3))
def
update_text_panel
(
self
,
time_data
):
def
update_text_panel
(
self
,
time_data
):
"""
"""
...
@@ -255,7 +263,7 @@ class SunEarthMoonSim(UniverseSimScenes):
...
@@ -255,7 +263,7 @@ class SunEarthMoonSim(UniverseSimScenes):
# self.set_window_size((1920 , 1080 ), False)
# self.set_window_size((1920 , 1080 ), False)
camera_look_at
(
self
.
sun
)
camera_look_at
(
self
.
sun
)
# 显示网格以及坐标线
# 显示网格以及坐标线
# self.show_grid_axises(scale_factor=
100
)
# self.show_grid_axises(scale_factor=
8
)
# 创建太阳系天体的真实轨迹(太阳和哈雷彗星除外)
# 创建太阳系天体的真实轨迹(太阳和哈雷彗星除外)
self
.
create_orbit_lines
()
self
.
create_orbit_lines
()
...
@@ -280,7 +288,8 @@ class SunEarthMoonSim(UniverseSimScenes):
...
@@ -280,7 +288,8 @@ class SunEarthMoonSim(UniverseSimScenes):
self
.
start_time
=
start_time
self
.
start_time
=
start_time
ursina_run
(
self
.
bodies
,
ursina_run
(
self
.
bodies
,
SECONDS_PER_DAY
/
24
,
SECONDS_PER_DAY
/
24
,
position
=
(
0
,
3.5
*
AU
,
-
AU
),
# position=(0, 3.5 * AU, -AU), # 顶上
position
=
(
0
,
1
*
AU
,
-
3.5
*
AU
),
gravity_works
=
False
,
gravity_works
=
False
,
cosmic_bg
=
''
,
cosmic_bg
=
''
,
show_trail
=
True
,
show_trail
=
True
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录