-
Notifications
You must be signed in to change notification settings - Fork 2
/
lagrangePoints.m
69 lines (51 loc) · 1.56 KB
/
lagrangePoints.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
function LP = lagrangePoints(mu);
%For a given value of mu, this function computes the location
%of all five libration points for the circular restricted three
%body problem. It returns them as equilibrium points in R^3
%space. Then the output is five points each with three components.
%Each point is a column in a matrix with three rows. The first column is
%L1, the second L2, and so on to the last which is L5.
%Compute the location of the libration points
l=1-mu;
LP = zeros(5,3);
%L1
p_L1=[1, 2*(mu-l), l^2-4*l*mu+mu^2, 2*mu*l*(l-mu)+mu-l, mu^2*l^2+2*(l^2+mu^2), mu^3-l^3];
L1roots=roots(p_L1);
%initialize L1 for loop
L1=0;
for i=1:5
if (L1roots(i) > -mu) && (L1roots(i) < l)
L1=L1roots(i);
end
end
LP(1,1) = L1;
%L2
p_L2=[1, 2*(mu-l), l^2-4*l*mu+mu^2, 2*mu*l*(l-mu)-(mu+l), mu^2*l^2+2*(l^2-mu^2), -(mu^3+l^3)];
L2roots=roots(p_L2);
%initialize L2 for loop
L2=0;
for i=1:5
if (L2roots(i) > -mu) && (L2roots(i) > l)
L2=L2roots(i);
end
end
LP(2,1) = L2;
%L3
p_L3=[1, 2*(mu-l), l^2-4*mu*l+mu^2, 2*mu*l*(l-mu)+(l+mu), mu^2*l^2+2*(mu^2-l^2), l^3+mu^3];
L3roots=roots(p_L3);
%initialize L3 for loop
L3=0;
for i=1:5
if L3roots(i) < -mu
L3=L3roots(i);
end
end
LP(3,1) = L3;
%L4
LP(4,1) = 0.5 - mu;
LP(4,2) = sqrt(3)/2;
%L5
LP(5,1) = 0.5 - mu;
LP(5,2) = -sqrt(3)/2;
LP = LP';
end