In [2]:
import numpy as np

from thesis_functions.astro import ComputeLibrationPoints


# Inputs: m1 = mass of larger body, 
#         m2 = mass of smaller body, 
#         r12 = distance from m1 to m2
#         M = Total mass of the system
m1 = 1.989e30;        # Sun
m2 = 5.97219e24;      # Earth
#m2 = 7.34767309e22;  # Moon
r12 = 149600000.0;    # Sun-to-Earth
M = m1 + m2;

# Gravitational constant G = 1 in nondimensional units
G = 6.67384e-11;  # m3 kg-1 s-2

# mu = Gravitational parameter = GM
# For nondimensional computations, mu = M2/M
mu = m2/M;

# Angular rotation rate of system:
omega = np.sqrt(G*M/(r12**3.0));

print m1, m2, r12, M, mu;

# Compute Libration Points and positions of primary bodies
X1, X2, L1, L2, L3, L4, L5 = ComputeLibrationPoints(mu)

# To re-dimensionalize, multiply all distances by r12
print 'X1', X1;
print 'X1', X1*r12;
print 'X2', X2;
print 'X2', X2*r12;
print 'L1', L1;
print 'L1', L1*r12;
print 'L2', L2;
print 'L2', L2*r12;
print 'L3', L3;
print 'L3', L3*r12;
print 'L4', L4;
print 'L4', L4*r12;
print 'L5', L5;
print 'L5', L5*r12;


1.989e+30 5.97219e+24 149600000.0 1.98900597219e+30 3.0026003358e-06
X1 [ -3.00260034e-06   0.00000000e+00   0.00000000e+00]
X1 [-449.18901024    0.            0.        ]
X2 [ 0.999997  0.        0.      ]
X2 [  1.49599551e+08   0.00000000e+00   0.00000000e+00]
L1 [ 0.99002757  0.          0.        ]
L1 [  1.48108124e+08   0.00000000e+00   0.00000000e+00]
L2 [ 1.01003313  0.          0.        ]
L2 [  1.51100957e+08   0.00000000e+00   0.00000000e+00]
L3 [-1.00000125  0.          0.        ]
L3 [ -1.49600187e+08   0.00000000e+00   0.00000000e+00]
L4 [ 0.499997   0.8660254  0.       ]
L4 [  7.47995508e+07   1.29557400e+08   0.00000000e+00]
L5 [ 0.499997  -0.8660254  0.       ]
L5 [  7.47995508e+07  -1.29557400e+08   0.00000000e+00]

In [3]:
# Earth/Moon Test

m1 = 5.97219e24;      # Earth
m2 = 7.34767309e22;   # Moon
r12 = 384400;
mu = 0.012277471;

# Compute Libration Points and positions of primary bodies
X1, X2, L1, L2, L3, L4, L5 = ComputeLibrationPoints(mu)

print 'X1', X1;
print 'X2', X2;
print 'L1', L1;
print 'L2', L2;
print 'L3', L3;
print 'L4', L4;
print 'L5', L5;

# analytic approximation from wikipedia
test = r12*(m2/(3.0*m1))**(1.0/3.0)

print test
print X2[0] - test/r12
print X2[0] + test/r12


X1 [-0.01227747  0.          0.        ]
X2 [ 0.98772253  0.          0.        ]
L1 [ 0.83629259  0.          0.        ]
L2 [ 1.15616817  0.          0.        ]
L3 [-1.00511551  0.          0.        ]
L4 [ 0.48772253  0.8660254   0.        ]
L5 [ 0.48772253 -0.8660254   0.        ]
61529.2607579
0.827656814229
1.14778824377

In [4]:
# dictionary test

Waypoints = dict();
Waypoints[0] = {'t': 0.0,
                'r': [20.0, 0.0, 0.0]};
Waypoints[1] = {'t': 60.0,
                'r': [10.0, 0.0, 0.0]};

print Waypoints[0]['r'][0]


20.0

In [5]:
# set up 3x3 identity matrix and zeroes matrix
I3 = np.eye(3)
Z3 = np.zeros((3,3))
print I3
print Z3
test = np.array([[1,2,3],[4,5,6]])
print test
A = np.vstack([np.hstack([Z3, I3]),
               np.hstack([I3, Z3])])
print A


[[ 1.  0.  0.]
 [ 0.  1.  0.]
 [ 0.  0.  1.]]
[[ 0.  0.  0.]
 [ 0.  0.  0.]
 [ 0.  0.  0.]]
[[1 2 3]
 [4 5 6]]
[[ 0.  0.  0.  1.  0.  0.]
 [ 0.  0.  0.  0.  1.  0.]
 [ 0.  0.  0.  0.  0.  1.]
 [ 1.  0.  0.  0.  0.  0.]
 [ 0.  1.  0.  0.  0.  0.]
 [ 0.  0.  1.  0.  0.  0.]]

In [6]:
a = np.array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6])

b = a[0:3]

c = np.array([a[0:3],
              a[3:6],
              a[6:9]])

c = a[0:9].reshape(3,3)

print a
print b
print c

d = np.dot(c, c)

print len(d[0])

print d

print d.reshape(1,9)
print d.reshape(9,1)

Phi = a[6:42].reshape(6,6)

print Phi

print d.reshape(1,9)[0]

e = np.concatenate((b, d.reshape(1,9)[0]))

print e


[ 1  2  3  4  5  6  7  8  9 10  1  2  3  4  5  6  7  8  9 10  1  2  3  4  5
  6  7  8  9 10  1  2  3  4  5  6  7  8  9 10  1  2  3  4  5  6]
[1 2 3]
[[1 2 3]
 [4 5 6]
 [7 8 9]]
3
[[ 30  36  42]
 [ 66  81  96]
 [102 126 150]]
[[ 30  36  42  66  81  96 102 126 150]]
[[ 30]
 [ 36]
 [ 42]
 [ 66]
 [ 81]
 [ 96]
 [102]
 [126]
 [150]]
[[ 7  8  9 10  1  2]
 [ 3  4  5  6  7  8]
 [ 9 10  1  2  3  4]
 [ 5  6  7  8  9 10]
 [ 1  2  3  4  5  6]
 [ 7  8  9 10  1  2]]
[ 30  36  42  66  81  96 102 126 150]
[  1   2   3  30  36  42  66  81  96 102 126 150]

In [17]:
rVec = np.array([[ 0.02601457 , 0.0,          0.0        ]])
print rVec
mag = np.linalg.norm(rVec,2,None)
mag = np.linalg.norm(rVec,2,1)[:,None]
print mag
print rVec/mag


[[ 0.02601457  0.          0.        ]]
[[ 0.02601457]]
[[ 1.  0.  0.]]

In [13]:
Waypoints = {}
nextPoint = 0
Waypoints['r_RLP_achieved'] = np.array([ 5.8, 3.4, 5.3 ])

dxW = 0.0
dyW = 0.0
dzW = 0.0
    
# compute updated waypoint location in RIC and VNB
#dxW = Waypoints['r_RLP_achieved'][0]
#dyW = Waypoints['r_RLP_achieved'][1]
#dzW = Waypoints['r_RLP_achieved'][2]
#print dxW, dyW, dzW
    
# compute updated waypoint location in RIC and VNB
[dxW, dyW, dzW] = Waypoints['r_RLP_achieved']

print dxW, dyW, dzW


5.8 3.4 5.3

In [ ]: