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