mirror of
https://github.com/cosinekitty/astronomy.git
synced 2026-05-19 06:17:03 -04:00
Added Python demo of calculating Jupiter's moons.
The demo shows how to correct for light travel time to render Jupiter's moons as they appear from the Earth. Created an addition operator for the Vector class in the Python code, because it is handy. Corrected a bug in the string representation of the Python StateVector class.
This commit is contained in:
@@ -162,6 +162,9 @@ class Vector:
|
||||
"""Returns the length of the vector in AU."""
|
||||
return math.sqrt(self.x**2 + self.y**2 + self.z**2)
|
||||
|
||||
def __add__(self, other):
|
||||
return Vector(self.x + other.x, self.y + other.y, self.z + other.z, self.t)
|
||||
|
||||
class StateVector:
|
||||
"""A combination of a position vector, a velocity vector, and a time.
|
||||
|
||||
@@ -197,7 +200,7 @@ class StateVector:
|
||||
self.t = t
|
||||
|
||||
def __repr__(self):
|
||||
return 'StateVector[pos=({}, {}, {}), vel=({}, {}, {}), t{}]'.format(
|
||||
return 'StateVector[pos=({}, {}, {}), vel=({}, {}, {}), t={}]'.format(
|
||||
self.x, self.y, self.z,
|
||||
self.vx, self.vy, self.vz,
|
||||
str(self.t))
|
||||
|
||||
Reference in New Issue
Block a user