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

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