--- DarthVader/OrbitalInfo/src/OrientationInfo.cpp 2008/10/01 15:26:35 1.1 +++ DarthVader/OrbitalInfo/src/OrientationInfo.cpp 2011/11/15 09:31:28 1.2 @@ -34,37 +34,20 @@ } TMatrixD OrientationInfo::ECItoGreenwich(TMatrixD Aij, UInt_t t){ - //t=1154304000+86400*365; TMatrixD Gij(3,3); - Double_t omg = (7.292115e-5)*a; // Earth rotation velosity (Around polar axis); - //Double_t t1 = 0; - //if(t<=1158883200) t1 = 1127347200+229.2732; //absTime at 22/09/2005 + diference between Solar midnight and Greenwich sidereal midnight - //if(t>1158883200&&t<=1190419200) t1 = 1158883200+172.3415;//absTime at 22/09/2006 + diference between Solar midnight and Greenwich sidereal midnight - //if(t>=1190419200&&t<1222041600) t1 = 1190419200+115.39; //absTime at 22/09/2007 + diference between Solar midnight and Greenwich sidereal midnight - //if(t>=1222041600) t1 = 1222041600 + 294.9361; //absTime at 22/09/2008 + diference between Solar midnight and Greenwich sidereal midnight - //UInt_t Nd = (t-t1)/86400; - //Int_t DifSuSt = Nd*236.55; + Double_t omg = (7.292115e-5)*a; // Earth rotation velosity (Around polar axis); Double_t d = (t-10957*86400-43200); //Number of day, passing from 01/01/2000 12:00:00 to t; d = d/86400; - //d = t-da*86400+DifSuSt - //cout<<"t = "<-0.1)){ - //cout<<"lon = "<0&&x0<0) Sa=-Sa+90; - //if (y0<0&&x0<0) Sa=Sa-90; - //if (y0>0&&x0==0) Sa=90; - //if (y0<0&&x0==0) Sa=-90; - Gij(0,0) = cos(lon); + lon=(-lon)/a; lat=(-lat)/a; // here has the same result as Gij.Invert() in ECItoGreenwich function + + Gij(0,0) = cos(lon); // rotation around z-axis: Gij(0,1) = -sin(lon); - Gij(0,2) = 0; - Gij(1,0) = sin(lon); - Gij(1,1) = cos(lon); + Gij(0,2) = 0; // | cos(lon) -sin(lon) 0| + Gij(1,0) = sin(lon); // | sin(lon) cos(lon) 0| + Gij(1,1) = cos(lon); // | 0 0 1| Gij(1,2) = 0; Gij(2,0) = 0; Gij(2,1) = 0; Gij(2,2) = 1; - - //cout<<"First rotation"< | 0 1 0 | + Fij(1,1) = 1; // |-sin(-lat) 0 cos(-lat)| |sin(lat) 0 cos(lat) | Fij(1,2) = 0; Fij(2,0) = sin(lat); Fij(2,1) = 0; Fij(2,2) = cos(lat); - - //Fij.Invert(); - - //if((lat<0.1)&&(lat>-0.1)){ - /* Hij=Gij*Aij; //TEST - - cout<<"First rotation"<>ret;*/ -// } + return Fij*(Gij*Aij); } +TMatrixD OrientationInfo::GEOtoGeomag(TMatrixD Aij,Double_t Bnorth, Double_t Beast, Double_t Bup){ //Geomagnetic geodetic reference frame + Double_t alpha = 0; + if(Beast==0. && Bnorth>0) alpha = 0; else + if(Beast==0. && Bnorth<0) alpha = 180.; else{ + if(Beast > 0) alpha = TMath::ATan(Bnorth/Beast)*TMath::RadToDeg() - 90.; + if(Beast < 0) alpha = TMath::ATan(Bnorth/Beast)*TMath::RadToDeg() + 90.; + } + alpha = alpha*TMath::DegToRad(); + Double_t beta = TMath::ATan(Bup/sqrt(pow(Bnorth,2)+pow(Beast,2))); + //if(Bup<0.0) beta = TMath::ATan(TMath::Abs(Bup/sqrt(pow(Bnorth,2)+pow(Beast,2)))); + //if(Bup>0.0) beta = TMath::ATan(TMath::Abs(sqrt(pow(Bnorth,2)+pow(Beast,2))/Bup)); + //cout<<"GEOtomag:alpha = "<> tri; + return Fij*(Gij*Aij); +} + TMatrixD OrientationInfo::PamelatoGEO(TMatrixD Aij, Double_t B1, Double_t B2, Double_t B3){ //TMatrixD Gij(3,3); TMatrixD Hij(3,1); @@ -164,23 +137,8 @@ Bij(0,0) = B1; Bij(1,0) = B2; Bij(2,0) = B3; - //Double_t alfa = TMath::ASin(sqrt(1/((Aij(1,2))/Aij(0,2)+1))) * TMath::RadToDeg(); - //Gij(0,0) = cos(alfa/a); - //Gij(0,1) = -sin(alfa/a); - //Gij(0,2) = 0; - //Gij(1,0) = 0; - //Gij(1,1) = 1; - //Gij(1,2) = 0; - //Gij(2,0) = sin(alfa/a); - //Gij(2,1) = cos(alfa/a); - //Gij(2,2) = 0; - Hij=Aij*Bij; return Hij; - //cout<<0.25-Aij(2,2)/(Aij(2,1)*Aij(2,0))<0){ + GirDir(0,0) = Py; + GirDir(1,0) = -Px; + }else{ + GirDir(0,0) = -Py; + GirDir(1,0) = Px; + } + GirDir(2,0) = 0.; + return GirDir; +} + Double_t OrientationInfo::GetPitchAngle(Double_t x1, Double_t y1, Double_t z1, Double_t x2, Double_t y2, Double_t z2){ 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(); }