performances + blackhole

added __slots__ to the Node class
+
added central black hole at the center of the galaxy in create_stars
This commit is contained in:
Crizomb 2023-02-14 12:57:26 +01:00 committed by GitHub
parent 0902bab7dd
commit 27a62277a6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -48,6 +48,7 @@ class Star:
class Node:
""""Node class"""
__slots__ = "center", "center_of_mass", "mass", "children", "width"
def __init__(self, center: Vec3, center_of_mass: Vec3, mass: float, children, width: float):
self.center = center
self.center_of_mass = center_of_mass
@ -132,6 +133,10 @@ def create_stars(nb_stars: int) -> List[Star]:
orthog = Vec3(1, 0, -x / z) if z > 0 else Vec3(-1, 0, x / z)
speed = orthog.normalize()*pos.norm
stars.append(Star(pos, speed, 1))
#add center blackhole
stars.append(Star(Vec3(0, 0, 0), Vec3(0, 0, 0), nb_stars/10))
return stars
def create_tree(stars: List[Star]) -> Node: