sun.py 1.2 KB
Newer Older
M
march3 已提交
1 2 3 4 5 6 7 8 9 10 11 12
# -*- coding:utf-8 -*-
# title           :
# description     :
# author          :Python超人
# date            :2023-01-22
# notes           :
# python_version  :3.8
# ==============================================================================
from bodies.body import Body


class Sun(Body):
M
march3 已提交
13 14 15 16 17 18 19
    """
    太阳
    ------------------------
    天体质量: 1.9891×10³⁰ kg
    平均密度: 1.408×10³ kg/m³
    """

M
march3 已提交
20
    def __init__(self, name="Sun", mass=1.9891e30,
M
march3 已提交
21 22
                 init_position=[0, 0, 0],
                 init_velocity=[0, 0, 0],
M
march3 已提交
23
                 texture="sun2.jpg", size_scale=1.0, distance_scale=1.0):
M
march3 已提交
24 25 26 27 28 29
        params = {
            "name": name,
            "mass": mass,
            "init_position": init_position,
            "init_velocity": init_velocity,
            "density": 1.408e3,
M
march3 已提交
30
            "color": (170, 98, 25),
M
march3 已提交
31 32 33 34 35 36
            "texture": texture,
            "size_scale": size_scale,
            "distance_scale": distance_scale
        }
        super().__init__(**params)

M
march3 已提交
37 38 39 40 41 42 43 44
    @property
    def is_fixed_star(self):
        """
        太阳为恒星
        :return:
        """
        return True

M
march3 已提交
45 46 47

if __name__ == '__main__':
    print(Sun())