-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCRes3BP_EOM.m
84 lines (53 loc) · 1.54 KB
/
CRes3BP_EOM.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
%{
...
This is the Equation of Motion of the CR3BP
Created on feb 20 2020 15:50
...
%}
function X_Dot = CRes3BP_EOM(t,X,mu)
if length(X)>4
type = 'ThreeDim';
else
type = 'Planar';
end
switch type
case 'Planar'
% Unpack the state variables
x = X(1);
y = X(2);
mu1 = 1-mu; % mass of larger primary (nearest origin on left)
mu2 = mu; % mass of smaller primary (furthest from origin on right)
% The Distances from the larger and Smaller Primary
d3= ((x+mu2)^2 + y^2)^1.5;
r3= ((x-mu1)^2 + y^2 )^1.5;
% Partial Derivative of the Pseudo Potential Function
Ux = x - mu1*(x+mu2)/d3 - mu2*(x-mu1)/r3 ;
Uy = y - mu1* y /d3 - mu2* y /r3 ;
xDot = X(3);
yDot = X(4);
xDDot = 2*yDot + Ux;
yDDot = -2*xDot + Uy;
X_Dot = [xDot;yDot;xDDot;yDDot];
%============================================================================
case 'ThreeDim'
% Unpack the state variables
x = X(1);
y = X(2);
z = X(3);
mu1 = 1-mu; % mass of larger primary (nearest origin on left)
mu2 = mu; % mass of smaller primary (furthest from origin on right)
% The Distances from the larger and Smaller Primary
d3= ((x+mu2)^2 + y^2 + z^2)^1.5; % P3 and larger primary
r3= ((x-mu1)^2 + y^2 + z^2 )^1.5; % P3 and larger primary
% Partial Derivative of the Pseudo Potential Function
Ux = x - mu1*(x+mu2)/d3 - mu2*(x-mu1)/r3 ;
Uy = y - mu1* y /d3 - mu2* y /r3 ;
Uz = -mu1*z/d3 - mu2*z/r3;
xDot = X(4);
yDot = X(5);
zDot = X(6);
xDDot = 2*yDot + Ux;
yDDot = -2*xDot + Uy;
zDDot = Uz;
X_Dot = [xDot;yDot;zDot;xDDot;yDDot;zDDot];
end