File Coverage

erfasrc/src/rm2v.c
Criterion Covered Total %
statement 0 16 0.0
branch 0 2 0.0
condition n/a
subroutine n/a
pod n/a
total 0 18 0.0


line stmt bran cond sub pod time code
1             #include "erfa.h"
2              
3 0           void eraRm2v(double r[3][3], double w[3])
4             /*
5             ** - - - - - - - -
6             ** e r a R m 2 v
7             ** - - - - - - - -
8             **
9             ** Express an r-matrix as an r-vector.
10             **
11             ** Given:
12             ** r double[3][3] rotation matrix
13             **
14             ** Returned:
15             ** w double[3] rotation vector (Note 1)
16             **
17             ** Notes:
18             **
19             ** 1) A rotation matrix describes a rotation through some angle about
20             ** some arbitrary axis called the Euler axis. The "rotation vector"
21             ** returned by this function has the same direction as the Euler axis,
22             ** and its magnitude is the angle in radians. (The magnitude and
23             ** direction can be separated by means of the function eraPn.)
24             **
25             ** 2) If r is null, so is the result. If r is not a rotation matrix
26             ** the result is undefined; r must be proper (i.e. have a positive
27             ** determinant) and real orthogonal (inverse = transpose).
28             **
29             ** 3) The reference frame rotates clockwise as seen looking along
30             ** the rotation vector from the origin.
31             **
32             ** Copyright (C) 2013-2020, NumFOCUS Foundation.
33             ** Derived, with permission, from the SOFA library. See notes at end of file.
34             */
35             {
36             double x, y, z, s2, c2, phi, f;
37              
38              
39 0           x = r[1][2] - r[2][1];
40 0           y = r[2][0] - r[0][2];
41 0           z = r[0][1] - r[1][0];
42 0           s2 = sqrt(x*x + y*y + z*z);
43 0 0         if (s2 > 0) {
44 0           c2 = r[0][0] + r[1][1] + r[2][2] - 1.0;
45 0           phi = atan2(s2, c2);
46 0           f = phi / s2;
47 0           w[0] = x * f;
48 0           w[1] = y * f;
49 0           w[2] = z * f;
50             } else {
51 0           w[0] = 0.0;
52 0           w[1] = 0.0;
53 0           w[2] = 0.0;
54             }
55              
56 0           return;
57              
58             }
59             /*----------------------------------------------------------------------
60             **
61             **
62             ** Copyright (C) 2013-2020, NumFOCUS Foundation.
63             ** All rights reserved.
64             **
65             ** This library is derived, with permission, from the International
66             ** Astronomical Union's "Standards of Fundamental Astronomy" library,
67             ** available from http://www.iausofa.org.
68             **
69             ** The ERFA version is intended to retain identical functionality to
70             ** the SOFA library, but made distinct through different function and
71             ** file names, as set out in the SOFA license conditions. The SOFA
72             ** original has a role as a reference standard for the IAU and IERS,
73             ** and consequently redistribution is permitted only in its unaltered
74             ** state. The ERFA version is not subject to this restriction and
75             ** therefore can be included in distributions which do not support the
76             ** concept of "read only" software.
77             **
78             ** Although the intent is to replicate the SOFA API (other than
79             ** replacement of prefix names) and results (with the exception of
80             ** bugs; any that are discovered will be fixed), SOFA is not
81             ** responsible for any errors found in this version of the library.
82             **
83             ** If you wish to acknowledge the SOFA heritage, please acknowledge
84             ** that you are using a library derived from SOFA, rather than SOFA
85             ** itself.
86             **
87             **
88             ** TERMS AND CONDITIONS
89             **
90             ** Redistribution and use in source and binary forms, with or without
91             ** modification, are permitted provided that the following conditions
92             ** are met:
93             **
94             ** 1 Redistributions of source code must retain the above copyright
95             ** notice, this list of conditions and the following disclaimer.
96             **
97             ** 2 Redistributions in binary form must reproduce the above copyright
98             ** notice, this list of conditions and the following disclaimer in
99             ** the documentation and/or other materials provided with the
100             ** distribution.
101             **
102             ** 3 Neither the name of the Standards Of Fundamental Astronomy Board,
103             ** the International Astronomical Union nor the names of its
104             ** contributors may be used to endorse or promote products derived
105             ** from this software without specific prior written permission.
106             **
107             ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
108             ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
109             ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
110             ** FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
111             ** COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
112             ** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
113             ** BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
114             ** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
115             ** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
116             ** LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
117             ** ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
118             ** POSSIBILITY OF SUCH DAMAGE.
119             **
120             */