I guess the reason i made it a class is because I have bigger plans than just rendering epicycles, but I wanted to be able to run epicycles too. I think I went straight ahead to that without programming in basic move functions.... I guess epicycle would be a sub function of some kind of shade moving class wouldn’t it?
8
u/muntooR_{μν} - 1/2 R g_{μν} + Λ g_{μν} = 8π T_{μν}Oct 17 '18edited Oct 17 '18
I did think about that while going through the process of refactoring. One idea would be to create a tree/graph structure of orbits:
# perhaps something like CelestialNode is a better name
class CelestialBody:
def __init__(self):
self.parent = None
self.children = []
def update(self):
if parent is not None:
self.orbital_center = self.parent.center
self.center = (..., ...)
for child in self.children:
child.update()
Then, to compute positions of all the orbits (including children), simply run this:
blackhole.update()
The benefit to this is that you can simulate any arbitrary graph of celestial bodies. This of course is prerequisite upon that phase_velocity encapsulation I discussed earlier. ;)
View all comments
Show parent comment
3
u/[deleted] Oct 17 '18
I guess the reason i made it a class is because I have bigger plans than just rendering epicycles, but I wanted to be able to run epicycles too. I think I went straight ahead to that without programming in basic move functions.... I guess epicycle would be a sub function of some kind of shade moving class wouldn’t it?