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

Last change on this file since 18368 was 18346, checked in by tbretz, 11 years ago
File size: 5.5 KB
Line 
1#include "sofa.h"
2
3double iauPas(double al, double ap, double bl, double bp)
4/*
5** - - - - - - -
6** i a u P a s
7** - - - - - - -
8**
9** Position-angle from spherical coordinates.
10**
11** This function is part of the International Astronomical Union's
12** SOFA (Standards Of Fundamental Astronomy) software collection.
13**
14** Status: vector/matrix support function.
15**
16** Given:
17** al double longitude of point A (e.g. RA) in radians
18** ap double latitude of point A (e.g. Dec) in radians
19** bl double longitude of point B
20** bp double latitude of point B
21**
22** Returned (function value):
23** double position angle of B with respect to A
24**
25** Notes:
26**
27** 1) The result is the bearing (position angle), in radians, of point
28** B with respect to point A. It is in the range -pi to +pi. The
29** sense is such that if B is a small distance "east" of point A,
30** the bearing is approximately +pi/2.
31**
32** 2) Zero is returned if the two points are coincident.
33**
34** This revision: 2013 June 18
35**
36** SOFA release 2015-02-09
37**
38** Copyright (C) 2015 IAU SOFA Board. See notes at end.
39*/
40{
41 double dl, x, y, pa;
42
43 dl = bl - al;
44 y = sin(dl) * cos(bp);
45 x = sin(bp) * cos(ap) - cos(bp) * sin(ap) * cos(dl);
46 pa = ((x != 0.0) || (y != 0.0)) ? atan2(y, x) : 0.0;
47
48 return pa;
49
50/*----------------------------------------------------------------------
51**
52** Copyright (C) 2015
53** Standards Of Fundamental Astronomy Board
54** of the International Astronomical Union.
55**
56** =====================
57** SOFA Software License
58** =====================
59**
60** NOTICE TO USER:
61**
62** BY USING THIS SOFTWARE YOU ACCEPT THE FOLLOWING SIX TERMS AND
63** CONDITIONS WHICH APPLY TO ITS USE.
64**
65** 1. The Software is owned by the IAU SOFA Board ("SOFA").
66**
67** 2. Permission is granted to anyone to use the SOFA software for any
68** purpose, including commercial applications, free of charge and
69** without payment of royalties, subject to the conditions and
70** restrictions listed below.
71**
72** 3. You (the user) may copy and distribute SOFA source code to others,
73** and use and adapt its code and algorithms in your own software,
74** on a world-wide, royalty-free basis. That portion of your
75** distribution that does not consist of intact and unchanged copies
76** of SOFA source code files is a "derived work" that must comply
77** with the following requirements:
78**
79** a) Your work shall be marked or carry a statement that it
80** (i) uses routines and computations derived by you from
81** software provided by SOFA under license to you; and
82** (ii) does not itself constitute software provided by and/or
83** endorsed by SOFA.
84**
85** b) The source code of your derived work must contain descriptions
86** of how the derived work is based upon, contains and/or differs
87** from the original SOFA software.
88**
89** c) The names of all routines in your derived work shall not
90** include the prefix "iau" or "sofa" or trivial modifications
91** thereof such as changes of case.
92**
93** d) The origin of the SOFA components of your derived work must
94** not be misrepresented; you must not claim that you wrote the
95** original software, nor file a patent application for SOFA
96** software or algorithms embedded in the SOFA software.
97**
98** e) These requirements must be reproduced intact in any source
99** distribution and shall apply to anyone to whom you have
100** granted a further right to modify the source code of your
101** derived work.
102**
103** Note that, as originally distributed, the SOFA software is
104** intended to be a definitive implementation of the IAU standards,
105** and consequently third-party modifications are discouraged. All
106** variations, no matter how minor, must be explicitly marked as
107** such, as explained above.
108**
109** 4. You shall not cause the SOFA software to be brought into
110** disrepute, either by misuse, or use for inappropriate tasks, or
111** by inappropriate modification.
112**
113** 5. The SOFA software is provided "as is" and SOFA makes no warranty
114** as to its use or performance. SOFA does not and cannot warrant
115** the performance or results which the user may obtain by using the
116** SOFA software. SOFA makes no warranties, express or implied, as
117** to non-infringement of third party rights, merchantability, or
118** fitness for any particular purpose. In no event will SOFA be
119** liable to the user for any consequential, incidental, or special
120** damages, including any lost profits or lost savings, even if a
121** SOFA representative has been advised of such damages, or for any
122** claim by any third party.
123**
124** 6. The provision of any version of the SOFA software under the terms
125** and conditions specified herein does not imply that future
126** versions will also be made available under the same terms and
127** conditions.
128*
129** In any published work or commercial product which uses the SOFA
130** software directly, acknowledgement (see www.iausofa.org) is
131** appreciated.
132**
133** Correspondence concerning SOFA software should be addressed as
134** follows:
135**
136** By email: sofa@ukho.gov.uk
137** By post: IAU SOFA Center
138** HM Nautical Almanac Office
139** UK Hydrographic Office
140** Admiralty Way, Taunton
141** Somerset, TA1 2DN
142** United Kingdom
143**
144**--------------------------------------------------------------------*/
145}
Note: See TracBrowser for help on using the repository browser.