source: trunk/FACT++/sofa/src/gd2gce.c@ 18368

Last change on this file since 18368 was 18346, checked in by tbretz, 11 years ago
File size: 6.8 KB
Line 
1#include "sofa.h"
2
3int iauGd2gce ( double a, double f, double elong, double phi,
4 double height, double xyz[3] )
5/*
6** - - - - - - - - - -
7** i a u G d 2 g c e
8** - - - - - - - - - -
9**
10** Transform geodetic coordinates to geocentric for a reference
11** ellipsoid of specified form.
12**
13** This function is part of the International Astronomical Union's
14** SOFA (Standards of Fundamental Astronomy) software collection.
15**
16** Status: support function.
17**
18** Given:
19** a double equatorial radius (Notes 1,4)
20** f double flattening (Notes 2,4)
21** elong double longitude (radians, east +ve)
22** phi double latitude (geodetic, radians, Note 4)
23** height double height above ellipsoid (geodetic, Notes 3,4)
24**
25** Returned:
26** xyz double[3] geocentric vector (Note 3)
27**
28** Returned (function value):
29** int status: 0 = OK
30** -1 = illegal case (Note 4)
31** Notes:
32**
33** 1) The equatorial radius, a, can be in any units, but meters is
34** the conventional choice.
35**
36** 2) The flattening, f, is (for the Earth) a value around 0.00335,
37** i.e. around 1/298.
38**
39** 3) The equatorial radius, a, and the height, height, must be
40** given in the same units, and determine the units of the
41** returned geocentric vector, xyz.
42**
43** 4) No validation is performed on individual arguments. The error
44** status -1 protects against (unrealistic) cases that would lead
45** to arithmetic exceptions. If an error occurs, xyz is unchanged.
46**
47** 5) The inverse transformation is performed in the function
48** iauGc2gde.
49**
50** 6) The transformation for a standard ellipsoid (such as WGS84) can
51** more conveniently be performed by calling iauGd2gc, which uses a
52** numerical code to identify the required a and f values.
53**
54** References:
55**
56** Green, R.M., Spherical Astronomy, Cambridge University Press,
57** (1985) Section 4.5, p96.
58**
59** Explanatory Supplement to the Astronomical Almanac,
60** P. Kenneth Seidelmann (ed), University Science Books (1992),
61** Section 4.22, p202.
62**
63** This revision: 2013 June 18
64**
65** SOFA release 2015-02-09
66**
67** Copyright (C) 2015 IAU SOFA Board. See notes at end.
68*/
69{
70 double sp, cp, w, d, ac, as, r;
71
72/* Functions of geodetic latitude. */
73 sp = sin(phi);
74 cp = cos(phi);
75 w = 1.0 - f;
76 w = w * w;
77 d = cp*cp + w*sp*sp;
78 if ( d <= 0.0 ) return -1;
79 ac = a / sqrt(d);
80 as = w * ac;
81
82/* Geocentric vector. */
83 r = (ac + height) * cp;
84 xyz[0] = r * cos(elong);
85 xyz[1] = r * sin(elong);
86 xyz[2] = (as + height) * sp;
87
88/* Success. */
89 return 0;
90
91/*----------------------------------------------------------------------
92**
93** Copyright (C) 2015
94** Standards Of Fundamental Astronomy Board
95** of the International Astronomical Union.
96**
97** =====================
98** SOFA Software License
99** =====================
100**
101** NOTICE TO USER:
102**
103** BY USING THIS SOFTWARE YOU ACCEPT THE FOLLOWING SIX TERMS AND
104** CONDITIONS WHICH APPLY TO ITS USE.
105**
106** 1. The Software is owned by the IAU SOFA Board ("SOFA").
107**
108** 2. Permission is granted to anyone to use the SOFA software for any
109** purpose, including commercial applications, free of charge and
110** without payment of royalties, subject to the conditions and
111** restrictions listed below.
112**
113** 3. You (the user) may copy and distribute SOFA source code to others,
114** and use and adapt its code and algorithms in your own software,
115** on a world-wide, royalty-free basis. That portion of your
116** distribution that does not consist of intact and unchanged copies
117** of SOFA source code files is a "derived work" that must comply
118** with the following requirements:
119**
120** a) Your work shall be marked or carry a statement that it
121** (i) uses routines and computations derived by you from
122** software provided by SOFA under license to you; and
123** (ii) does not itself constitute software provided by and/or
124** endorsed by SOFA.
125**
126** b) The source code of your derived work must contain descriptions
127** of how the derived work is based upon, contains and/or differs
128** from the original SOFA software.
129**
130** c) The names of all routines in your derived work shall not
131** include the prefix "iau" or "sofa" or trivial modifications
132** thereof such as changes of case.
133**
134** d) The origin of the SOFA components of your derived work must
135** not be misrepresented; you must not claim that you wrote the
136** original software, nor file a patent application for SOFA
137** software or algorithms embedded in the SOFA software.
138**
139** e) These requirements must be reproduced intact in any source
140** distribution and shall apply to anyone to whom you have
141** granted a further right to modify the source code of your
142** derived work.
143**
144** Note that, as originally distributed, the SOFA software is
145** intended to be a definitive implementation of the IAU standards,
146** and consequently third-party modifications are discouraged. All
147** variations, no matter how minor, must be explicitly marked as
148** such, as explained above.
149**
150** 4. You shall not cause the SOFA software to be brought into
151** disrepute, either by misuse, or use for inappropriate tasks, or
152** by inappropriate modification.
153**
154** 5. The SOFA software is provided "as is" and SOFA makes no warranty
155** as to its use or performance. SOFA does not and cannot warrant
156** the performance or results which the user may obtain by using the
157** SOFA software. SOFA makes no warranties, express or implied, as
158** to non-infringement of third party rights, merchantability, or
159** fitness for any particular purpose. In no event will SOFA be
160** liable to the user for any consequential, incidental, or special
161** damages, including any lost profits or lost savings, even if a
162** SOFA representative has been advised of such damages, or for any
163** claim by any third party.
164**
165** 6. The provision of any version of the SOFA software under the terms
166** and conditions specified herein does not imply that future
167** versions will also be made available under the same terms and
168** conditions.
169*
170** In any published work or commercial product which uses the SOFA
171** software directly, acknowledgement (see www.iausofa.org) is
172** appreciated.
173**
174** Correspondence concerning SOFA software should be addressed as
175** follows:
176**
177** By email: sofa@ukho.gov.uk
178** By post: IAU SOFA Center
179** HM Nautical Almanac Office
180** UK Hydrographic Office
181** Admiralty Way, Taunton
182** Somerset, TA1 2DN
183** United Kingdom
184**
185**--------------------------------------------------------------------*/
186
187}
Note: See TracBrowser for help on using the repository browser.