line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#include "erfa.h" |
2
|
|
|
|
|
|
|
|
3
|
11
|
|
|
|
|
|
int eraGd2gce ( double a, double f, double elong, double phi, |
4
|
|
|
|
|
|
|
double height, double xyz[3] ) |
5
|
|
|
|
|
|
|
/* |
6
|
|
|
|
|
|
|
** - - - - - - - - - - |
7
|
|
|
|
|
|
|
** e r a G d 2 g c e |
8
|
|
|
|
|
|
|
** - - - - - - - - - - |
9
|
|
|
|
|
|
|
** |
10
|
|
|
|
|
|
|
** Transform geodetic coordinates to geocentric for a reference |
11
|
|
|
|
|
|
|
** ellipsoid of specified form. |
12
|
|
|
|
|
|
|
** |
13
|
|
|
|
|
|
|
** Given: |
14
|
|
|
|
|
|
|
** a double equatorial radius (Notes 1,4) |
15
|
|
|
|
|
|
|
** f double flattening (Notes 2,4) |
16
|
|
|
|
|
|
|
** elong double longitude (radians, east +ve) |
17
|
|
|
|
|
|
|
** phi double latitude (geodetic, radians, Note 4) |
18
|
|
|
|
|
|
|
** height double height above ellipsoid (geodetic, Notes 3,4) |
19
|
|
|
|
|
|
|
** |
20
|
|
|
|
|
|
|
** Returned: |
21
|
|
|
|
|
|
|
** xyz double[3] geocentric vector (Note 3) |
22
|
|
|
|
|
|
|
** |
23
|
|
|
|
|
|
|
** Returned (function value): |
24
|
|
|
|
|
|
|
** int status: 0 = OK |
25
|
|
|
|
|
|
|
** -1 = illegal case (Note 4) |
26
|
|
|
|
|
|
|
** Notes: |
27
|
|
|
|
|
|
|
** |
28
|
|
|
|
|
|
|
** 1) The equatorial radius, a, can be in any units, but meters is |
29
|
|
|
|
|
|
|
** the conventional choice. |
30
|
|
|
|
|
|
|
** |
31
|
|
|
|
|
|
|
** 2) The flattening, f, is (for the Earth) a value around 0.00335, |
32
|
|
|
|
|
|
|
** i.e. around 1/298. |
33
|
|
|
|
|
|
|
** |
34
|
|
|
|
|
|
|
** 3) The equatorial radius, a, and the height, height, must be |
35
|
|
|
|
|
|
|
** given in the same units, and determine the units of the |
36
|
|
|
|
|
|
|
** returned geocentric vector, xyz. |
37
|
|
|
|
|
|
|
** |
38
|
|
|
|
|
|
|
** 4) No validation is performed on individual arguments. The error |
39
|
|
|
|
|
|
|
** status -1 protects against (unrealistic) cases that would lead |
40
|
|
|
|
|
|
|
** to arithmetic exceptions. If an error occurs, xyz is unchanged. |
41
|
|
|
|
|
|
|
** |
42
|
|
|
|
|
|
|
** 5) The inverse transformation is performed in the function |
43
|
|
|
|
|
|
|
** eraGc2gde. |
44
|
|
|
|
|
|
|
** |
45
|
|
|
|
|
|
|
** 6) The transformation for a standard ellipsoid (such as ERFA_WGS84) can |
46
|
|
|
|
|
|
|
** more conveniently be performed by calling eraGd2gc, which uses a |
47
|
|
|
|
|
|
|
** numerical code to identify the required a and f values. |
48
|
|
|
|
|
|
|
** |
49
|
|
|
|
|
|
|
** References: |
50
|
|
|
|
|
|
|
** |
51
|
|
|
|
|
|
|
** Green, R.M., Spherical Astronomy, Cambridge University Press, |
52
|
|
|
|
|
|
|
** (1985) Section 4.5, p96. |
53
|
|
|
|
|
|
|
** |
54
|
|
|
|
|
|
|
** Explanatory Supplement to the Astronomical Almanac, |
55
|
|
|
|
|
|
|
** P. Kenneth Seidelmann (ed), University Science Books (1992), |
56
|
|
|
|
|
|
|
** Section 4.22, p202. |
57
|
|
|
|
|
|
|
** |
58
|
|
|
|
|
|
|
** Copyright (C) 2013-2020, NumFOCUS Foundation. |
59
|
|
|
|
|
|
|
** Derived, with permission, from the SOFA library. See notes at end of file. |
60
|
|
|
|
|
|
|
*/ |
61
|
|
|
|
|
|
|
{ |
62
|
|
|
|
|
|
|
double sp, cp, w, d, ac, as, r; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
/* Functions of geodetic latitude. */ |
66
|
11
|
|
|
|
|
|
sp = sin(phi); |
67
|
11
|
|
|
|
|
|
cp = cos(phi); |
68
|
11
|
|
|
|
|
|
w = 1.0 - f; |
69
|
11
|
|
|
|
|
|
w = w * w; |
70
|
11
|
|
|
|
|
|
d = cp*cp + w*sp*sp; |
71
|
11
|
50
|
|
|
|
|
if ( d <= 0.0 ) return -1; |
72
|
11
|
|
|
|
|
|
ac = a / sqrt(d); |
73
|
11
|
|
|
|
|
|
as = w * ac; |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
/* Geocentric vector. */ |
76
|
11
|
|
|
|
|
|
r = (ac + height) * cp; |
77
|
11
|
|
|
|
|
|
xyz[0] = r * cos(elong); |
78
|
11
|
|
|
|
|
|
xyz[1] = r * sin(elong); |
79
|
11
|
|
|
|
|
|
xyz[2] = (as + height) * sp; |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
/* Success. */ |
82
|
11
|
|
|
|
|
|
return 0; |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
/*---------------------------------------------------------------------- |
86
|
|
|
|
|
|
|
** |
87
|
|
|
|
|
|
|
** |
88
|
|
|
|
|
|
|
** Copyright (C) 2013-2020, NumFOCUS Foundation. |
89
|
|
|
|
|
|
|
** All rights reserved. |
90
|
|
|
|
|
|
|
** |
91
|
|
|
|
|
|
|
** This library is derived, with permission, from the International |
92
|
|
|
|
|
|
|
** Astronomical Union's "Standards of Fundamental Astronomy" library, |
93
|
|
|
|
|
|
|
** available from http://www.iausofa.org. |
94
|
|
|
|
|
|
|
** |
95
|
|
|
|
|
|
|
** The ERFA version is intended to retain identical functionality to |
96
|
|
|
|
|
|
|
** the SOFA library, but made distinct through different function and |
97
|
|
|
|
|
|
|
** file names, as set out in the SOFA license conditions. The SOFA |
98
|
|
|
|
|
|
|
** original has a role as a reference standard for the IAU and IERS, |
99
|
|
|
|
|
|
|
** and consequently redistribution is permitted only in its unaltered |
100
|
|
|
|
|
|
|
** state. The ERFA version is not subject to this restriction and |
101
|
|
|
|
|
|
|
** therefore can be included in distributions which do not support the |
102
|
|
|
|
|
|
|
** concept of "read only" software. |
103
|
|
|
|
|
|
|
** |
104
|
|
|
|
|
|
|
** Although the intent is to replicate the SOFA API (other than |
105
|
|
|
|
|
|
|
** replacement of prefix names) and results (with the exception of |
106
|
|
|
|
|
|
|
** bugs; any that are discovered will be fixed), SOFA is not |
107
|
|
|
|
|
|
|
** responsible for any errors found in this version of the library. |
108
|
|
|
|
|
|
|
** |
109
|
|
|
|
|
|
|
** If you wish to acknowledge the SOFA heritage, please acknowledge |
110
|
|
|
|
|
|
|
** that you are using a library derived from SOFA, rather than SOFA |
111
|
|
|
|
|
|
|
** itself. |
112
|
|
|
|
|
|
|
** |
113
|
|
|
|
|
|
|
** |
114
|
|
|
|
|
|
|
** TERMS AND CONDITIONS |
115
|
|
|
|
|
|
|
** |
116
|
|
|
|
|
|
|
** Redistribution and use in source and binary forms, with or without |
117
|
|
|
|
|
|
|
** modification, are permitted provided that the following conditions |
118
|
|
|
|
|
|
|
** are met: |
119
|
|
|
|
|
|
|
** |
120
|
|
|
|
|
|
|
** 1 Redistributions of source code must retain the above copyright |
121
|
|
|
|
|
|
|
** notice, this list of conditions and the following disclaimer. |
122
|
|
|
|
|
|
|
** |
123
|
|
|
|
|
|
|
** 2 Redistributions in binary form must reproduce the above copyright |
124
|
|
|
|
|
|
|
** notice, this list of conditions and the following disclaimer in |
125
|
|
|
|
|
|
|
** the documentation and/or other materials provided with the |
126
|
|
|
|
|
|
|
** distribution. |
127
|
|
|
|
|
|
|
** |
128
|
|
|
|
|
|
|
** 3 Neither the name of the Standards Of Fundamental Astronomy Board, |
129
|
|
|
|
|
|
|
** the International Astronomical Union nor the names of its |
130
|
|
|
|
|
|
|
** contributors may be used to endorse or promote products derived |
131
|
|
|
|
|
|
|
** from this software without specific prior written permission. |
132
|
|
|
|
|
|
|
** |
133
|
|
|
|
|
|
|
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
134
|
|
|
|
|
|
|
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
135
|
|
|
|
|
|
|
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
136
|
|
|
|
|
|
|
** FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
137
|
|
|
|
|
|
|
** COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
138
|
|
|
|
|
|
|
** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
139
|
|
|
|
|
|
|
** BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
140
|
|
|
|
|
|
|
** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
141
|
|
|
|
|
|
|
** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
142
|
|
|
|
|
|
|
** LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN |
143
|
|
|
|
|
|
|
** ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
144
|
|
|
|
|
|
|
** POSSIBILITY OF SUCH DAMAGE. |
145
|
|
|
|
|
|
|
** |
146
|
|
|
|
|
|
|
*/ |