-
Notifications
You must be signed in to change notification settings - Fork 20
/
cc62s.f
99 lines (88 loc) · 2.41 KB
/
cc62s.f
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
SUBROUTINE sla_CC62S (V, A, B, R, AD, BD, RD)
*+
* - - - - - -
* C C 6 2 S
* - - - - - -
*
* Conversion of position & velocity in Cartesian coordinates
* to spherical coordinates (single precision)
*
* Given:
* V r(6) Cartesian position & velocity vector
*
* Returned:
* A r longitude (radians)
* B r latitude (radians)
* R r radial coordinate
* AD r longitude derivative (radians per unit time)
* BD r latitude derivative (radians per unit time)
* RD r radial derivative
*
* P.T.Wallace Starlink 28 April 1996
*
* Copyright (C) 1996 Rutherford Appleton Laboratory
*
* License:
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program (see SLA_CONDITIONS); if not, write to the
* Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307 USA
*
*-
IMPLICIT NONE
REAL V(6),A,B,R,AD,BD,RD
REAL X,Y,Z,XD,YD,ZD,RXY2,RXY,R2,XYP
* Components of position/velocity vector
X=V(1)
Y=V(2)
Z=V(3)
XD=V(4)
YD=V(5)
ZD=V(6)
* Component of R in XY plane squared
RXY2=X*X+Y*Y
* Modulus squared
R2=RXY2+Z*Z
* Protection against null vector
IF (R2.EQ.0.0) THEN
X=XD
Y=YD
Z=ZD
RXY2=X*X+Y*Y
R2=RXY2+Z*Z
END IF
* Position and velocity in spherical coordinates
RXY=SQRT(RXY2)
XYP=X*XD+Y*YD
IF (RXY2.NE.0.0) THEN
A=ATAN2(Y,X)
B=ATAN2(Z,RXY)
AD=(X*YD-Y*XD)/RXY2
BD=(ZD*RXY2-Z*XYP)/(R2*RXY)
ELSE
A=0.0
IF (Z.NE.0.0) THEN
B=ATAN2(Z,RXY)
ELSE
B=0.0
END IF
AD=0.0
BD=0.0
END IF
R=SQRT(R2)
IF (R.NE.0.0) THEN
RD=(XYP+Z*ZD)/R
ELSE
RD=0.0
END IF
END