Changeset 473 in Sophya for trunk/SophyaLib/Samba/localmap.cc
- Timestamp:
- Oct 18, 1999, 4:37:44 PM (26 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaLib/Samba/localmap.cc
r470 r473 89 89 //++ 90 90 template<class T> 91 LocalMap<T>::LocalMap(int _4 nx, int_4ny) : nSzX_(nx), nSzY_(ny)91 LocalMap<T>::LocalMap(int nx, int ny) : nSzX_(nx), nSzY_(ny) 92 92 // 93 93 // Constructeur … … 155 155 //++ 156 156 template<class T> 157 void LocalMap<T>::ReSize(int _4 nx, int_4ny)157 void LocalMap<T>::ReSize(int nx, int ny) 158 158 // 159 159 // Redimensionne l'espace de stokage des pixels … … 175 175 //++ 176 176 template<class T> 177 int _4LocalMap<T>::NbPixels() const177 int LocalMap<T>::NbPixels() const 178 178 // 179 179 // Retourne le nombre de pixels du découpage … … 185 185 //++ 186 186 template<class T> 187 T& LocalMap<T>::PixVal(int _4k)187 T& LocalMap<T>::PixVal(int k) 188 188 // 189 189 // Retourne la valeur du contenu du pixel d'indice k … … 203 203 204 204 template<class T> 205 T const& LocalMap<T>::PixVal(int _4k) const205 T const& LocalMap<T>::PixVal(int k) const 206 206 // 207 207 // Retourne la valeur du contenu du pixel d'indice k … … 220 220 //++ 221 221 template<class T> 222 int _4 LocalMap<T>::PixIndexSph(float theta, floatphi) const222 int LocalMap<T>::PixIndexSph(double theta,double phi) const 223 223 // 224 224 // Retourne l'indice du pixel vers lequel pointe une direction définie par … … 234 234 235 235 // theta et phi en coordonnees relatives (on se ramene a une situation par rapport au plan de reference) 236 float theta_aux=theta;237 float phi_aux=phi;236 double theta_aux= theta; 237 double phi_aux = phi; 238 238 UserToReference(theta_aux, phi_aux); 239 239 240 240 // coordonnees dans le plan local en unites de pixels 241 floatx,y;242 AngleProjToPix(theta_aux, 243 244 floatxmin= -x0_-0.5;245 floatxmax= xmin+nSzX_;246 if((x > 247 floatxcurrent= xmin;241 double x,y; 242 AngleProjToPix(theta_aux,phi_aux, x, y); 243 244 double xmin= -x0_-0.5; 245 double xmax= xmin+nSzX_; 246 if((x > xmax) || (x < xmin)) return(-1); 247 double xcurrent= xmin; 248 248 for(i = 0; i < nSzX_; i++ ) 249 249 { … … 251 251 if( x < xcurrent ) break; 252 252 } 253 floatymin= -y0_-0.5;254 floatymax= ymin+nSzY_;253 double ymin= -y0_-0.5; 254 double ymax= ymin+nSzY_; 255 255 if((y > ymax) || (y < ymin)) return(-1); 256 floatycurrent= ymin;256 double ycurrent= ymin; 257 257 for(j = 0; j < nSzY_; j++ ) 258 258 { … … 265 265 //++ 266 266 template<class T> 267 void LocalMap<T>::PixThetaPhi(int _4 k, float& theta, float& phi) const267 void LocalMap<T>::PixThetaPhi(int k,double& theta,double& phi) const 268 268 // 269 269 // Retourne les coordonnées (theta,phi) du milieu du pixel d'indice k … … 279 279 Getij(k,i,j); 280 280 281 float X= float(i-x0_);282 float Y= float(j-y0_);281 double X= double(i-x0_); 282 double Y= double(j-y0_); 283 283 // situation de ce pixel dans le plan de reference 284 floatx= X*cos_angle_-Y*sin_angle_;285 floaty= X*sin_angle_+Y* cos_angle_;284 double x= X*cos_angle_-Y*sin_angle_; 285 double y= X*sin_angle_+Y* cos_angle_; 286 286 // projection sur la sphere 287 287 PixProjToAngle(x, y, theta, phi); … … 292 292 //++ 293 293 template<class T> 294 r_8 LocalMap<T>::PixSolAngle(int_4k) const294 double LocalMap<T>::PixSolAngle(int k) const 295 295 // 296 296 // Pixel Solid angle (steradians) … … 301 301 int i,j; 302 302 Getij(k,i,j); 303 float X= float(i-x0_); 304 float Y= float(j-y0_); 305 float XR= X+float(i)*0.5; 306 float XL= X-float(i)*0.5; 307 float YU= Y+float(j)*0.5; 308 float YL= Y-float(j)*0.5; 303 double X= double(i-x0_); 304 double Y= double(j-y0_); 305 double XR= X+double(i)*0.5; 306 double XL= X-double(i)*0.5; 307 double YU= Y+double(j)*0.5; 308 double YL= Y-double(j)*0.5; 309 309 310 // situation dans le plan de reference 310 float x0= XL*cos_angle_-YL*sin_angle_; 311 float y0= XL*sin_angle_+YL*cos_angle_; 312 float xa= XR*cos_angle_-YL*sin_angle_; 313 float ya= XR*sin_angle_+YL*cos_angle_; 314 float xb= XL*cos_angle_-YU*sin_angle_; 315 float yb= XL*sin_angle_+YU*cos_angle_; 311 double x0= XL*cos_angle_-YL*sin_angle_; 312 double y0= XL*sin_angle_+YL*cos_angle_; 313 double xa= XR*cos_angle_-YL*sin_angle_; 314 double ya= XR*sin_angle_+YL*cos_angle_; 315 double xb= XL*cos_angle_-YU*sin_angle_; 316 double yb= XL*sin_angle_+YU*cos_angle_; 317 316 318 // projection sur la sphere 317 float tet0,phi0,teta,phia,tetb,phib; 318 PixProjToAngle(x0, y0, tet0, phi0); 319 PixProjToAngle(xa, ya, teta, phia); 320 PixProjToAngle(xb, yb, tetb, phib); 319 double thet0,phi0,theta,phia,thetb,phib; 320 PixProjToAngle(x0, y0, thet0, phi0); 321 PixProjToAngle(xa, ya, theta, phia); 322 PixProjToAngle(xb, yb, thetb, phib); 323 321 324 // angle solide 322 floatsol= fabs((xa-x0)*(yb-y0)-(xb-x0)*(ya-y0));323 return r_8(sol);324 } 325 326 //++ 327 template<class T> 328 void LocalMap<T>::SetOrigin(float theta0, float phi0, floatangle)325 double sol= fabs((xa-x0)*(yb-y0)-(xb-x0)*(ya-y0)); 326 return sol; 327 } 328 329 //++ 330 template<class T> 331 void LocalMap<T>::SetOrigin(double theta0,double phi0,double angle) 329 332 // 330 333 // Fixe la repere de reference ( angles en degres) 331 334 //-- 332 335 { 333 theta0_= (double)theta0;334 phi0_ = (double)phi0;335 angle_ = (double)angle;336 theta0_= theta0; 337 phi0_ = phi0; 338 angle_ = angle; 336 339 x0_= nSzX_/2; 337 340 y0_= nSzY_/2; 338 cos_angle_= cos df(angle);339 sin_angle_= sin df(angle);341 cos_angle_= cos(angle*Pi/180.); 342 sin_angle_= sin(angle*Pi/180.); 340 343 originFlag_= true; 341 344 cout << " LocalMap:: set origin 1 done" << endl; … … 344 347 //++ 345 348 template<class T> 346 void LocalMap<T>::SetOrigin(float theta0, float phi0, int_4 x0, int_4 y0, floatangle)349 void LocalMap<T>::SetOrigin(double theta0,double phi0,int x0,int y0,double angle) 347 350 // 348 351 // Fixe le repere de reference (angles en degres) 349 352 //-- 350 353 { 351 theta0_= (double)theta0;352 phi0_ = (double)phi0;353 angle_ = (double)angle;354 theta0_= theta0; 355 phi0_ = phi0; 356 angle_ = angle; 354 357 x0_= x0; 355 358 y0_= y0; 356 cos_angle_= cos df(angle);357 sin_angle_= sin df(angle);359 cos_angle_= cos(angle*Pi/180.); 360 sin_angle_= sin(angle*Pi/180.); 358 361 originFlag_= true; 359 362 cout << " LocalMap:: set origin 2 done" << endl; … … 362 365 //++ 363 366 template<class T> 364 void LocalMap<T>::SetSize( float angleX, floatangleY)367 void LocalMap<T>::SetSize(double angleX,double angleY) 365 368 // 366 369 // Fixe l'extension de la carte (angles en degres) 367 370 //-- 368 371 { 369 angleX_= (double)angleX; 370 angleY_= (double)angleY; 371 372 //tgAngleX_= T(tan(angleX*Pi/360.)); 373 //tgAngleY_= T(tan(angleY*Pi/360.)); 374 372 angleX_= angleX; 373 angleY_= angleY; 375 374 376 375 // tangente de la moitie de l'ouverture angulaire totale 377 tgAngleX_= tan d(0.5*angleX_);378 tgAngleY_= tan d(0.5*angleY_);376 tgAngleX_= tan(0.5*angleX_*Pi/180.); 377 tgAngleY_= tan(0.5*angleY_*Pi/180.); 379 378 380 379 extensFlag_= true; … … 391 390 for(int m = 0; m < nPix_; m++) 392 391 { 393 floattheta,phi;392 double theta,phi; 394 393 PixThetaPhi(m,theta,phi); 395 394 sphere(theta,phi)= pixels_(m); … … 400 399 //++ 401 400 template<class T> 402 void LocalMap<T>::Getij(int k, int& i,int& j) const401 void LocalMap<T>::Getij(int k,int& i,int& j) const 403 402 // 404 403 //-- … … 411 410 //++ 412 411 template<class T> 413 void LocalMap<T>::ReferenceToUser( float &theta, float &phi) const412 void LocalMap<T>::ReferenceToUser(double& theta,double& phi) const 414 413 // 415 414 // -- 416 415 { 417 if(theta > (r_4)Pi || theta < 0. || phi < 0. || phi >= 2*(r_4)Pi) 418 { 419 //cout << " LocalMap::ReferenceToUser : exceptions a mettre en place" <<endl; 420 // THROW(out_of_range("LocalMap::PIxVal Pixel index out of range")); 416 if(theta > Pi || theta < 0. || phi < 0. || phi >= 2*Pi) 417 { 421 418 throw "LocalMap::ReferenceToUser (theta,phi) out of range"; 422 419 } 423 420 424 //cout << " ReferenceToUser entree, t= " << theta << " phi= " << phi << endl; 425 theta= (r_4)theta0_*Pi/180.+theta-(r_4)Pi*0.5; 421 theta= theta0_*Pi/180.+theta-Pi*0.5; 426 422 if(theta < 0.) 427 423 { 428 424 theta= -theta; 429 phi += (r_4)Pi;425 phi += Pi; 430 426 } 431 427 else 432 428 { 433 if(theta > (r_4)Pi)429 if(theta > Pi) 434 430 { 435 theta= 2.* (r_4)Pi-theta;436 phi += (r_4)Pi;431 theta= 2.*Pi-theta; 432 phi += Pi; 437 433 } 438 434 } 439 435 440 phi= (r_4)phi0_*Pi/180.+phi;441 while(phi >= 2.* (r_4)Pi) phi-=2.*(r_4)Pi;442 443 if(theta > (r_4)Pi || theta < 0. || phi < 0. || phi >= 2*(r_4)Pi)436 phi= phi0_*Pi/180.+phi; 437 while(phi >= 2.*Pi) phi-= 2.*Pi; 438 439 if(theta > Pi || theta < 0. || phi < 0. || phi >= 2*Pi) 444 440 { 445 441 cout << " LocalMap::ReferenceToUser : erreur bizarre dans le transfert a la carte utilisateur " << endl; … … 447 443 exit(0); 448 444 } 449 //cout << " ReferenceToUser sortie, t= " << theta << " phi= " << phi << endl; 450 } 451 452 //++ 453 template<class T> 454 void LocalMap<T>::UserToReference(float &theta, float &phi) const 445 } 446 447 //++ 448 template<class T> 449 void LocalMap<T>::UserToReference(double& theta,double& phi) const 455 450 // 456 451 // -- 457 452 { 458 if(theta > (r_4)Pi || theta < 0. || phi<0. || phi >= 2*(r_4)Pi)459 { 460 cout << " LocalMap::UserToReference : exceptionsa mettre en place" <<endl;461 // 453 if(theta > Pi || theta < 0. || phi < 0. || phi >= 2*Pi) 454 { 455 cout<<" LocalMap::UserToReference: exceptions a mettre en place" <<endl; 456 // THROW(out_of_range("LocalMap::PIxVal Pixel index out of range")); 462 457 throw "LocalMap::UserToReference (theta,phi) out of range"; 463 458 } 464 459 465 float phi1=phi-(r_4)phi0_*Pi/180.;466 if(phi1 < 0.) phi1+= 2.*(r_4)Pi;467 468 float theta1= theta-(r_4)theta0_*Pi/180.+(r_4)Pi*0.5;460 double phi1= phi-phi0_*Pi/180.; 461 if(phi1 < 0.) phi1+= 2.*Pi; 462 463 double theta1= theta-theta0_*Pi/180.+Pi*0.5; 469 464 if(theta1 < 0.) 470 465 { 471 466 theta= -theta1; 472 phi1+= (r_4)Pi;467 phi1+= Pi; 473 468 } 474 469 else 475 470 { 476 if(theta1 > (r_4)Pi)471 if(theta1 > Pi) 477 472 { 478 theta= 2.* (r_4)Pi-theta1;479 phi1+= (r_4)Pi;473 theta= 2.*Pi-theta1; 474 phi1+= Pi; 480 475 } 481 476 } 482 477 483 while(phi1 >= 2.* (r_4)Pi) phi1-=2.*(r_4)Pi;478 while(phi1 >= 2.*Pi) phi1-= 2.*Pi; 484 479 phi= phi1; 485 if(theta > (r_4)Pi || theta < 0. || phi < 0. || phi >= 2*(r_4)Pi)480 if(theta > Pi || theta < 0. || phi < 0. || phi >= 2*Pi) 486 481 { 487 482 cout << " LocalMap::UserToReference : erreur bizarre dans le transfert a la carte de reference " << endl; … … 493 488 //++ 494 489 template<class T> 495 void LocalMap<T>::PixProjToAngle( float x, float y, float& theta, float& phi) const496 // 497 // (x,y) representent les coordonnees en unites de pixels d'un point DANS 490 void LocalMap<T>::PixProjToAngle(double x,double y,double& theta,double& phi) const 491 // 492 // (x,y) representent les coordonnees en unites de pixels d'un point DANS LE PLAN DE REFERENCE. 498 493 // On recupere (theta,phi) par rapport au repere "absolu" theta=pi/2 et phi=0. 499 494 //-- 500 495 { 501 theta= (r_4)Pi*0.5-atan(2*y*tgAngleY_/(float)nSzY_);502 phi= atan2(2 *x*tgAngleX_,(float)nSzX_);496 theta= Pi*0.5-atan(2.*y*tgAngleY_/(double)nSzY_); 497 phi= atan2(2.*x*tgAngleX_,(double)nSzX_); 503 498 if(phi < 0.) phi += DeuxPi; 504 499 } … … 506 501 //++ 507 502 template<class T> 508 void LocalMap<T>::AngleProjToPix( float theta, float phi, float& x, float& y) const503 void LocalMap<T>::AngleProjToPix(double theta,double phi,double& x,double& y) const 509 504 // 510 505 // (theta,phi) par rapport au repere "absolu" theta=pi/2,phi=0. On recupere … … 512 507 //-- 513 508 { 514 if(phi >= (r_4)Pi) phi-= DeuxPi;509 if(phi >= Pi) phi-= DeuxPi; 515 510 // y=0.5*mSzY_*cot(theta)/tgAngleY_; $CHECK-REZA-04/99$ 516 511 y= 0.5*nSzY_/tan(theta)/tgAngleY_; // ? cot = 1/tan ? … … 606 601 } 607 602 608 int _4nSzX;603 int nSzX; 609 604 is.GetI4(nSzX); 610 605 dobj->setSize_x(nSzX); 611 606 612 int _4nSzY;607 int nSzY; 613 608 is.GetI4(nSzY); 614 609 dobj->setSize_y(nSzY); 615 610 616 int _4nPix;611 int nPix; 617 612 is.GetI4(nPix); 618 613 dobj->setNbPixels(nPix); … … 624 619 { 625 620 cout<<" ReadSelf:: local mapping"<<endl; 626 int _4x0, y0;627 floattheta, phi, angle;621 int x0, y0; 622 double theta, phi, angle; 628 623 is.GetI4(x0); 629 624 is.GetI4(y0); 630 is.GetR 4(theta);631 is.GetR 4(phi);632 is.GetR 4(angle);625 is.GetR8(theta); 626 is.GetR8(phi); 627 is.GetR8(angle); 633 628 dobj->SetOrigin(theta, phi, x0, y0, angle); 634 629 635 floatangleX, angleY;636 is.GetR 4(angleX);637 is.GetR 4(angleY);630 double angleX, angleY; 631 is.GetR8(angleX); 632 is.GetR8(angleY); 638 633 dobj->SetSize(angleX, angleY); 639 634 } … … 657 652 658 653 char strg[256]; 659 int _4nSzX= dobj->Size_x();660 int _4nSzY= dobj->Size_y();661 int _4nPix= dobj->NbPixels();654 int nSzX= dobj->Size_x(); 655 int nSzY= dobj->Size_y(); 656 int nPix= dobj->NbPixels(); 662 657 663 658 if(dobj->ptrInfo()) … … 681 676 string ss("local mapping is done"); 682 677 os.PutStr(ss); 683 int _4x0, y0;684 floattheta, phi, angle;678 int x0, y0; 679 double theta, phi, angle; 685 680 dobj->Origin(theta, phi, x0, y0, angle); 686 681 os.PutI4(x0); 687 682 os.PutI4(y0); 688 os.PutR 4(theta);689 os.PutR 4(phi);690 os.PutR 4(angle);691 692 floatangleX, angleY;683 os.PutR8(theta); 684 os.PutR8(phi); 685 os.PutR8(angle); 686 687 double angleX, angleY; 693 688 dobj->Aperture(angleX, angleY); 694 os.PutR 4(angleX);695 os.PutR 4(angleY);689 os.PutR8(angleX); 690 os.PutR8(angleY); 696 691 } 697 692 else
Note:
See TracChangeset
for help on using the changeset viewer.