From d0a81ec0d2417eca4d8474448f2b0ac9624cd780 Mon Sep 17 00:00:00 2001 From: march3 Date: Fri, 24 Mar 2023 12:26:37 +0800 Subject: [PATCH] =?UTF-8?q?Python=E8=B6=85=E4=BA=BA-=E5=AE=87=E5=AE=99?= =?UTF-8?q?=E6=A8=A1=E6=8B=9F=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scenes/fiction/__init__.py | 0 scenes/{ => fiction}/fixed_stars.py | 0 scenes/{ => fiction}/sun_dysen_sphere.py | 0 scenes/science/__init__.py | 0 scenes/{ => science}/gravity_slingshot.py | 0 scenes/solar_system/__init__.py | 0 scenes/{ => solar_system}/earth_at_night.py | 0 scenes/{ => solar_system}/earth_moon.py | 0 .../mercury_high_resolution.py | 0 scenes/{ => solar_system}/solar_system_1.py | 0 scenes/{ => solar_system}/solar_system_2.py | 0 scenes/{ => solar_system}/solar_system_3.py | 0 scenes/{ => solar_system}/sun_earth.py | 0 .../{ => solar_system}/sun_earth_jupiter.py | 0 scenes/{ => solar_system}/sun_earth_moon.py | 0 scenes/tri_bodies/__init__.py | 0 scenes/{ => tri_bodies}/three_body_01.py | 0 scenes/{ => tri_bodies}/three_body_02.py | 0 scenes/{ => tri_bodies}/three_body_03.py | 0 .../tri_bodies_sim_perfect.py | 0 scenes/{ => tri_bodies}/two_body_01.py | 0 simulators/manim_simulator.py | 73 ------------------- simulators/pyglet_simulator.py | 9 --- 23 files changed, 82 deletions(-) create mode 100644 scenes/fiction/__init__.py rename scenes/{ => fiction}/fixed_stars.py (100%) rename scenes/{ => fiction}/sun_dysen_sphere.py (100%) create mode 100644 scenes/science/__init__.py rename scenes/{ => science}/gravity_slingshot.py (100%) create mode 100644 scenes/solar_system/__init__.py rename scenes/{ => solar_system}/earth_at_night.py (100%) rename scenes/{ => solar_system}/earth_moon.py (100%) rename scenes/{ => solar_system}/mercury_high_resolution.py (100%) rename scenes/{ => solar_system}/solar_system_1.py (100%) rename scenes/{ => solar_system}/solar_system_2.py (100%) rename scenes/{ => solar_system}/solar_system_3.py (100%) rename scenes/{ => solar_system}/sun_earth.py (100%) rename scenes/{ => solar_system}/sun_earth_jupiter.py (100%) rename scenes/{ => solar_system}/sun_earth_moon.py (100%) create mode 100644 scenes/tri_bodies/__init__.py rename scenes/{ => tri_bodies}/three_body_01.py (100%) rename scenes/{ => tri_bodies}/three_body_02.py (100%) rename scenes/{ => tri_bodies}/three_body_03.py (100%) rename scenes/{ => tri_bodies}/tri_bodies_sim_perfect.py (100%) rename scenes/{ => tri_bodies}/two_body_01.py (100%) delete mode 100644 simulators/manim_simulator.py delete mode 100644 simulators/pyglet_simulator.py diff --git a/scenes/fiction/__init__.py b/scenes/fiction/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/scenes/fixed_stars.py b/scenes/fiction/fixed_stars.py similarity index 100% rename from scenes/fixed_stars.py rename to scenes/fiction/fixed_stars.py diff --git a/scenes/sun_dysen_sphere.py b/scenes/fiction/sun_dysen_sphere.py similarity index 100% rename from scenes/sun_dysen_sphere.py rename to scenes/fiction/sun_dysen_sphere.py diff --git a/scenes/science/__init__.py b/scenes/science/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/scenes/gravity_slingshot.py b/scenes/science/gravity_slingshot.py similarity index 100% rename from scenes/gravity_slingshot.py rename to scenes/science/gravity_slingshot.py diff --git a/scenes/solar_system/__init__.py b/scenes/solar_system/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/scenes/earth_at_night.py b/scenes/solar_system/earth_at_night.py similarity index 100% rename from scenes/earth_at_night.py rename to scenes/solar_system/earth_at_night.py diff --git a/scenes/earth_moon.py b/scenes/solar_system/earth_moon.py similarity index 100% rename from scenes/earth_moon.py rename to scenes/solar_system/earth_moon.py diff --git a/scenes/mercury_high_resolution.py b/scenes/solar_system/mercury_high_resolution.py similarity index 100% rename from scenes/mercury_high_resolution.py rename to scenes/solar_system/mercury_high_resolution.py diff --git a/scenes/solar_system_1.py b/scenes/solar_system/solar_system_1.py similarity index 100% rename from scenes/solar_system_1.py rename to scenes/solar_system/solar_system_1.py diff --git a/scenes/solar_system_2.py b/scenes/solar_system/solar_system_2.py similarity index 100% rename from scenes/solar_system_2.py rename to scenes/solar_system/solar_system_2.py diff --git a/scenes/solar_system_3.py b/scenes/solar_system/solar_system_3.py similarity index 100% rename from scenes/solar_system_3.py rename to scenes/solar_system/solar_system_3.py diff --git a/scenes/sun_earth.py b/scenes/solar_system/sun_earth.py similarity index 100% rename from scenes/sun_earth.py rename to scenes/solar_system/sun_earth.py diff --git a/scenes/sun_earth_jupiter.py b/scenes/solar_system/sun_earth_jupiter.py similarity index 100% rename from scenes/sun_earth_jupiter.py rename to scenes/solar_system/sun_earth_jupiter.py diff --git a/scenes/sun_earth_moon.py b/scenes/solar_system/sun_earth_moon.py similarity index 100% rename from scenes/sun_earth_moon.py rename to scenes/solar_system/sun_earth_moon.py diff --git a/scenes/tri_bodies/__init__.py b/scenes/tri_bodies/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/scenes/three_body_01.py b/scenes/tri_bodies/three_body_01.py similarity index 100% rename from scenes/three_body_01.py rename to scenes/tri_bodies/three_body_01.py diff --git a/scenes/three_body_02.py b/scenes/tri_bodies/three_body_02.py similarity index 100% rename from scenes/three_body_02.py rename to scenes/tri_bodies/three_body_02.py diff --git a/scenes/three_body_03.py b/scenes/tri_bodies/three_body_03.py similarity index 100% rename from scenes/three_body_03.py rename to scenes/tri_bodies/three_body_03.py diff --git a/scenes/tri_bodies_sim_perfect.py b/scenes/tri_bodies/tri_bodies_sim_perfect.py similarity index 100% rename from scenes/tri_bodies_sim_perfect.py rename to scenes/tri_bodies/tri_bodies_sim_perfect.py diff --git a/scenes/two_body_01.py b/scenes/tri_bodies/two_body_01.py similarity index 100% rename from scenes/two_body_01.py rename to scenes/tri_bodies/two_body_01.py diff --git a/simulators/manim_simulator.py b/simulators/manim_simulator.py deleted file mode 100644 index 55cc0be..0000000 --- a/simulators/manim_simulator.py +++ /dev/null @@ -1,73 +0,0 @@ -# -*- coding:utf-8 -*- -# title :manim天体运行模拟器 -# description :manim天体运行模拟器 -# author :Python超人 -# date :2023-02-11 -# link :https://gitcode.net/pythoncr/ -# python_version :3.8 -# manim version :Manim Community v0.17.2 -# ============================================================================== -# 环境安装教程参考: -# https://blog.csdn.net/FRIGIDWINTER/article/details/121526956 - -import os -from manim import * -from manim import * -from manim.mobject.three_d import Sphere -from manim.three_d.light import * -from manim.mobject.opengl import * -from PIL import Image - - -class TexturedSphere(ThreeDVMobject): - def __init__(self, radius=1, u_min=0, u_max=1, v_min=0, v_max=1, **kwargs): - self.radius = radius - self.u_min = u_min - self.u_max = u_max - self.v_min = v_min - self.v_max = v_max - super().__init__(**kwargs) - - def init_points(self): - sphere = Sphere(radius=self.radius).mesh - for i in range(len(sphere[0])): - u, v = sphere[0][i], sphere[1][i] - self.add_point(self.radius * np.array([ - np.cos(u) * np.sin(v), - np.sin(u) * np.sin(v), - np.cos(v) - ])) - self.add_tex_coords([ - interpolate(self.u_min, self.u_max, u / (2 * np.pi)), - interpolate(self.v_min, self.v_max, v / np.pi) - ]) - self.set_color_by_tex() - - def set_color_by_tex(self, texture_file='saturn.jpg'): - texture_path = f'textures/{texture_file}' - texture = Image.open(texture_path).transpose(Image.FLIP_TOP_BOTTOM).convert('RGBA') - self.set_texture(texture) - - -class TexturedSaturn(Scene): - def construct(self): - sphere = TexturedSphere(radius=2.5, texture_file='saturn.jpg') - rings = TexturedSphere(radius=3.5, texture_file='saturnRings.jpg', u_min=0.2, u_max=0.8, v_min=0.2, v_max=0.8) - rings.set_rotation(right=PI / 2) - rings.set_shade_in_3d(True) - rings.set_opacity(0.8) - - light = ThreeDPointLight( - location=5 * OUT + 5 * RIGHT + 5 * UP, - color=WHITE, - ) - ambient = ThreeDAmbientLight(color="#444444") - self.add(light, ambient, sphere, rings) - self.set_camera_orientation(phi=75 * DEGREES, theta=-30 * DEGREES) - self.begin_ambient_camera_rotation(rate=0.2) - self.wait(20) - self.stop_ambient_camera_rotation() - - -if __name__ == '__main__': - os.system("manim -pqh manim_simulator.py TexturedSaturn") diff --git a/simulators/pyglet_simulator.py b/simulators/pyglet_simulator.py deleted file mode 100644 index fdedce1..0000000 --- a/simulators/pyglet_simulator.py +++ /dev/null @@ -1,9 +0,0 @@ -# -*- coding:utf-8 -*- -# title :pyglet天体运行模拟器 -# description :pyglet天体运行模拟器 -# author :Python超人 -# date :2023-02-11 -# link :https://gitcode.net/pythoncr/ -# python_version :3.8 -# ============================================================================== -# pip install -i http://pypi.douban.com/simple/ --trusted-host=pypi.douban.com pyglet -- GitLab