Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Python_超人
宇宙模拟器
提交
3558bb8c
宇宙模拟器
项目概览
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看板
提交
3558bb8c
编写于
11月 06, 2023
作者:
三月三net
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Python超人-宇宙模拟器
上级
33f7d6af
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
79 addition
and
67 deletion
+79
-67
bodies/earth.py
bodies/earth.py
+2
-0
bodies/jupiter.py
bodies/jupiter.py
+2
-0
bodies/mars.py
bodies/mars.py
+2
-0
bodies/mercury.py
bodies/mercury.py
+2
-0
bodies/neptune.py
bodies/neptune.py
+2
-0
bodies/saturn.py
bodies/saturn.py
+2
-0
bodies/uranus.py
bodies/uranus.py
+2
-0
bodies/venus.py
bodies/venus.py
+2
-0
sim_scenes/solar_system/halley_comet_lib.py
sim_scenes/solar_system/halley_comet_lib.py
+48
-0
sim_scenes/solar_system/halley_comet_sim.py
sim_scenes/solar_system/halley_comet_sim.py
+3
-33
sim_scenes/solar_system/halley_comet_sim_02.py
sim_scenes/solar_system/halley_comet_sim_02.py
+10
-25
sim_scenes/solar_system/halley_comet_sim_03.py
sim_scenes/solar_system/halley_comet_sim_03.py
+2
-9
未找到文件。
bodies/earth.py
浏览文件 @
3558bb8c
...
@@ -51,6 +51,8 @@ class Earth(Body):
...
@@ -51,6 +51,8 @@ class Earth(Body):
"parent"
:
parent
"parent"
:
parent
}
}
super
().
__init__
(
**
params
)
super
().
__init__
(
**
params
)
# 公转周期(天)
self
.
orbital_days
=
365.24219
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
...
...
bodies/jupiter.py
浏览文件 @
3558bb8c
...
@@ -45,6 +45,8 @@ class Jupiter(Body):
...
@@ -45,6 +45,8 @@ class Jupiter(Body):
"show_name"
:
show_name
"show_name"
:
show_name
}
}
super
().
__init__
(
**
params
)
super
().
__init__
(
**
params
)
# 公转周期(天)
self
.
orbital_days
=
11.862
*
365.24219
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
...
...
bodies/mars.py
浏览文件 @
3558bb8c
...
@@ -45,6 +45,8 @@ class Mars(Body):
...
@@ -45,6 +45,8 @@ class Mars(Body):
"show_name"
:
show_name
"show_name"
:
show_name
}
}
super
().
__init__
(
**
params
)
super
().
__init__
(
**
params
)
# 公转周期(天)
self
.
orbital_days
=
686.971
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
...
...
bodies/mercury.py
浏览文件 @
3558bb8c
...
@@ -46,6 +46,8 @@ class Mercury(Body):
...
@@ -46,6 +46,8 @@ class Mercury(Body):
"show_name"
:
show_name
"show_name"
:
show_name
}
}
super
().
__init__
(
**
params
)
super
().
__init__
(
**
params
)
#
self
.
orbital_days
=
87.9691
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
...
...
bodies/neptune.py
浏览文件 @
3558bb8c
...
@@ -46,6 +46,8 @@ class Neptune(Body):
...
@@ -46,6 +46,8 @@ class Neptune(Body):
"show_name"
:
show_name
"show_name"
:
show_name
}
}
super
().
__init__
(
**
params
)
super
().
__init__
(
**
params
)
# 公转周期(天)
self
.
orbital_days
=
164.8
*
365.24219
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
...
...
bodies/saturn.py
浏览文件 @
3558bb8c
...
@@ -47,6 +47,8 @@ class Saturn(Body):
...
@@ -47,6 +47,8 @@ class Saturn(Body):
}
}
self
.
__has_rings
=
True
self
.
__has_rings
=
True
super
().
__init__
(
**
params
)
super
().
__init__
(
**
params
)
# 公转周期(天)
self
.
orbital_days
=
29.4571
*
365.24219
def
show_rings
(
self
,
value
):
def
show_rings
(
self
,
value
):
self
.
__has_rings
=
value
self
.
__has_rings
=
value
...
...
bodies/uranus.py
浏览文件 @
3558bb8c
...
@@ -46,6 +46,8 @@ class Uranus(Body):
...
@@ -46,6 +46,8 @@ class Uranus(Body):
"show_name"
:
show_name
"show_name"
:
show_name
}
}
super
().
__init__
(
**
params
)
super
().
__init__
(
**
params
)
# 公转周期(天)
self
.
orbital_days
=
84.0205
*
365.24219
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
...
...
bodies/venus.py
浏览文件 @
3558bb8c
...
@@ -46,6 +46,8 @@ class Venus(Body):
...
@@ -46,6 +46,8 @@ class Venus(Body):
"show_name"
:
show_name
"show_name"
:
show_name
}
}
super
().
__init__
(
**
params
)
super
().
__init__
(
**
params
)
# 公转周期(天)
self
.
orbital_days
=
224.701
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
...
...
sim_scenes/solar_system/halley_comet_lib.py
0 → 100644
浏览文件 @
3558bb8c
# -*- coding:utf-8 -*-
# title :哈雷彗星场景半真实模拟共用库
# description :
# author :Python超人
# date :2023-11-06
# link :https://gitcode.net/pythoncr/
# python_version :3.9
# ==============================================================================
import
math
from
dataclasses
import
dataclass
from
dataclasses
import
field
from
common.celestial_data_service
import
get_reality_orbit_points
from
common.consts
import
AU
from
objs
import
HalleComet
from
simulators.ursina.ursina_mesh
import
create_orbit_by_points
@
dataclass
(
order
=
True
)
class
HalleyCometParams
:
start_time
:
str
=
field
(
default
=
'1983-03-20 00:00:00'
)
init_velocity
:
list
[
float
]
=
field
(
default_factory
=
[
3.34
,
0
,
10.718
])
init_position
:
list
[
float
]
=
field
(
default_factory
=
[
0
,
0.5
*
AU
,
-
10
*
AU
])
def
create_halley_comet
(
init_velocity
,
init_position
):
"""
创建哈雷彗星
@return:
"""
# 哈雷彗星的平均运行速度约为每小时 70,000 英里或每小时 126,000 公里 。(35公里/秒)
# 每76.1年环绕太阳一周的周期彗星
halley_comet
=
HalleComet
(
# size_scale=4e7,
size_scale
=
1e8
,
init_velocity
=
init_velocity
,
init_position
=
init_position
)
\
.
set_light_disable
(
True
)
return
halley_comet
def
create_orbit_line
(
center_body
,
body
,
start_time
):
orbital_days
=
int
(
math
.
ceil
(
body
.
orbital_days
*
1.02
))
points
=
get_reality_orbit_points
(
type
(
body
).
__name__
.
lower
(),
start_time
=
start_time
,
days
=
orbital_days
,
segments
=
100
)
# print(points)
orbit_line
=
create_orbit_by_points
(
center_body
.
position
,
points
,
line_color
=
body
.
trail_color
)
return
orbit_line
sim_scenes/solar_system/halley_comet_sim.py
浏览文件 @
3558bb8c
...
@@ -20,6 +20,7 @@ from common.func import calculate_distance
...
@@ -20,6 +20,7 @@ from common.func import calculate_distance
from
objs
import
HalleComet
from
objs
import
HalleComet
from
sim_scenes.func
import
create_text_panel
from
sim_scenes.func
import
create_text_panel
from
sim_scenes.func
import
ursina_run
,
create_sphere_sky
from
sim_scenes.func
import
ursina_run
,
create_sphere_sky
from
sim_scenes.solar_system.halley_comet_lib
import
HalleyCometParams
,
create_halley_comet
,
create_orbit_line
from
simulators.ursina.entities.body_timer
import
TimeData
from
simulators.ursina.entities.body_timer
import
TimeData
from
simulators.ursina.entities.entity_utils
import
get_value_direction_vectors
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
...
@@ -30,13 +31,6 @@ from dataclasses import dataclass
...
@@ -30,13 +31,6 @@ from dataclasses import dataclass
from
dataclasses
import
field
from
dataclasses
import
field
@
dataclass
(
order
=
True
)
class
HalleyCometParams
:
start_time
:
str
=
field
(
default
=
'1983-03-20 00:00:00'
)
init_velocity
:
list
[
float
]
=
field
(
default_factory
=
[
3.34
,
0
,
10.718
])
init_position
:
list
[
float
]
=
field
(
default_factory
=
[
0
,
0.5
*
AU
,
-
10
*
AU
])
class
HalleyCometSim
:
class
HalleyCometSim
:
"""
"""
哈雷彗星场景模拟
哈雷彗星场景模拟
...
@@ -80,14 +74,6 @@ class HalleyCometSim:
...
@@ -80,14 +74,6 @@ class HalleyCometSim:
self
.
neptune
,
# 海王星
self
.
neptune
,
# 海王星
# self.pluto, # 冥王星
# self.pluto, # 冥王星
]
]
self
.
mercury
.
orbital_days
=
87.9691
self
.
venus
.
orbital_days
=
224.701
self
.
earth
.
orbital_days
=
365.24219
self
.
mars
.
orbital_days
=
686.971
self
.
jupiter
.
orbital_days
=
11.862
*
365.24219
self
.
saturn
.
orbital_days
=
29.4571
*
365.24219
self
.
uranus
.
orbital_days
=
84.0205
*
365.24219
self
.
neptune
.
orbital_days
=
164.8
*
365.24219
# self.bodies = [
# self.bodies = [
# self.sun, # 太阳
# self.sun, # 太阳
...
@@ -107,27 +93,13 @@ class HalleyCometSim:
...
@@ -107,27 +93,13 @@ class HalleyCometSim:
创建哈雷彗星
创建哈雷彗星
@return:
@return:
"""
"""
# 哈雷彗星的平均运行速度约为每小时 70,000 英里或每小时 126,000 公里 。(35公里/秒)
self
.
halley_comet
=
create_halley_comet
(
self
.
params
.
init_velocity
,
self
.
params
.
init_position
)
# 每76.1年环绕太阳一周的周期彗星
self
.
halley_comet
=
HalleComet
(
# size_scale=4e7,
size_scale
=
0.4e8
,
init_velocity
=
self
.
params
.
init_velocity
,
init_position
=
self
.
params
.
init_position
)
\
.
set_light_disable
(
True
)
self
.
bodies
.
append
(
self
.
halley_comet
)
self
.
bodies
.
append
(
self
.
halley_comet
)
def
build
(
self
):
def
build
(
self
):
self
.
build_solar_system
()
self
.
build_solar_system
()
self
.
build_halley_comet
()
self
.
build_halley_comet
()
def
create_orbit_line
(
self
,
center_body
,
body
):
orbital_days
=
int
(
math
.
ceil
(
body
.
orbital_days
*
1.02
))
points
=
get_reality_orbit_points
(
type
(
body
).
__name__
.
lower
(),
start_time
=
self
.
start_time
,
days
=
orbital_days
,
segments
=
100
)
# print(points)
orbit_line
=
create_orbit_by_points
(
center_body
.
position
,
points
,
line_color
=
body
.
trail_color
)
return
orbit_line
def
on_ready
(
self
):
def
on_ready
(
self
):
"""
"""
...
@@ -150,7 +122,7 @@ class HalleyCometSim:
...
@@ -150,7 +122,7 @@ class HalleyCometSim:
for
body
in
self
.
bodies
[
1
:]:
for
body
in
self
.
bodies
[
1
:]:
if
isinstance
(
body
,
HalleComet
):
if
isinstance
(
body
,
HalleComet
):
continue
continue
orbit_line
=
self
.
create_orbit_line
(
self
.
sun
,
body
)
orbit_line
=
create_orbit_line
(
self
.
sun
,
body
,
self
.
start_time
)
self
.
orbit_lines
.
append
(
orbit_line
)
self
.
orbit_lines
.
append
(
orbit_line
)
self
.
text_panel
=
create_text_panel
()
self
.
text_panel
=
create_text_panel
()
...
@@ -323,8 +295,6 @@ if __name__ == '__main__':
...
@@ -323,8 +295,6 @@ if __name__ == '__main__':
# init_velocity=[-2.841, 4.7, 8.86],
# init_velocity=[-2.841, 4.7, 8.86],
# init_position=[0, -5 * AU, -10 * AU]
# init_position=[0, -5 * AU, -10 * AU]
sim
=
HalleyCometSim
(
params
)
sim
=
HalleyCometSim
(
params
)
sim
.
build
()
sim
.
build
()
...
...
sim_scenes/solar_system/halley_comet_sim_02.py
浏览文件 @
3558bb8c
...
@@ -20,6 +20,7 @@ from common.func import calculate_distance
...
@@ -20,6 +20,7 @@ from common.func import calculate_distance
from
objs
import
HalleComet
from
objs
import
HalleComet
from
sim_scenes.func
import
create_text_panel
from
sim_scenes.func
import
create_text_panel
from
sim_scenes.func
import
ursina_run
,
create_sphere_sky
from
sim_scenes.func
import
ursina_run
,
create_sphere_sky
from
sim_scenes.solar_system.halley_comet_lib
import
create_halley_comet
,
create_orbit_line
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
...
@@ -64,14 +65,6 @@ class HalleyCometSim:
...
@@ -64,14 +65,6 @@ class HalleyCometSim:
self
.
neptune
,
# 海王星
self
.
neptune
,
# 海王星
# self.pluto, # 冥王星
# self.pluto, # 冥王星
]
]
self
.
mercury
.
orbital_days
=
87.9691
self
.
venus
.
orbital_days
=
224.701
self
.
earth
.
orbital_days
=
365.24219
self
.
mars
.
orbital_days
=
686.971
self
.
jupiter
.
orbital_days
=
11.862
*
365.24219
self
.
saturn
.
orbital_days
=
29.4571
*
365.24219
self
.
uranus
.
orbital_days
=
84.0205
*
365.24219
self
.
neptune
.
orbital_days
=
164.8
*
365.24219
# self.bodies = [
# self.bodies = [
# self.sun, # 太阳
# self.sun, # 太阳
...
@@ -88,28 +81,20 @@ class HalleyCometSim:
...
@@ -88,28 +81,20 @@ class HalleyCometSim:
创建哈雷彗星
创建哈雷彗星
@return:
@return:
"""
"""
# 哈雷彗星的平均运行速度约为每小时 70,000 英里或每小时 126,000 公里 。(35公里/秒)
self
.
halley_comet
=
create_halley_comet
([
-
2.836
,
4.705
,
8.85
],
[
0
,
-
5
*
AU
,
-
10
*
AU
])
# 每76.1年环绕太阳一周的周期彗星
self
.
halley_comet
=
HalleComet
(
# size_scale=4e7,
size_scale
=
1e8
,
init_velocity
=
[
-
2.836
,
4.705
,
8.85
],
init_position
=
[
0
,
-
5
*
AU
,
-
10
*
AU
])
\
.
set_light_disable
(
True
)
self
.
bodies
.
append
(
self
.
halley_comet
)
self
.
bodies
.
append
(
self
.
halley_comet
)
def
build
(
self
):
def
build
(
self
):
self
.
build_solar_system
()
self
.
build_solar_system
()
self
.
build_halley_comet
()
self
.
build_halley_comet
()
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
(),
start_time
=
self
.
dt
,
days
=
orbital_days
,
#
points = get_reality_orbit_points(type(body).__name__.lower(), start_time=self.dt, days=orbital_days,
segments
=
100
)
#
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
def
on_ready
(
self
):
def
on_ready
(
self
):
"""
"""
...
@@ -134,7 +119,7 @@ class HalleyCometSim:
...
@@ -134,7 +119,7 @@ class HalleyCometSim:
for
body
in
self
.
bodies
[
1
:]:
for
body
in
self
.
bodies
[
1
:]:
if
isinstance
(
body
,
HalleComet
):
if
isinstance
(
body
,
HalleComet
):
continue
continue
orbit_line
=
self
.
create_orbit_line
(
self
.
sun
,
body
)
orbit_line
=
create_orbit_line
(
self
.
sun
,
body
,
self
.
dt
)
self
.
orbit_lines
.
append
(
orbit_line
)
self
.
orbit_lines
.
append
(
orbit_line
)
self
.
text_panel
=
create_text_panel
()
self
.
text_panel
=
create_text_panel
()
...
...
sim_scenes/solar_system/halley_comet_sim_03.py
浏览文件 @
3558bb8c
...
@@ -18,6 +18,7 @@ from common.func import calculate_distance
...
@@ -18,6 +18,7 @@ from common.func import calculate_distance
from
objs
import
HalleComet
,
Obj
from
objs
import
HalleComet
,
Obj
from
sim_scenes.func
import
camera_look_at
,
two_bodies_colliding
,
create_text_panel
from
sim_scenes.func
import
camera_look_at
,
two_bodies_colliding
,
create_text_panel
from
sim_scenes.func
import
ursina_run
,
create_sphere_sky
from
sim_scenes.func
import
ursina_run
,
create_sphere_sky
from
sim_scenes.solar_system.halley_comet_lib
import
create_halley_comet
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_line
from
simulators.ursina.ursina_mesh
import
create_orbit_line
...
@@ -64,14 +65,7 @@ class HalleyCometSim:
...
@@ -64,14 +65,7 @@ class HalleyCometSim:
创建哈雷彗星
创建哈雷彗星
@return:
@return:
"""
"""
# 哈雷彗星的平均运行速度约为每小时 70,000 英里或每小时 126,000 公里 。(35公里/秒)
self
.
halley_comet
=
create_halley_comet
([
-
3.34
,
3
,
10.718
],
[
0
,
-
2
*
AU
,
-
10
*
AU
])
# 每76.1年环绕太阳一周的周期彗星
self
.
halley_comet
=
HalleComet
(
# size_scale=4e7,
size_scale
=
1e8
,
init_velocity
=
[
-
3.34
,
3
,
10.718
],
init_position
=
[
0
,
-
2
*
AU
,
-
10
*
AU
])
\
.
set_light_disable
(
True
)
self
.
bodies
.
append
(
self
.
halley_comet
)
self
.
bodies
.
append
(
self
.
halley_comet
)
def
build
(
self
):
def
build
(
self
):
...
@@ -84,7 +78,6 @@ class HalleyCometSim:
...
@@ -84,7 +78,6 @@ class HalleyCometSim:
@return:
@return:
"""
"""
# 创建天空
# 创建天空
from
ursina
import
scene
UrsinaConfig
.
trail_type
=
"line"
UrsinaConfig
.
trail_type
=
"line"
UrsinaConfig
.
trail_length
=
91
UrsinaConfig
.
trail_length
=
91
UrsinaConfig
.
trail_thickness_factor
=
3
UrsinaConfig
.
trail_thickness_factor
=
3
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录