Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Python_超人
宇宙模拟器
提交
718e9a67
宇宙模拟器
项目概览
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看板
提交
718e9a67
编写于
4月 02, 2024
作者:
三月三net
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Python超人-宇宙模拟器
上级
7571125f
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
84 addition
and
35 deletion
+84
-35
common/celestial_data_service.py
common/celestial_data_service.py
+7
-2
sim_scenes/featured/earth_seasons_live.md
sim_scenes/featured/earth_seasons_live.md
+7
-0
sim_scenes/featured/earth_seasons_live.py
sim_scenes/featured/earth_seasons_live.py
+70
-33
未找到文件。
common/celestial_data_service.py
浏览文件 @
718e9a67
...
...
@@ -127,7 +127,7 @@ def get_celestial_body_data(body_name):
def
set_solar_system_celestial_position
(
bodies
,
dt
,
recalc_moon_pos
,
recalc_moon_pos_scale
=
50
,
set_velocity
=
True
,
set_acceleration
=
True
):
set_velocity
=
True
,
set_acceleration
=
True
,
center_pos
=
None
):
"""
根据日期时间 dt 设置太阳系中天体的真实位置
...
...
@@ -183,8 +183,13 @@ def set_solar_system_celestial_position(bodies, dt, recalc_moon_pos, recalc_moon
posvel
[
1
].
z
.
value
*
AU
/
SECONDS_PER_DAY
,
posvel
[
1
].
y
.
value
*
AU
/
SECONDS_PER_DAY
]
# 实时调整天体的位置和速度
body
.
position
=
np
.
array
(
position
)
if
center_pos
is
None
:
body
.
position
=
np
.
array
(
position
)
else
:
body
.
position
=
np
.
array
(
position
)
-
center_pos
if
set_velocity
:
body
.
velocity
=
np
.
array
(
velocity
)
...
...
sim_scenes/featured/earth_seasons_live.md
0 → 100644
浏览文件 @
718e9a67
2024/01/02 11:51 水星留(视赤经17.45h),转为顺行
2024/01/03 15:52 月球过天赤道,进入南半球,月球视赤纬0度
2024/01/09 04:10 金星合月,金星在月球以北5.70度?
2024/01/10 02:47 水星合月,水星在月球以北6.59度?
2024/04/09 09:24 水星合月,水星在月球以北2.19度
\ No newline at end of file
sim_scenes/featured/earth_seasons_live.py
浏览文件 @
718e9a67
...
...
@@ -8,8 +8,8 @@
# ==============================================================================
from
ursina
import
camera
,
window
,
Text
,
color
from
bodies
import
Sun
,
Earth
,
Moon
from
common.celestial_data_service
import
set_solar_system_celestial_position
,
conv_to_astropy_time
from
bodies
import
*
from
common.celestial_data_service
import
set_solar_system_celestial_position
,
conv_to_astropy_time
,
get_body_posvel
from
common.consts
import
SECONDS_PER_DAY
,
AU
from
sim_scenes.featured.earth_seasons_base
import
EarthSeasonsSimBase
from
sim_scenes.func
import
ursina_run
,
camera_look_at
,
create_sphere_sky
...
...
@@ -19,19 +19,34 @@ from simulators.ursina.entities.body_timer import TimeData, BodyTimer
from
simulators.ursina.ui.control_ui
import
ControlUI
from
simulators.ursina.ursina_config
import
UrsinaConfig
from
simulators.ursina.ursina_event
import
UrsinaEvent
from
simulators.ursina_simulator
import
UrsinaSimulator
import
numpy
as
np
class
EarthSeasonsSimLive
(
EarthSeasonsSimBase
):
def
__init__
(
self
):
super
(
EarthSeasonsSimLive
,
self
).
__init__
(
exit_at_total_days
=
370
,
super
(
EarthSeasonsSimLive
,
self
).
__init__
(
sun_transparent
=
False
,
exit_at_total_days
=
370
,
delay_run
=
False
,
earth_cn_size_factor
=
1.01
,
earth_clouds_size_factor
=
1.015
)
self
.
start_time
=
'2023-12-20 00:00:00'
self
.
sun
.
size_scale
=
3e1
self
.
moon
=
Moon
(
name
=
"月球"
,
size_scale
=
5e3
,
rotation_speed
=
0.645
)
# 月球
self
.
bodies
.
append
(
self
.
moon
)
self
.
mercury
=
Mercury
(
size_scale
=
5e3
)
self
.
venus
=
Venus
(
name
=
"金星"
,
size_scale
=
5e3
)
self
.
mars
=
Mars
(
size_scale
=
5e3
)
self
.
jupiter
=
Jupiter
(
size_scale
=
1e3
)
self
.
saturn
=
Saturn
(
size_scale
=
1e3
)
self
.
uranus
=
Uranus
(
size_scale
=
4e3
)
self
.
neptune
=
Neptune
(
size_scale
=
4e3
)
self
.
bodies
+=
[
self
.
moon
,
self
.
mercury
,
self
.
venus
,
self
.
mars
,
self
.
jupiter
,
self
.
saturn
,
self
.
uranus
,
self
.
neptune
]
self
.
last_year
=
None
for
body
in
self
.
bodies
:
if
isinstance
(
body
,
Earth
):
...
...
@@ -40,6 +55,28 @@ class EarthSeasonsSimLive(EarthSeasonsSimBase):
body
.
rotation_speed
*=
2.5
body
.
set_resolution
(
50
)
self
.
season_earths
=
[
self
.
earth_1
,
self
.
earth_2
,
self
.
earth_3
,
self
.
earth_4
]
self
.
planets
=
[]
self
.
jieqis
=
{
"春分-2023"
:
'2023-03-21 00:00:00'
,
"夏至-2023"
:
'2023-06-21 00:00:00'
,
"秋分-2023"
:
'2023-09-23 00:00:00'
,
"冬至-2023"
:
'2023-12-22 00:00:00'
,
"春分-2024"
:
'2024-03-20 00:00:00'
,
"夏至-2024"
:
'2024-06-21 00:00:00'
,
"秋分-2024"
:
'2024-09-22 00:00:00'
,
"冬至-2024"
:
'2024-12-21 00:00:00'
,
"春分-2025"
:
'2025-03-20 00:00:00'
,
"夏至-2025"
:
'2025-06-21 00:00:00'
,
"秋分-2025"
:
'2025-09-23 00:00:00'
,
"冬至-2025"
:
'2024-12-21 00:00:00'
,
}
for
body
in
self
.
bodies
:
if
body
not
in
self
.
season_earths
:
self
.
planets
.
append
(
body
)
def
earth_text_display
(
self
,
term_name
):
for
e
in
[
self
.
earth_1
,
self
.
earth_2
,
self
.
earth_3
,
self
.
earth_4
]:
# if hasattr(e, "name_text"):
...
...
@@ -48,6 +85,12 @@ class EarthSeasonsSimLive(EarthSeasonsSimBase):
# else:
e
.
name_text
.
enabled
=
True
def
get_center_pos
(
self
,
dt
):
posvel
=
get_body_posvel
(
self
.
earth
,
dt
)
position
=
[
posvel
[
0
].
x
.
value
*
AU
,
posvel
[
0
].
z
.
value
*
AU
,
posvel
[
0
].
y
.
value
*
AU
]
center_pos
=
np
.
array
(
position
)
return
center_pos
def
on_ready
(
self
):
super
(
EarthSeasonsSimLive
,
self
).
on_ready
()
# camera_look_at(self.sun, rotation_z=0)
...
...
@@ -57,7 +100,7 @@ class EarthSeasonsSimLive(EarthSeasonsSimBase):
self
.
earth_4
.
planet
.
alpha
=
0.2
self
.
earth
.
planet
.
name_text
.
enabled
=
False
# , self.earth_clouds, self.earth_cn
# , self.earth_clouds, self.earth_cn
self
.
earth_1
.
planet
.
rotation_y
=
115
# 春分
self
.
earth_2
.
planet
.
rotation_y
=
15
# 夏至
...
...
@@ -67,13 +110,14 @@ class EarthSeasonsSimLive(EarthSeasonsSimBase):
self
.
moon
.
planet
.
rotation_y
=
180
self
.
show_title
()
camera
.
fov
=
140
window
.
borderless
=
True
window
.
exit_button
=
False
# window.fullscreen = True
window
.
position
=
(
1920
,
0
)
# 设置窗口的宽度和高度
window
.
size
=
(
2340
,
1079
)
#
window.position = (1920, 0)
#
#
设置窗口的宽度和高度
#
window.size = (2340, 1079)
def
on_timer_changed
(
self
,
time_data
:
TimeData
):
super
(
EarthSeasonsSimLive
,
self
).
on_timer_changed
(
time_data
)
...
...
@@ -81,6 +125,9 @@ class EarthSeasonsSimLive(EarthSeasonsSimBase):
dt
=
time_data
.
get_datetime
(
self
.
start_time
)
self
.
set_bodies_position
(
time_data
)
self
.
show_clock
(
dt
)
ec
=
UrsinaSimulator
.
EditorCamera
# ec.target_z -= 0.05
# camera.position += camera.left * 0.0001
def
set_bodies_position
(
self
,
time_data
:
TimeData
):
"""
...
...
@@ -88,34 +135,20 @@ class EarthSeasonsSimLive(EarthSeasonsSimBase):
@param time_data:
@return:
"""
jieqis
=
{
"春分-2023"
:
'2023-03-21 00:00:00'
,
"夏至-2023"
:
'2023-06-21 00:00:00'
,
"秋分-2023"
:
'2023-09-23 00:00:00'
,
"冬至-2023"
:
'2023-12-22 00:00:00'
,
"春分-2024"
:
'2024-03-20 00:00:00'
,
"夏至-2024"
:
'2024-06-21 00:00:00'
,
"秋分-2024"
:
'2024-09-22 00:00:00'
,
"冬至-2024"
:
'2024-12-21 00:00:00'
,
"春分-2025"
:
'2025-03-20 00:00:00'
,
"夏至-2025"
:
'2025-06-21 00:00:00'
,
"秋分-2025"
:
'2025-09-23 00:00:00'
,
"冬至-2025"
:
'2024-12-21 00:00:00'
,
}
dt
=
conv_to_astropy_time
(
self
.
start_time
)
bodies
=
[]
center_pos
=
self
.
get_center_pos
(
dt
)
year
=
int
(
dt
.
jyear
)
for
body
in
self
.
bodies
:
jieqir
=
jieqis
.
get
(
f
"
{
body
.
name
}
-
{
year
}
"
,
None
)
if
jieqir
is
not
None
:
jieqir
=
conv_to_astropy_time
(
jieqir
)
set_solar_system_celestial_position
([
body
],
jieqir
,
False
)
else
:
bodies
.
append
(
body
)
if
self
.
last_year
!=
year
:
for
body
in
self
.
season_earths
:
jieqir
=
self
.
jieqis
.
get
(
f
"
{
body
.
name
}
-
{
year
}
"
,
None
)
if
jieqir
is
not
None
:
jieqir
=
conv_to_astropy_time
(
jieqir
)
set_solar_system_celestial_position
([
body
],
jieqir
,
False
,
center_pos
=
center_pos
)
self
.
last_year
=
year
t
=
dt
+
time_data
.
total_days
set_solar_system_celestial_position
(
bodies
,
t
,
True
,
recalc_moon_pos_scale
=
180
)
set_solar_system_celestial_position
(
self
.
planets
,
t
,
True
,
recalc_moon_pos_scale
=
180
,
center_pos
=
center_pos
)
def
exit_handle
(
self
):
UrsinaEvent
.
on_reset
()
...
...
@@ -128,10 +161,13 @@ class EarthSeasonsSimLive(EarthSeasonsSimBase):
aspect_ratio
=
window
.
aspect_ratio
position
,
origin
=
(
-
0.5
*
aspect_ratio
-
0.1
,
0.48
),
(
-
0.05
,
0.1
)
position2
,
origin2
=
(
-
0.5
*
aspect_ratio
-
0.1
,
0.40
),
(
-
0.05
,
0.1
)
text1
=
Text
(
text
=
"太阳视角:观察日食月食"
,
color
=
color
.
white
,
scale
=
2.5
,
position
=
position
,
# (-0.98, 0.48),
# text1 = Text(text="太阳视角:观察日食月食", color=color.white, scale=2.5, position=position, # (-0.98, 0.48),
# font=font)
ext1
=
Text
(
text
=
"太阳视角:2024年重要天象"
,
color
=
color
.
white
,
scale
=
2.5
,
position
=
position
,
# (-0.98, 0.48),
font
=
font
)
text2
=
Text
(
text
=
"(地球自转放慢10倍)"
,
color
=
color
.
white
,
scale
=
1.5
,
position
=
position2
,
# (-0.98, 0.48),
font
=
font
)
# 2024年重要天象
def
show_clock
(
self
,
dt
):
"""
...
...
@@ -163,6 +199,7 @@ if __name__ == '__main__':
sim
.
run
(
# dt=SECONDS_PER_DAY * 10,
# dt=SECONDS_PER_DAY * 3,
init_position
=
[
0
,
0
,
-
2
*
AU
],
show_exit_button
=
False
,
show_camera_info
=
False
,
gravity_works
=
False
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录