RACRotation.cpp
Go to the documentation of this file.
1 //==============================================================================
2 //
3 // This file is part of GNSSTk, the ARL:UT GNSS Toolkit.
4 //
5 // The GNSSTk is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU Lesser General Public License as published
7 // by the Free Software Foundation; either version 3.0 of the License, or
8 // any later version.
9 //
10 // The GNSSTk is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public
16 // License along with GNSSTk; if not, write to the Free Software Foundation,
17 // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
18 //
19 // This software was developed by Applied Research Laboratories at the
20 // University of Texas at Austin.
21 // Copyright 2004-2022, The Board of Regents of The University of Texas System
22 //
23 //==============================================================================
24 
25 //==============================================================================
26 //
27 // This software was developed by Applied Research Laboratories at the
28 // University of Texas at Austin, under contract to an agency or agencies
29 // within the U.S. Department of Defense. The U.S. Government retains all
30 // rights to use, duplicate, distribute, disclose, or release this software.
31 //
32 // Pursuant to DoD Directive 523024
33 //
34 // DISTRIBUTION STATEMENT A: This software has been approved for public
35 // release, distribution is unlimited.
36 //
37 //==============================================================================
38 
39 //
40 //
41 //#include <stdio.h>
42 
43 // gnsstk
44 #include "RACRotation.hpp"
45 
46 namespace gnsstk
47 {
48 
49 //using namespace std;
50 
51 RACRotation::RACRotation( const gnsstk::Triple& SVPositionVector,
52  const gnsstk::Triple& SVVelocityVector)
53  : gnsstk::Matrix<double>(3,3)
54 {
55  compute( SVPositionVector, SVVelocityVector );
56 }
57 
59  : gnsstk::Matrix<double>(3,3)
60 {
61  compute( xvt.x, xvt.v );
62 }
63 
64 //
65 // Given the SV position vector and the SV velocity vector,
66 // compute a rotation from ECEF XYZ to ECEF Radial,
67 // Along-Track, Cross-Track (RAC).
68 //
69 // Let the SV position vector be represented by R
70 // Let the SV velocity vector be represented by V
71 // 1.) Form the unit vector R^ = R / |R|.
72 // 2.) Compute vector C = R^ cross V and unit vector C^ = C / |C|. C^ is
73 // perpendiculat to the RV plane
74 // 3.) Compute A^ = C^ corss R^.
75 // 4.) [R^, A^, C^] is an orthonormal triad and the rotation matrix between
76 // XYZ and RAC is the matrix where R^, C^, and A^ are each a row of the
77 // matrix.
78 //
79 void RACRotation::compute( const gnsstk::Triple& SVPositionVector,
80  const gnsstk::Triple& SVVelocityVector)
81 {
82 
83  gnsstk::Triple unitR = SVPositionVector.unitVector();
84  gnsstk::Triple C = unitR.cross(SVVelocityVector);
85  gnsstk::Triple unitC = C.unitVector();
86  gnsstk::Triple unitA = unitC.cross(unitR);
87 
88  (*this) (0,0) = unitR[0];
89  (*this) (0,1) = unitR[1];
90  (*this) (0,2) = unitR[2];
91  (*this) (1,0) = unitA[0];
92  (*this) (1,1) = unitA[1];
93  (*this) (1,2) = unitA[2];
94  (*this) (2,0) = unitC[0];
95  (*this) (2,1) = unitC[1];
96  (*this) (2,2) = unitC[2];
97 }
98 
100 {
101  gnsstk::Vector<double> outV(3);
102 
103  /*
104  My goal was to use the following statement.
105  outV = this * inV;
106  However, for some reason, gcc refuses to recognize RACRotation as a
107  Matrix subclass. Therefore, I've incorporated the matrix multiply
108  as a temporary kludge.
109  */
110  if (inV.size()!=3)
111  {
112  gnsstk::Exception e("Incompatible dimensions for Vector");
113  GNSSTK_THROW(e);
114  }
115  size_t i, j;
116  for (i = 0; i < 3; i++)
117  {
118  outV[i] = 0;
119  for (j = 0; j < 3; j++)
120  {
121  double temp = (*this)(i,j) * inV[j];
122  outV[i] += temp;
123  }
124  }
125  /* end kludge */
126  return(outV);
127 }
128 
130 {
132  v[0] = inVec[0];
133  v[1] = inVec[1];
134  v[2] = inVec[2];
135 
137  gnsstk::Triple outVec( vOut[0], vOut[1], vOut[2] );
138  return(outVec);
139 }
140 
142 {
143  gnsstk::Xvt out;
144  out.clkbias = in.clkbias;
145  out.relcorr = in.relcorr;
146  out.clkdrift = in.clkdrift;
147  out.x = convertToRAC( in.x );
148  out.v = convertToRAC( in.v );
149  return(out);
150 }
151 } // end namespace gnsstk
gnsstk::Matrix< double >::v
Vector< double > v
the matrix stored in column major order
Definition: Matrix.hpp:239
gnsstk::Xvt::v
Triple v
satellite velocity in ECEF Cartesian, meters/second
Definition: Xvt.hpp:152
gnsstk::Triple
Definition: Triple.hpp:68
gnsstk
For Sinex::InputHistory.
Definition: BasicFramework.cpp:50
gnsstk::Triple::unitVector
Triple unitVector() const
Definition: Triple.cpp:134
gnsstk::RACRotation::convertToRAC
gnsstk::Vector< double > convertToRAC(const gnsstk::Vector< double > &inV)
Definition: RACRotation.cpp:99
gnsstk::Xvt::relcorr
double relcorr
relativity correction (standard 2R.V/c^2 term), seconds
Definition: Xvt.hpp:155
example4.temp
temp
Definition: example4.py:35
gnsstk::Exception
Definition: Exception.hpp:151
gnsstk::Xvt::x
Triple x
Sat position ECEF Cartesian (X,Y,Z) meters.
Definition: Xvt.hpp:151
gnsstk::Matrix
Definition: Matrix.hpp:72
RACRotation.hpp
gnsstk::Xvt::clkdrift
double clkdrift
satellite clock drift in seconds/second
Definition: Xvt.hpp:154
gnsstk::Xvt
Definition: Xvt.hpp:60
gnsstk::RACRotation::RACRotation
RACRotation(const gnsstk::Triple &SVPositionVector, const gnsstk::Triple &SVVelocityVector)
Definition: RACRotation.cpp:51
gnsstk::Vector< double >
gnsstk::Vector::size
size_t size() const
STL size.
Definition: Vector.hpp:207
gnsstk::Triple::cross
Triple cross(const Triple &right) const noexcept
Definition: Triple.cpp:118
GNSSTK_THROW
#define GNSSTK_THROW(exc)
Definition: Exception.hpp:366
gnsstk::Xvt::clkbias
double clkbias
Sat clock correction in seconds.
Definition: Xvt.hpp:153
gnsstk::RACRotation::compute
void compute(const gnsstk::Triple &SVPositionVector, const gnsstk::Triple &SVVelocityVector)
Definition: RACRotation.cpp:79


gnsstk
Author(s):
autogenerated on Wed Oct 25 2023 02:40:40