- Timestamp:
- Sep 24, 1999, 9:16:54 AM (26 years ago)
- Location:
- trunk/Poubelle/archTOI.old
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Poubelle/archTOI.old/plgalcross.cc
r423 r427 5 5 #include <math.h> 6 6 7 #ifndef M_PI8 #define M_PI 3.141592653589799 #endif10 11 #ifndef M_2PI12 #define M_2PI (2*M_PI)13 #endif14 15 7 #include "plgalcross.h" 16 8 17 9 ////////////////////////////////////////////////////////////////////////// 18 // Pour calculer les azimuth d'intersection d'une direction avec10 // Pour calculer les azimuth (E of N) d'intersection d'une direction avec 19 11 // le plan galactique: 20 12 // ---- INPUT: … … 30 22 // soit (12h 51mn 30s, +27d 07' 42", 2000) 31 23 // ---- OUTPUT: 32 // azCr1,2 : azimuths d'intersection du plan definit au dessus24 // azCr1,2 : azimuths (E of N) d'intersection du plan definit au dessus 33 25 // avec le cercle balaye par l'axe du detecteur 34 26 // (degres decimaux [0,360[) … … 78 70 // - Equation de la droite d'intersection du plan avec le plan du cercle: 79 71 // a*x + b*y + c*z = 0 avec z=sin(hRot) 80 double R2=cos(hRot); R2*=R2;72 double ch=cos(hRot); 81 73 double z=sin(hRot), chG=cos(hG), shG=sin(hG); 82 if( R2<SMALL_ANGLE_2) {83 // R2=0 : le detecteur ne tourne pas (zRot==0 ou 180),74 if(ch*ch<SMALL_ANGLE_2) { 75 // ch=0 : le detecteur ne tourne pas (zRot==0 ou 180), 84 76 // il est selon l'axe OZ ou -OZ. Une seule solution possible 85 77 // si le plan passe par le pole cad si hG==0 et l'azimuth … … 92 84 if(z*z<SMALL_ANGLE_2) return 3; else return 1; 93 85 } else { 94 double a=chG*cos(aG), b=-chG*sin(aG), cz=shG*z ;86 double a=chG*cos(aG), b=-chG*sin(aG), cz=shG*z, R2=ch*ch; 95 87 //Stabilite numerique: |b|>|a| on resoud pour "x" sinon pour "y" 96 88 // **** cas 1-/ |b|>|a| : droite y = -(a/b)*x-cz/b … … 104 96 // cas 1-/ x1,x2 ==> y = -(a/b)*x-cz/b ==> y1,y2 105 97 // cas 2-/ y1,y2 ==> x = -(b/a)*x-cz/a ==> x1,x2 106 // **** Azimuth: az=atan2(-y,x) (car sens retrograde cf eq OM=|...|) 98 // **** Azimuth: az=atan2(-y/cos(hRot),x/cos(hRot)) 99 // (car sens retrograde cf eq OM=|...|) 107 100 bool calcx = (fabs(b)>fabs(a))? true: false; 108 101 double A,B,C; … … 117 110 else {y1=sol1; y2=sol2; x1=-b/a*y1-cz/a; x2=-b/a*y2-cz/a;} 118 111 // Calcul des azimuths 119 azCr1 = atan2(-y1 ,x1); azCr2 = atan2(-y2,x2);112 azCr1 = atan2(-y1/ch,x1/ch); azCr2 = atan2(-y2/ch,x2/ch); 120 113 // on convertit en degres decimaux 121 114 azCr1 *= DEG_IN_RADIAN; azCr2 *= DEG_IN_RADIAN; … … 140 133 // latitude : latitude du lieu en degre [-90,90] decimaux 141 134 // OUTPUT: les coordonnees horizontales: 142 // azimuth : azimuth degre [0,360[ decimaux 135 // azimuth : azimuth (E of N) degre [0,360[ decimaux 136 // ici compte + dans sens retrograde avec origine au Nord, 137 // azimuth "des marins" (serveur BDL, USNO, xephem , skycalc...) 143 138 // elevation : elevation degre [-90,90] decimaux 144 139 // (distance zenithale z = 90-elevation) 145 140 // RETURN: 0 si Ok, 1 si probleme 146 // TRANSFO: 141 // TRANSFO: (dans cette formule l'origine des azimuths est au Sud, 142 // azimut "des astronomes" ou (E of S)) 147 143 // sin(azi) cos(elev) = sin(ha) cos(dec) 148 144 // cos(azi) cos(elev) = cos(ha) cos(dec) sin(lat) - sin(dec) cos(lat) 149 145 // sin(elev) = cos(ha) cos(dec) cos(lat) + sin(dec) sin(lat) 150 // avec azi=azimuth , elev=elevation, lat=latitude,146 // avec azi=azimuth (E of S), elev=elevation, lat=latitude, 151 147 // dec=declinaison, ha=angle horaire=tsid-alpha 148 // Puis azi(E of S) = azi(E of N) + Pi 152 149 { 153 150 azimuth = elevation = 0.; … … 167 164 elevation = ch*cd*cl+sl*sd; 168 165 if(elevation<-1.) elevation=-1.; if(elevation>1.) elevation=1.; 169 elevation = asin(elevation); //entre [-Pi ,Pi]166 elevation = asin(elevation); //entre [-Pi/2,Pi/2] 170 167 171 168 // calcul de l'azimuth 172 if(fabs(cos(elevation))<SMALL_ANGLE) { //elevation=-Pi/2 ou Pi/2 169 double ce = cos(elevation); 170 if(fabs(ce)<SMALL_ANGLE) { //elevation=-Pi/2 ou Pi/2 173 171 azimuth = 0.; //azimuth indifferent 174 172 } else { 175 azimuth = atan2(sh*cd ,ch*cd*sl-sd*cl); //entre -Pi et +Pi176 if(azimuth<0.) azimuth += M_2PI; //remise azimuth entre 0 et 2Pi173 azimuth = atan2(sh*cd/ce,(ch*cd*sl-sd*cl)/ce); //entre -Pi et +Pi 174 azimuth += M_PI; //azimuth (E of S) -> (E of N) 177 175 } 178 176 … … 217 215 // | vp[2] | | sin(dp) | 218 216 dp = asin(vp[2]); // asin retourne entre -Pi/2 et Pi/2 ... Ok 219 nvp = cos(dp);220 if(fabs( nvp)<1.e-30) { // cas ou dp=+Pi/2 ou -Pi/2, ap est indifferent217 double cdp = cos(dp); 218 if(fabs(cdp)<SMALL_ANGLE) { // cas ou dp=+Pi/2 ou -Pi/2, ap est indifferent 221 219 ap = 0.; 222 220 } else { 223 ap = atan2(vp[1] ,vp[0]); // renvoie entre -Pi et +Pi221 ap = atan2(vp[1]/cdp,vp[0]/cdp); // renvoie entre -Pi et +Pi 224 222 if(ap<0.) ap += M_2PI; 225 223 } -
trunk/Poubelle/archTOI.old/plgalcross.h
r423 r427 8 8 ,double& azCr1,double& azCr2); 9 9 int EquatToHoriz(double alpha,double delta,double TSid,double latitude 10 ,double& azimuth,double& hauteur);10 ,double& azimuth,double& elevation); 11 11 int FindPerpEquat(double a1,double d1,double a2,double d2,double& ap,double& dp);
Note:
See TracChangeset
for help on using the changeset viewer.