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

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