-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjacobiValue3D.m
69 lines (48 loc) · 1.37 KB
/
jacobiValue3D.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
%{
...
Created on Feb 20, 2020 16:18
This function calculates the jacobi value of a state in the Circular
Restricted 3-Body Problem (CR3BP)
Inputs
------
X - 1x6 Vector - Your current states [x,y,z,xDot,yDot,zDot]
mu - double - Your systems nondimenisonal mass ratio
Outputs
-------
jacobiConst - double - The jacobi constant
C = 2U - (xdot^2+ydot^2+zdot^2)
U = (x^2 +y^2)/2 + (1-mu)/d + mu/r
=======================================================
Source File: Ari Rubinstein
WebSite : https://github.com/gereshes/CR3BP-Functions/blob/master/jacobiValue3D.m
Modified to accept 2D and 3D value
=======================================================
...
%}
function [jacobiConst] = jacobiValue3D(X,mu)
if length(X)>4
type = 'ThreeDim';
else
type = 'Planar';
end
switch type
case 'Planar'
x=X(1);
y=X(2);
xDot=X(3);
yDot=X(4);
r=sqrt(((x-1+mu).^2)+(y.^2));
d=sqrt(((x+mu).^2)+(y.^2));
jacobiConst = (x.^2)+(y.^2) +(2*(1-mu)./d)+(2*mu./r) - ((xDot.^2)+(yDot.^2));
%============================================================================
case 'ThreeDim'
x=X(1);
y=X(2);
z=X(3);
xDot=X(4);
yDot=X(5);
zDot=X(6);
r=sqrt(((x-1+mu).^2)+(y.^2)+(z.^2));
d=sqrt(((x+mu).^2)+(y.^2)+(z.^2));
jacobiConst = (x.^2)+(y.^2) +(2*(1-mu)./d)+(2*mu./r) - ((xDot.^2)+(yDot.^2)+(zDot.^2));
end