OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
eqnox.f
Go to the documentation of this file.
1  SUBROUTINE eqnox(X,GM,Y)
2 C VERSION OF 4/1/85
3 C PURPOSE
4 C COMPUTES THE EQUINOCTIAL ELEMENTS A,H,K,P,Q,LAMDA AND
5 C CLASSICAL ELEMENTS E,I,NODE,W,M AND OTHER MISC VARIABLES
6 C INPUT
7 C X = 6-D CARTESIAN COORD X,Y,Z,XD,YD,ZD (KM,KM/SEC)
8 C GM = GRAVITATION CONSTANT * MASS OF PLANET (KM**3/SEC**2)
9 C OUTPUT
10 C Y(1) = A, SEMI-MAJOR AXIS (KM)
11 C Y(2) = H, E * SIN(W + NODE)
12 C Y(3) = K, E * COS(W + NODE)
13 C Y(4) = P, TAN(I/2) * SIN(NODE)
14 C Y(5) = Q, TAN(I/2) * COS(NODE)
15 C Y(6) = LAMDA, M + NODE + W (RAD)
16 C Y(7) = E, ECCENTRICITY
17 C Y(8) = I, INCLINATION (RAD)
18 C Y(9) = NODE, LONGITUDE OF ASCENDING NODE (RAD)
19 C Y(10) = W, ARGUMENT OF PERIAPSIS (RAD)
20 C Y(11) = MA, MEAN ANOMALY (RAD)
21 C Y(12) = TA, TRUE ANOMALY (RAD)
22 C Y(13) = EA, ECCENTRIC ANOMALY (RAD)
23 C Y(14) = L, TRUE LONGITUDE (RAD)
24 C Y(15) = F, ECCENTRIC LONGITUDE (RAD)
25 C Y(16) = R, RADIUS (KM)
26 C Y(17) = V, VELOCITY (KM/SEC)
27 C Y(18) = ORBITAL PERIOD (SEC)
28 C CALL SUBROUTINES
29 C NONE
30 C REFERENCES
31 C JPL EM 312/87-153, 20 APRIL 1987
32 C AIAA #75-9, ON THE FORMULATION OF THE GRAVITATIONAL POTENTIAL
33 C IN TERMS OF EQUINOCTIAL VARIABLES, CEFOLA AND BROUCKE, 1975
34 C ANALYSIS
35 C JOHNNY H. KWOK - JPL
36 C PROGRAMMER
37 C JOHNNY H. KWOK - JPL
38 C PROGRAM MODIFICATIONS
39 C NONE
40 C COMMENTS
41 C THIS PROGRAM RECYCLES STORAGE DUMMY VARIABLES. SO BE CAREFUL
42 C WHEN MODIFYING THIS ROUTINE. THIS PROGRAM DOES NOT WORK FOR
43 C PARABOLIC OR HYPERBOLIC OR RETROGRADE EQUATORIAL ORBITS.
44 C IF EITHER INCLINATION OR ECCENTRICITY IS NEAR ZERO, THE
45 C CLASSICAL ORBITAL ELEMENTS MAY NOT BE DEFINED AND THE USER
46 C SHOULD INTERPRET ACCORDINGLY.
47 C
48  IMPLICIT DOUBLE PRECISION (a-h,o-z)
49  dimension x(6),y(18)
50  dimension v1(3),v2(3),v3(3)
51  DATA zero,one,two/0.d0,1.d0,2.d0/
52  DATA tpi/6.283185307179586d0/
53 C *** D2 = V2
54 C *** D3 = RDV
55  y(16)=dsqrt(x(1)**2+x(2)**2+x(3)**2)
56  d2=x(4)**2+x(5)**2+x(6)**2
57  d3=x(1)*x(4)+x(2)*x(5)+x(3)*x(6)
58  y(17)=dsqrt(d2)
59  y(1)=one/(two/y(16)-d2/gm)
60  y(18)=tpi/dsqrt(gm/y(1)**3)
61 C *** D4 = V2/GM - 1/R
62 C *** D5 = RDV/GM
63  d4=d2/gm-one/y(16)
64  d5=d3/gm
65 C *** V1 = ECCENTRICITY VECTOR
66  DO 10 i=1,3
67  10 v1(i)=d4*x(i)-d5*x(i+3)
68 C *** V2 = VECTOR W = R CROSS V, ANGULAR MOMENTUM VECTOR
69  v2(1)=x(2)*x(6)-x(3)*x(5)
70  v2(2)=x(3)*x(4)-x(1)*x(6)
71  v2(3)=x(1)*x(5)-x(2)*x(4)
72 C *** D1 = MAGNITUDE OF W
73  d1=dsqrt(v2(1)**2+v2(2)**2+v2(3)**2)
74  DO 20 i=1,3
75  20 v2(i)=v2(i)/d1
76 C *** D1 = 1 + WZ
77  d1 = one+v2(3)
78  y(4)=v2(1)/d1
79  y(5)=-v2(2)/d1
80 C *** D1 = P**2
81 C *** D2 = Q**2
82  d1=y(4)*y(4)
83  d2=y(5)*y(5)
84 C *** D3
85 C *** D4
86  d3=one+d1+d2
87  d4=two*y(4)*y(5)
88 C *** V2 = UNIT VECTOR G
89 C *** V3 = UNIT VECTOR F
90  v2(1)=d4
91  v2(2)=one+d1-d2
92  v2(3)=two*y(5)
93  v3(1)=one-d1+d2
94  v3(2)=d4
95  v3(3)=-two*y(4)
96  DO 30 i=1,3
97  v2(i)=v2(i)/d3
98  30 v3(i)=v3(i)/d3
99  y(2)=v1(1)*v2(1)+v1(2)*v2(2)+v1(3)*v2(3)
100  y(3)=v1(1)*v3(1)+v1(2)*v3(2)+v1(3)*v3(3)
101 C *** D1 = X1
102 C *** D2 = Y1
103  d1=x(1)*v3(1)+x(2)*v3(2)+x(3)*v3(3)
104  d2=x(1)*v2(1)+x(2)*v2(2)+x(3)*v2(3)
105  y(14)=datan2(d2,d1)
106 C *** D3 = DSQRT(1-H*H-K*K)
107 C *** D4 = A * DSQRT(1-H*H-K*K)
108 C *** D5 = BETA = 1/(1+A*DSQRT(1-H*H-K*K))
109  d3=dsqrt(one-y(2)**2-y(3)**2)
110  d4=y(1)*d3
111  d5=one/(one+d3)
112 C *** D6 = COS(F)
113 C *** D7 = SIN(F)
114  d6=y(3)+((one-y(3)*y(3)*d5)*d1-y(2)*y(3)*d5*d2)/d4
115  d7=y(2)+((one-y(2)*y(2)*d5)*d2-y(2)*y(3)*d5*d1)/d4
116  y(15)=datan2(d7,d6)
117  y(6)=y(15)-y(3)*d7+y(2)*d6
118  y(7)=dsqrt(y(2)*y(2)+y(3)*y(3))
119  y(8)=two*datan(dsqrt(y(4)*y(4)+y(5)*y(5)))
120  IF (y(8).NE.zero) THEN
121  y(9)=datan2(y(4),y(5))
122  ELSE
123  y(9)=zero
124  ENDIF
125  IF (y(7).NE.zero) THEN
126  y(10)=datan2(y(2),y(3))-y(9)
127  ELSE
128  y(10)=zero
129  ENDIF
130  y(11)=y(6)-y(9)-y(10)
131  y(12)=y(14)-y(9)-y(10)
132  y(13)=y(15)-y(9)-y(10)
133 C
134 C *** MAKE ALL ANGLES BETWEEN ZERO AND TWO PI
135 C
136  y(6)=dmod(y(6)+two*tpi,tpi)
137  DO 40 i=8,15
138  40 y(i)=dmod(y(i)+two*tpi,tpi)
139  RETURN
140  END
subroutine eqnox(X, GM, Y)
Definition: eqnox.f:2