Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Python_超人
宇宙模拟器
提交
950dbad7
宇宙模拟器
项目概览
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看板
提交
950dbad7
编写于
1月 24, 2024
作者:
三月三net
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Python超人-宇宙模拟器
上级
18b4e75c
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
128 addition
and
0 deletion
+128
-0
sim_scenes/featured/bodies_size_sim.py
sim_scenes/featured/bodies_size_sim.py
+128
-0
未找到文件。
sim_scenes/featured/bodies_size_sim.py
0 → 100644
浏览文件 @
950dbad7
# -*- coding:utf-8 -*-
# title :天体大小比较
# description :天体大小比较
# author :Python超人
# date :2024-01-24
# link :https://gitcode.net/pythoncr/
# python_version :3.9
# ==============================================================================
import
threading
from
bodies
import
Sun
,
Mercury
,
Venus
,
Earth
,
Mars
,
Jupiter
,
Saturn
,
Uranus
,
Neptune
,
Pluto
,
Moon
,
Callisto
,
Europa
,
\
Ganymede
,
Sirius
from
bodies
import
Rigel
,
Bellatrix
,
Alcyone
,
Antares
,
Arcturus
,
Aldebaran
,
Betelgeuse
from
bodies
import
EtaCarinae
,
YCanumVenaticorum
,
VYCanisMajoris
,
UYScuti
,
CarinaeV382
,
Stephenson_2_18
from
bodies.jupiter_system
import
Io
from
common.consts
import
SECONDS_PER_HOUR
,
SECONDS_PER_DAY
,
AU
from
sim_scenes.func
import
ursina_run
,
create_sphere_sky
from
sim_scenes.universe_sim_scenes
import
UniverseSimScenes
from
simulators.ursina.entities.body_timer
import
TimeData
,
AppTimeUtil
from
simulators.ursina.entities.entity_utils
import
create_directional_light
from
simulators.ursina.ursina_event
import
UrsinaEvent
from
simulators.ursina.ursina_config
import
UrsinaConfig
import
ursina
from
ursina
import
camera
,
time
,
Vec3
,
application
class
BodiesSizeSim
(
UniverseSimScenes
):
def
__init__
(
self
):
self
.
D
=
AU
/
30000
# earth1 = Earth("地球1", init_position=[0, 0, 0], rotate_angle=-23.44)
self
.
bodies
=
[
Pluto
(
name
=
"冥王星"
,
init_position
=
[
-
4
*
self
.
D
,
0
,
0
]),
Moon
(
"月球"
,
init_position
=
[
-
3
*
self
.
D
,
0
,
0
]),
Io
(
name
=
"木卫一"
,
init_position
=
[
-
2
*
self
.
D
,
0
,
0
]),
Europa
(
name
=
"木卫二"
,
init_position
=
[
-
self
.
D
,
0
,
0
]),
Ganymede
(
name
=
"木卫三"
,
init_position
=
[
0
,
0
,
0
]),
Callisto
(
name
=
"木卫四"
,
init_position
=
[
self
.
D
,
0
,
0
]),
Mercury
(
name
=
"水星"
,
init_position
=
[
2
*
self
.
D
,
0
,
0
]),
Mars
(
name
=
"火星"
,
init_position
=
[
-
4
*
self
.
D
,
self
.
D
,
self
.
D
]),
Venus
(
name
=
"金星"
,
init_position
=
[
-
self
.
D
,
self
.
D
,
self
.
D
]),
Earth
(
"地球"
,
texture
=
"earth2.jpg"
,
rotate_angle
=
0
,
init_position
=
[
3
*
self
.
D
,
self
.
D
,
self
.
D
]),
Uranus
(
name
=
"天王星"
,
init_position
=
[
-
6
*
self
.
D
,
5
*
self
.
D
,
5
*
self
.
D
]),
Neptune
(
name
=
"海王星"
,
init_position
=
[
6
*
self
.
D
,
5
*
self
.
D
,
5
*
self
.
D
]),
Saturn
(
name
=
"土星"
,
init_position
=
[
-
20
*
self
.
D
,
11
*
self
.
D
,
30
*
self
.
D
]),
# .show_rings(False),
Jupiter
(
name
=
"木星"
,
texture
=
'jupiter_hd.jpg'
,
init_position
=
[
25
*
self
.
D
,
14
*
self
.
D
,
25
*
self
.
D
]),
Sun
(
name
=
"太阳"
,
init_position
=
[
70
*
self
.
D
,
70
*
self
.
D
,
250
*
self
.
D
]),
Sirius
(
name
=
"天狼星A"
,
init_position
=
[
-
90
*
self
.
D
,
120
*
self
.
D
,
450
*
self
.
D
]),
Alcyone
(
name
=
"昴宿六"
,
init_position
=
[
-
900
*
self
.
D
,
1200
*
self
.
D
,
1200
*
self
.
D
]),
# 质量倍数 6 半径倍数 9.5
Arcturus
(
name
=
"大角星"
,
init_position
=
[
2000
*
self
.
D
,
3000
*
self
.
D
,
4000
*
self
.
D
]),
# 质量倍数 1.1 半径倍数 25.7
Aldebaran
(
name
=
"毕宿五"
,
init_position
=
[
-
5000
*
self
.
D
,
4000
*
self
.
D
,
9000
*
self
.
D
]),
# 质量倍数 1.16 半径倍数 44.13
Rigel
(
name
=
"参宿七"
,
init_position
=
[
9000
*
self
.
D
,
8000
*
self
.
D
,
13000
*
self
.
D
]),
# 质量倍数 18 半径倍数 78
# # YCanumVenaticorum(name="猎犬座Y", init_position=[-90*self.D, 120*self.D, 450*self.D]), # 质量倍数 3.0 半径倍数 215
EtaCarinae
(
name
=
"海山二"
,
init_position
=
[
-
15000
*
self
.
D
,
28000
*
self
.
D
,
45000
*
self
.
D
]),
# 质量倍数 125 半径倍数 278
# # Antares(name="心宿二", init_position=[-90*self.D, 120*self.D, 450*self.D]), # 质量倍数 15 半径倍数 680
CarinaeV382
(
name
=
"船底座V382"
,
init_position
=
[
35000
*
self
.
D
,
70000
*
self
.
D
,
150000
*
self
.
D
]),
# 质量倍数 39 半径倍数 747
# # Betelgeuse(name="参宿四", init_position=[-90*self.D, 120*self.D, 450*self.D]), # 质量倍数 19 半径倍数 1180
VYCanisMajoris
(
name
=
"大犬座VY"
,
init_position
=
[
-
85000
*
self
.
D
,
140000
*
self
.
D
,
360000
*
self
.
D
]),
# 质量倍数 30 半径倍数 1400
# # UYScuti(name="盾牌座 UY", init_position=[-85000*self.D, 140000*self.D, 360000*self.D]), # 盾牌座 UY 质量倍数 10 半径倍数 1708
Stephenson_2_18
(
name
=
"史蒂文森2-18"
,
init_position
=
[
95000
*
self
.
D
,
200000
*
self
.
D
,
800000
*
self
.
D
])
# 史蒂文森2-18 质量倍数 40.0 半径倍数 2150
]
for
body
in
self
.
bodies
:
# if body.rotation_speed == 0:
body
.
rotation_speed
=
10
body
.
init_velocity
=
[
0
,
0
,
0
]
body
.
ignore_mass
=
True
def
on_ready
(
self
):
# 运行前触发
# 为了较好的立体效果,可以增加太阳光线,光线直射地球(target=earth)
create_directional_light
(
position
=
([
-
1e2
,
-
1e2
,
-
5e4
]),
light_num
=
3
,
target
=
self
.
bodies
[
0
])
camera
.
clip_plane_near
=
0.001
camera
.
clip_plane_far
=
50000000
camera
.
fov
=
60
application
.
time_scale
=
0.001
sky
=
create_sphere_sky
(
scale
=
100000
)
# sky.alpha = 0.5
# sky.rotation_y = -90
sky
.
rotation_x
=
200
# sky.rotation_z = 200
# for idx, body in enumerate(self.bodies):
# if idx <= len(body_rotation_y) - 1:
# body.planet.rotation_y = body_rotation_y[idx]
# interval = 5
def
on_timer_changed
(
self
,
time_data
:
TimeData
):
pass
def
run
(
self
):
# 运行中,每时每刻都会触发 on_timer_changed
UrsinaEvent
.
on_timer_changed_subscription
(
self
.
on_timer_changed
)
# 运行前会触发 on_ready
UrsinaEvent
.
on_ready_subscription
(
self
.
on_ready
)
# 使用 ursina 查看的运行效果
# 常用快捷键: P:运行和暂停 O:重新开始 I:显示天体轨迹
# position = 左-右+、上+下-、前+后-
ursina_run
(
self
.
bodies
,
SECONDS_PER_HOUR
/
2
,
position
=
[
0
,
0
,
-
5e4
],
# position=[0, 2e4, -15e4], # 海王星
# position=[0, 2e4, -35e4], # 木星
# position=[0, 35e4, -150e4], # 太阳
# position=[0, 50e4, -250e4], # 天狼星
# position=[0, 500e4, -2400e4], # 昴宿六
# position=[0, 1500e4, -5500e4], # 大角星
# position=[0, 2500e4, -10000e4], # 毕宿五
# position=[0, 5000e4, -20000e4], # 参宿七
# position=[0, 15000e4, -55000e4], # 海山二
# position=[0, 38000e4, -150000e4], # 船底座V382
# position=[0, 80000e4, -300000e4], # 盾牌座 UY
# position=[0, 70000e4, -280000e4], # 史蒂文森2-18
cosmic_bg
=
''
,
# show_name=True,
show_control_info
=
False
,
show_exit_button
=
False
,
show_camera_info
=
False
,
show_grid
=
False
,
# view_closely=True,
timer_enabled
=
True
)
if
__name__
==
'__main__'
:
BodiesSizeSim
().
run
()
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录