1 |
#include <iostream> |
2 |
#include <stdio.h> |
3 |
#include <TObject.h> |
4 |
#include <TString.h> |
5 |
#include <TMatrixD.h> |
6 |
|
7 |
#include <OrientationInfo.h> |
8 |
|
9 |
ClassImp(OrientationInfo) |
10 |
|
11 |
|
12 |
using namespace std; |
13 |
|
14 |
OrientationInfo::OrientationInfo() : TObject(){ |
15 |
a = 360/(2*TMath::Pi()); |
16 |
Re = 6000000; |
17 |
} |
18 |
|
19 |
OrientationInfo::~OrientationInfo(){ |
20 |
} |
21 |
|
22 |
TMatrixD OrientationInfo::QuatoECI(Float_t q0, Float_t q1, Float_t q2, Float_t q3){ |
23 |
TMatrixD Pij(3,3); |
24 |
Pij(0,0) = pow(q0,2)+pow(q1,2)-pow(q2,2)-pow(q3,2); |
25 |
Pij(0,1) = /*2*(q1*q2+q0*q3);/*/ 2*(q1*q2-q0*q3); |
26 |
Pij(0,2) = /*2*(q1*q3-q0*q2);/*/ 2*(q1*q3+q0*q2); |
27 |
Pij(1,0) = /*2*(q1*q2-q0*q3);/*/ 2*(q1*q2+q0*q3); |
28 |
Pij(1,1) = pow(q0,2)-pow(q1,2)+pow(q2,2)-pow(q3,2); |
29 |
Pij(1,2) = /*2*(q2*q3+q0*q1);/*/ 2*(q2*q3-q0*q1); |
30 |
Pij(2,0) = /*2*(q1*q3+q0*q2);/*/ 2*(q1*q3-q0*q2); |
31 |
Pij(2,1) = /*2*(q2*q3-q0*q1);/*/ 2*(q2*q3+q0*q1); |
32 |
Pij(2,2) = pow(q0,2)-pow(q1,2)-pow(q2,2)+pow(q3,2); |
33 |
return Pij; |
34 |
} |
35 |
|
36 |
TMatrixD OrientationInfo::ECItoGreenwich(TMatrixD Aij, UInt_t t){ |
37 |
//t=1154304000+86400*365; |
38 |
TMatrixD Gij(3,3); |
39 |
Double_t omg = (7.292115e-5)*a; // Earth rotation velosity (Around polar axis); |
40 |
//Double_t t1 = 0; |
41 |
//if(t<=1158883200) t1 = 1127347200+229.2732; //absTime at 22/09/2005 + diference between Solar midnight and Greenwich sidereal midnight |
42 |
//if(t>1158883200&&t<=1190419200) t1 = 1158883200+172.3415;//absTime at 22/09/2006 + diference between Solar midnight and Greenwich sidereal midnight |
43 |
//if(t>=1190419200&&t<1222041600) t1 = 1190419200+115.39; //absTime at 22/09/2007 + diference between Solar midnight and Greenwich sidereal midnight |
44 |
//if(t>=1222041600) t1 = 1222041600 + 294.9361; //absTime at 22/09/2008 + diference between Solar midnight and Greenwich sidereal midnight |
45 |
//UInt_t Nd = (t-t1)/86400; |
46 |
//Int_t DifSuSt = Nd*236.55; |
47 |
Double_t d = (t-10957*86400-43200); //Number of day, passing from 01/01/2000 12:00:00 to t; |
48 |
d = d/86400; |
49 |
//d = t-da*86400+DifSuSt |
50 |
//cout<<"t = "<<t<<"\n"; |
51 |
//cout<<"t - 2000y = "<<t-10957*86400-43200<<"\n"; |
52 |
//cout<<"d = "<<d<<"\n"; |
53 |
//Int_t tl = t%86400; //!!!!!!!!!!!!!!!!!!!!!!!! |
54 |
Double_t T = d/36525; //Number of Julian centuries; |
55 |
|
56 |
//Double_t tl = t-t1-Nd*86400-DifSuSt; |
57 |
Double_t Se = 6*3600+41*60+236.555367908*d+0.093104*pow(T,2)-(6.2e-6)*pow(T,3); |
58 |
//cout<<"Se = "<<Se<<"\n"; |
59 |
//cout<<t<<endl<<d<<endl<<tl<<endl<<Se+omg*tl*86400/360<<endl; |
60 |
Int_t tr = (t-10957*86400)%86400; |
61 |
//cout<<"tr = "<<tr<<endl; |
62 |
Double_t Somg = (Se+49.077+omg*86400*tr/360)*360/86400; |
63 |
//cout<<"t1 = "<<(t-10957*86400)%86400<<"\n"; |
64 |
//cout<<"tr = "<<tr<<"\n"; |
65 |
//cout<<"Somg = "<<Se+omg*86400*tr/360<<"\n"; |
66 |
//cout<<"Somg = "<<((Somg-360*6)*86400/360/3600-20)*60<<"\n"; |
67 |
//cout<<cos(Somg/a)<<endl; |
68 |
Gij(0,0) = cos(Somg/a); |
69 |
Gij(0,1) = -sin(Somg/a); |
70 |
Gij(0,2) = 0; |
71 |
Gij(1,0) = sin(Somg/a); |
72 |
Gij(1,1) = cos(Somg/a); |
73 |
Gij(1,2) = 0; |
74 |
Gij(2,0) = 0; |
75 |
Gij(2,1) = 0; |
76 |
Gij(2,2) = 1; |
77 |
Gij.Invert(); |
78 |
//SetDirAxisGreenwich(Aij); |
79 |
//cout<<(Somg/a)<<endl<<Aij(0,0)<<" "<<Aij(1,0)<<" "<<Aij(2,0)<<endl; |
80 |
return Gij*Aij; |
81 |
} |
82 |
|
83 |
TMatrixD OrientationInfo::GreenwichtoGEO(Double_t lat, Double_t lon, TMatrixD Aij){ |
84 |
//Double_t a = 360/(2*TMath::Pi()); |
85 |
//Double_t Re = 6000000; |
86 |
TMatrixD Gij(3,3); |
87 |
TMatrixD Fij(3,3); |
88 |
|
89 |
TMatrixD Hij(3,3); //TEST |
90 |
TMatrixD Iij(3,3); //TEST |
91 |
|
92 |
// if((lat<0.1)&&(lat>-0.1)){ |
93 |
//cout<<"lon = "<<lon<<" lat = "<<lat<<endl; |
94 |
lon=(-lon)/a; lat=(-lat)/a; |
95 |
//cout<<"lon = "<<lon<<" lat = "<<lat<<endl; |
96 |
// |
97 |
// cout<<"Quaternions Array"<<endl; |
98 |
//cout<<Aij(0,0)<<" "<<Aij(0,1)<<" "<<Aij(0,2)<<endl; |
99 |
//cout<<Aij(1,0)<<" "<<Aij(1,1)<<" "<<Aij(1,2)<<endl; |
100 |
//cout<<Aij(2,0)<<" "<<Aij(2,1)<<" "<<Aij(2,2)<<endl<<endl; |
101 |
// } |
102 |
//Double_t x0 = (alt+Re)*sin(lat)*sin(lon); |
103 |
//Double_t y0 = (alt+Re)*sin(lat)*cos(lon); |
104 |
//Double_t Sa = lon-a*atan(y0/x0); |
105 |
//if (y0>0&&x0<0) Sa=-Sa+90; |
106 |
//if (y0<0&&x0<0) Sa=Sa-90; |
107 |
//if (y0>0&&x0==0) Sa=90; |
108 |
//if (y0<0&&x0==0) Sa=-90; |
109 |
|
110 |
Gij(0,0) = cos(lon); |
111 |
Gij(0,1) = -sin(lon); |
112 |
Gij(0,2) = 0; |
113 |
Gij(1,0) = sin(lon); |
114 |
Gij(1,1) = cos(lon); |
115 |
Gij(1,2) = 0; |
116 |
Gij(2,0) = 0; |
117 |
Gij(2,1) = 0; |
118 |
Gij(2,2) = 1; |
119 |
|
120 |
//cout<<"First rotation"<<endl; |
121 |
//cout<<Gij(0,0)<<" "<<Gij(0,1)<<" "<<Gij(0,2)<<endl; |
122 |
//cout<<Gij(1,0)<<" "<<Gij(1,1)<<" "<<Gij(1,2)<<endl; |
123 |
//cout<<Gij(2,0)<<" "<<Gij(2,1)<<" "<<Gij(2,2)<<endl<<endl; |
124 |
|
125 |
//Gij.Invert(); |
126 |
|
127 |
Fij(0,0) = cos(lat); |
128 |
Fij(0,1) = 0; |
129 |
Fij(0,2) = -sin(lat); |
130 |
Fij(1,0) = 0; |
131 |
Fij(1,1) = 1; |
132 |
Fij(1,2) = 0; |
133 |
Fij(2,0) = sin(lat); |
134 |
Fij(2,1) = 0; |
135 |
Fij(2,2) = cos(lat); |
136 |
|
137 |
//Fij.Invert(); |
138 |
|
139 |
//if((lat<0.1)&&(lat>-0.1)){ |
140 |
/* Hij=Gij*Aij; //TEST |
141 |
|
142 |
cout<<"First rotation"<<endl; |
143 |
cout<<Hij(0,0)<<" "<<Hij(0,1)<<" "<<Hij(0,2)<<endl; |
144 |
cout<<Hij(1,0)<<" "<<Hij(1,1)<<" "<<Hij(1,2)<<endl; |
145 |
cout<<Hij(2,0)<<" "<<Hij(2,1)<<" "<<Hij(2,2)<<endl<<endl; |
146 |
|
147 |
Iij = Fij*(Gij*Aij); //TEST |
148 |
|
149 |
cout<<"Second rotation"<<endl; |
150 |
cout<<Iij(0,0)<<" "<<Iij(0,1)<<" "<<Iij(0,2)<<endl; |
151 |
cout<<Iij(1,0)<<" "<<Iij(1,1)<<" "<<Iij(1,2)<<endl; |
152 |
cout<<Iij(2,0)<<" "<<Iij(2,1)<<" "<<Iij(2,2)<<endl; |
153 |
// |
154 |
Int_t ret; |
155 |
cin>>ret;*/ |
156 |
// } |
157 |
return Fij*(Gij*Aij); |
158 |
} |
159 |
|
160 |
TMatrixD OrientationInfo::PamelatoGEO(TMatrixD Aij, Double_t B1, Double_t B2, Double_t B3){ |
161 |
//TMatrixD Gij(3,3); |
162 |
TMatrixD Hij(3,1); |
163 |
TMatrixD Bij(3,1); |
164 |
Bij(0,0) = B1; |
165 |
Bij(1,0) = B2; |
166 |
Bij(2,0) = B3; |
167 |
//Double_t alfa = TMath::ASin(sqrt(1/((Aij(1,2))/Aij(0,2)+1))) * TMath::RadToDeg(); |
168 |
//Gij(0,0) = cos(alfa/a); |
169 |
//Gij(0,1) = -sin(alfa/a); |
170 |
//Gij(0,2) = 0; |
171 |
//Gij(1,0) = 0; |
172 |
//Gij(1,1) = 1; |
173 |
//Gij(1,2) = 0; |
174 |
//Gij(2,0) = sin(alfa/a); |
175 |
//Gij(2,1) = cos(alfa/a); |
176 |
//Gij(2,2) = 0; |
177 |
|
178 |
Hij=Aij*Bij; |
179 |
return Hij; |
180 |
//cout<<0.25-Aij(2,2)/(Aij(2,1)*Aij(2,0))<<endl; |
181 |
//cout<<Hij(0,0)<<endl;//" "<<Hij(0,1)<<" "<<Hij(0,2)<<endl; |
182 |
//cout<<Hij(1,0)<<endl;//" "<<Hij(1,1)<<" "<<Hij(1,2)<<endl; |
183 |
//cout<<Hij(2,0)<<endl;//" "<<Hij(2,1)<<" "<<Hij(2,2)<<endl; |
184 |
} |
185 |
|
186 |
TMatrixD OrientationInfo::ColPermutation(TMatrixD Aij){ |
187 |
TMatrixD Gij(3,3); |
188 |
Gij(0,0) = 1; Gij(0,1) = 0; Gij(0,2) = 0; |
189 |
Gij(1,0) = 0; Gij(1,1) = 0; Gij(1,2) = 1; |
190 |
Gij(2,0) = 0; Gij(2,1) = -1; Gij(2,2) = 0; |
191 |
return Aij*Gij; |
192 |
} |
193 |
|
194 |
Double_t OrientationInfo::GetPitchAngle(Double_t x1, Double_t y1, Double_t z1, Double_t x2, Double_t y2, Double_t z2){ |
195 |
return TMath::ACos((x1*x2 + y1*y2 + z1*z2)/(sqrt(pow(x1,2)+pow(y1,2)+pow(z1,2))*sqrt(pow(x2,2)+pow(y2,2)+pow(z2,2)))) * TMath::RadToDeg(); |
196 |
} |