Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Python_超人
宇宙模拟器
提交
3e5672dc
宇宙模拟器
项目概览
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看板
提交
3e5672dc
编写于
10月 28, 2023
作者:
三月三net
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Python超人-宇宙模拟器(哈雷彗星模拟2代码清理备份)
上级
a1947921
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
21 addition
and
15 deletion
+21
-15
sim_scenes/solar_system/halley_comet_sim_02.py
sim_scenes/solar_system/halley_comet_sim_02.py
+21
-15
未找到文件。
sim_scenes/solar_system/halley_comet_sim_02.py
浏览文件 @
3e5672dc
...
@@ -8,10 +8,13 @@
...
@@ -8,10 +8,13 @@
# ==============================================================================
# ==============================================================================
import
time
import
time
import
math
import
math
from
ursina
import
camera
,
application
import
pytz
from
ursina
import
camera
,
application
from
astropy.time
import
Time
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
,
init_bodies_reality_pos_vels
,
get_reality_orbit_points
from
common.celestial_data_service
import
get_init_pos_vels
,
init_bodies_reality_pos_vels
,
get_reality_orbit_points
,
\
conv_to_astropy_time
from
common.color_utils
import
trail_color_brightest
from
common.color_utils
import
trail_color_brightest
from
common.consts
import
SECONDS_PER_YEAR
,
AU
from
common.consts
import
SECONDS_PER_YEAR
,
AU
from
common.func
import
calculate_distance
from
common.func
import
calculate_distance
...
@@ -29,8 +32,14 @@ class HalleyCometSim:
...
@@ -29,8 +32,14 @@ class HalleyCometSim:
哈雷彗星场景模拟
哈雷彗星场景模拟
"""
"""
def
__init__
(
self
):
def
__init__
(
self
,
dt
=
None
):
pass
if
dt
is
None
:
self
.
dt
=
Time
.
now
()
elif
isinstance
(
dt
,
str
):
self
.
dt
=
conv_to_astropy_time
(
dt
)
else
:
self
.
dt
=
dt
# print("北京时间:", dt.to_datetime(timezone=pytz.timezone('Asia/Shanghai')))
def
build_solar_system
(
self
):
def
build_solar_system
(
self
):
# region 构建太阳系
# region 构建太阳系
...
@@ -73,7 +82,8 @@ class HalleyCometSim:
...
@@ -73,7 +82,8 @@ class HalleyCometSim:
# ]
# ]
# endregion
# endregion
trail_color_brightest
(
self
.
bodies
)
trail_color_brightest
(
self
.
bodies
)
init_bodies_reality_pos_vels
(
self
.
bodies
)
init_bodies_reality_pos_vels
(
self
.
bodies
,
self
.
dt
)
def
build_halley_comet
(
self
):
def
build_halley_comet
(
self
):
"""
"""
...
@@ -135,7 +145,8 @@ class HalleyCometSim:
...
@@ -135,7 +145,8 @@ class HalleyCometSim:
def
create_orbit_line
(
self
,
center_body
,
body
):
def
create_orbit_line
(
self
,
center_body
,
body
):
orbital_days
=
int
(
math
.
ceil
(
body
.
orbital_days
*
1.02
))
orbital_days
=
int
(
math
.
ceil
(
body
.
orbital_days
*
1.02
))
points
=
get_reality_orbit_points
(
type
(
body
).
__name__
.
lower
(),
days
=
orbital_days
,
segments
=
100
)
points
=
get_reality_orbit_points
(
type
(
body
).
__name__
.
lower
(),
start_time
=
self
.
dt
,
days
=
orbital_days
,
segments
=
100
)
# print(points)
# print(points)
orbit_line
=
create_orbit_by_points
(
center_body
.
position
,
points
,
line_color
=
body
.
trail_color
)
orbit_line
=
create_orbit_by_points
(
center_body
.
position
,
points
,
line_color
=
body
.
trail_color
)
return
orbit_line
return
orbit_line
...
@@ -158,7 +169,7 @@ class HalleyCometSim:
...
@@ -158,7 +169,7 @@ class HalleyCometSim:
# WorldGrid().draw_axises(10)
# WorldGrid().draw_axises(10)
application
.
time_scale
=
5
application
.
time_scale
=
5
#
self.orbit_lines = []
self
.
orbit_lines
=
[]
for
body
in
self
.
bodies
[
1
:]:
for
body
in
self
.
bodies
[
1
:]:
if
isinstance
(
body
,
HalleComet
):
if
isinstance
(
body
,
HalleComet
):
continue
continue
...
@@ -212,7 +223,7 @@ body.position - sun.position
...
@@ -212,7 +223,7 @@ body.position - sun.position
# # 海王星 2.6574795246124268 93.01887512207031 -90.14009857177734
# # 海王星 2.6574795246124268 93.01887512207031 -90.14009857177734
# orbit_line.body = body
# orbit_line.body = body
#
self.orbit_lines.append(orbit_line)
self
.
orbit_lines
.
append
(
orbit_line
)
self
.
text_panel
=
create_text_panel
()
self
.
text_panel
=
create_text_panel
()
...
@@ -232,13 +243,8 @@ body.position - sun.position
...
@@ -232,13 +243,8 @@ body.position - sun.position
d
=
calculate_distance
(
self
.
halley_comet
.
position
,
self
.
sun
.
position
)
d
=
calculate_distance
(
self
.
halley_comet
.
position
,
self
.
sun
.
position
)
self
.
text_panel
.
text
=
"哈雷彗星距离太阳:%.3f AU"
%
(
d
/
AU
)
self
.
text_panel
.
text
=
"哈雷彗星距离太阳:%.3f AU"
%
(
d
/
AU
)
# for i, orbit_line in enumerate(self.orbit_lines):
for
i
,
orbit_line
in
enumerate
(
self
.
orbit_lines
):
# if i < 4:
orbit_line
.
position
=
self
.
sun
.
planet
.
position
# adj_scale = False
# else:
# adj_scale = True
# # 由于天体运行不是标准的圆形,则需要动态调整轨道的大小,保证轨道线始终在天体的中心位置
# orbit_line.auto_adjust(adj_scale=adj_scale)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录