source: trunk/FACT++/sofa/src/sepp.c@ 18365

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