Beispiel #1
0
    def test_gibbs(self):
        r1 = [0, 0, 6378.137]
        r2 = [0, -4464.696, -5102.509]
        r3 = [0, 5740.323, 3189.068]

        gibbs = prelimorbit.Gibbs()
        v2 = gibbs.solve(r1, r2, r3)
        v2_mag = util.magnitude(v2)

        self.assertAlmostEqual(v2[0], 0.00000, places=4)
        self.assertAlmostEqual(v2[1], 5.5311448, places=4)
        self.assertAlmostEqual(v2[2], -5.1918029, places=4)
        self.assertAlmostEqual(v2_mag, 7.58, places=1)
Beispiel #2
0
from astro import prelimorbit, util
import math

if __name__ == '__main__':
    r1 = [0, 0, 6378.137]
    r2 = [0, -4464.696, -5102.509]
    r3 = [0, 5740.323, 3189.068]
    r2_mag = util.magnitude(r2)

    gibbs = prelimorbit.Gibbs()
    v2 = gibbs.solve(r1, r2, r3)
    v2_mag = util.magnitude(v2)

    print("v2:", v2)
    print("v2 Magnitude:", v2_mag)

    h_m = util.cross_product(r2, v2)
    h_m_mag = util.magnitude(h_m)
    dot_rv2 = util.dot_product(r2, v2)
    e_0 = ((v2_mag**2 / gibbs.mu) -
           (1 / r2_mag)) * r2[0] - (dot_rv2 / gibbs.mu) * v2[0]
    e_1 = ((v2_mag**2 / gibbs.mu) -
           (1 / r2_mag)) * r2[1] - (dot_rv2 / gibbs.mu) * v2[1]
    e_2 = ((v2_mag**2 / gibbs.mu) -
           (1 / r2_mag)) * r2[2] - (dot_rv2 / gibbs.mu) * v2[2]
    e = [e_0, e_1, e_2]
    e_mag = util.magnitude(e)
    k_hat = [0, 0, 1]
    i_hat = [1, 0, 0]
    n = util.cross_product(k_hat, h_m)
    n_mag = util.magnitude(n)
Beispiel #3
0
 def reached_dest(self, x, y):
     distance = magnitude(self.ship.x - x, self.ship.y - y)
     return distance < REACHED_DEST_THRESHOLD
Beispiel #4
0
 def d_tke(F):
     return tke - (0.5 * self.mass * magnitude(*v1f(F)) ** 2 + \
                   0.5 * other.mass * magnitude(*v2f(F)) ** 2)
Beispiel #5
0
 def choose_target(self, target_group):
     # Acquire based solely on distance
     key_func = lambda s: magnitude(self.ship.x - s.x, self.ship.y - s.y)
     return sorted(target_group, key=key_func)[0]