-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsolar_system_body.py
66 lines (52 loc) · 1.35 KB
/
solar_system_body.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/env python3
'''
/************************/
/* solar_system_body.py */
/* Version 1.0 */
/* 2024/08/03 */
/************************/
'''
import numpy as np
import sys
class Body:
def __init__(self, name='', radius=0, mass=0, scale=1,
color=np.zeros(3),
position=np.zeros(3), velocity=np.zeros(3)):
self._name = name
self._radius = radius
self._mass = mass
self._scale = scale
self._color = color
self._position = position
self._velocity = velocity
@property
def name(self):
return self._name
@property
def radius(self):
return self._radius
@property
def mass(self):
return self._mass
@property
def mass_plot(self):
return np.log(self._mass) / np.log(self._scale)
@property
def color(self):
return self._color
@property
def position(self):
return self._position
@position.setter
def position(self, position):
self._position = np.array(position)
@property
def velocity(self):
return self._velocity
@velocity.setter
def velocity(self, velocity):
self._velocity = np.array(velocity)
if __name__ == '__main__':
if sys.version_info[0] < 3:
raise RuntimeError('Must be using Python 3')
pass