Changeset 1217 in Sophya for trunk/SophyaLib/SkyMap/localmap.cc
- Timestamp:
- Oct 3, 2000, 10:19:18 AM (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaLib/SkyMap/localmap.cc
r979 r1217 9 9 10 10 11 //***************************************************************************** 12 //++ 13 // Class LocalMap 14 // 15 // include localmap.h 16 // 17 // A local map of a region of the sky, in cartesian coordinates. 18 // It has an origin in (theta0, phi0), mapped to pixel(x0, y0) 19 // (x0, y0 might be outside of this local map) 20 // default value of (x0, y0) is middle of the map, center of 21 // pixel(nx/2, ny/2) 22 // 23 // A local map is a 2 dimensional array, with i as column index and j 24 // as row index. The map is supposed to lie on a plan tangent to the 25 // celestial sphere in a point whose coordinates are (x0,y0) on the local 26 // map and (theta0, phi0) on the sphere. The range of the map is defined 27 // by two values of angles covered respectively by all the pixels in 28 // x direction and all the pixels in y direction (SetSize()). 29 // 30 // A "reference plane" is considered : this plane is tangent to the 31 // celestial sphere in a point with angles theta=Pi/2 and phi=0. This 32 // point is the origine of coordinates is of the reference plane. The 33 // x-axis is the tangent parallel to the equatorial line and oriented 34 // toward the increasing phi's ; the y-axis is parallel to the meridian 35 // line and oriented toward the north pole. 36 // 37 // Internally, a map is first defined within this reference plane and 38 // tranported until the point (theta0, phi0) in such a way that both 39 // axes are kept parallel to meridian and parallel lines of the sphere. 40 // The user can define its own map with axes rotated with respect to 41 // reference axes (this rotation is characterized by angle between 42 // the local parallel line and the wanted x-axis-- see method 43 // SetOrigin(...)) 44 // 45 // 46 47 // 48 //-- 49 //++ 50 // 51 // Links Parents 52 // 53 // PixelMap 54 // 55 //-- 56 //++ 57 // 58 // Links Childs 59 // 60 // 61 //-- 62 //++ 63 // Titre Constructors 64 //-- 65 //++ 11 /*! 12 \class SOPHYA::LocalMap 13 14 A local map has an origin in (theta0, phi0), mapped to pixel(x0, y0) 15 (x0, y0 might be outside of this local map) 16 default value of (x0, y0) is middle of the map, center of pixel(nx/2, ny/2) 17 A local map is a 2 dimensional array, with i as column index and j 18 as row index. The map is supposed to lie on a plan tangent to the 19 celestial sphere in a point whose coordinates are (x0,y0) on the local 20 map and (theta0, phi0) on the sphere. The range of the map is defined 21 by two values of angles covered respectively by all the pixels in 22 x direction and all the pixels in y direction (SetSize()). 23 24 A "reference plane" is considered : this plane is tangent to the 25 celestial sphere in a point with angles theta=Pi/2 and phi=0. This 26 point is the origine of coordinates is of the reference plane. The 27 x-axis is the tangent parallel to the equatorial line and oriented 28 toward the increasing phi's ; the y-axis is parallel to the meridian 29 line and oriented toward the north pole. 30 31 Internally, a map is first defined within this reference plane and 32 tranported until the point (theta0, phi0) in such a way that both 33 axes are kept parallel to meridian and parallel lines of the sphere. 34 The user can define its own map with axes rotated with respect to 35 reference axes (this rotation is characterized by angle between 36 the local parallel line and the wanted x-axis-- see method 37 SetOrigin(...)) 38 */ 66 39 template<class T> 67 40 LocalMap<T>::LocalMap() : pixels_() 68 //69 //70 //--71 41 { 72 42 InitNul(); 73 // pixels_.Reset(); 74 } 75 76 //++ 43 } 44 77 45 template<class T> 78 46 LocalMap<T>::LocalMap(int_4 nx, int_4 ny) : nSzX_(nx), nSzY_(ny) 79 //80 //81 //--82 47 { 83 48 InitNul(); … … 87 52 } 88 53 89 //++90 54 template<class T> 91 55 LocalMap<T>::LocalMap(const LocalMap<T>& lm, bool share) 92 56 : pixels_(lm.pixels_, share) 93 94 //95 // copy constructor96 //--97 57 { 98 58 … … 101 61 } 102 62 103 //++104 63 template<class T> 105 64 LocalMap<T>::LocalMap(const LocalMap<T>& lm) 106 65 : pixels_(lm.pixels_) 107 66 108 //109 // copy constructor110 //--111 67 { 112 68 … … 115 71 } 116 72 117 //++118 // Titre Destructor119 //--120 //++121 73 template<class T> 122 74 LocalMap<T>::~LocalMap() 123 //124 //--125 75 { 126 76 InitNul(); … … 129 79 130 80 131 //++ 132 // Titre Public Methods 133 //-- 134 135 //++ 81 /*! \fn void SOPHYA::LocalMap::ReSize(int_4 nx, int_4 ny) 82 83 Resize storage area for pixels 84 */ 136 85 template<class T> 137 86 void LocalMap<T>::ReSize(int_4 nx, int_4 ny) 138 //139 // Resize storage area for pixels140 //--141 87 { 142 88 InitNul(); … … 188 134 189 135 190 //++ 136 /*! \fn int_4 SOPHYA::LocalMap::NbPixels() const 137 138 \return number of pixels 139 */ 191 140 template<class T> 192 141 int_4 LocalMap<T>::NbPixels() const 193 //194 // Return number of pixels195 //--196 142 { 197 143 return(nPix_); 198 144 } 199 145 200 //++ 146 /*! \fn T& SOPHYA::LocalMap::PixVal(int_4 k) 147 148 \return value of pixel with index k 149 */ 201 150 template<class T> 202 151 T& LocalMap<T>::PixVal(int_4 k) 203 //204 // Return value of pixel with index k205 //--206 152 { 207 153 if((k < 0) || (k >= nPix_)) 208 154 { 209 155 cout << " LocalMap::PIxVal : exceptions a mettre en place" <<endl; 210 // THROW(out_of_range("LocalMap::PIxVal Pixel index out of range"));211 156 THROW(rangeCheckErr); 212 //throw "LocalMap::PIxVal Pixel index out of range";213 157 } 214 158 return(pixels_(k)); 215 159 } 216 160 217 //++ 218 161 /*! \fn T const& SOPHYA::LocalMap::PixVal(int_4 k) const 162 const version of previous method 163 */ 219 164 template<class T> 220 165 T const& LocalMap<T>::PixVal(int_4 k) const 221 //222 // const version of previous method223 //--224 166 { 225 167 if((k < 0) || (k >= nPix_)) 226 168 { 227 169 cout << " LocalMap::PIxVal : exceptions a mettre en place" <<endl; 228 // THROW(out_of_range("LocalMap::PIxVal Pixel index out of range"));229 230 170 throw "LocalMap::PIxVal Pixel index out of range"; 231 171 } … … 233 173 } 234 174 175 /*! \fn bool SOPHYA::LocalMap::ContainsSph(double theta, double phi) const 176 177 \return true if teta,phi in map 178 */ 235 179 template<class T> 236 180 bool LocalMap<T>::ContainsSph(double theta, double phi) const … … 240 184 } 241 185 242 //++ 186 /*! \fn int_4 SOPHYA::LocalMap::PixIndexSph(double theta,double phi) const 187 188 \return index of the pixel with spherical coordinates (theta,phi) 189 */ 243 190 template<class T> 244 191 int_4 LocalMap<T>::PixIndexSph(double theta,double phi) const 245 //246 // Return index of the pixel with spherical coordinates (theta,phi)247 //--248 192 { 249 193 int_4 i,j; … … 284 228 } 285 229 286 //++ 230 /*! \fn void SOPHYA::LocalMap::PixThetaPhi(int_4 k,double& theta,double& phi) const 231 232 \return (theta, phi) coordinates of pixel with index k 233 */ 287 234 template<class T> 288 235 void LocalMap<T>::PixThetaPhi(int_4 k,double& theta,double& phi) const 289 //290 // Return (theta, phi) coordinates of pixel with index k291 //--292 236 { 293 237 if(!(originFlag_) || !(extensFlag_)) … … 311 255 } 312 256 257 /*! \fn T SOPHYA::LocalMap::SetPixels(T v) 258 259 Set all pixels to value v 260 */ 313 261 template <class T> 314 262 T LocalMap<T>::SetPixels(T v) … … 318 266 } 319 267 320 //++ 268 /*! \fn double SOPHYA::LocalMap::PixSolAngle(int_4 k) const 269 270 Pixel Solid angle (steradians) 271 272 All the pixels have not necessarly the same size in (theta, phi) 273 because of the projection scheme which is not yet fixed. 274 */ 321 275 template<class T> 322 276 double LocalMap<T>::PixSolAngle(int_4 k) const 323 //324 // Pixel Solid angle (steradians)325 // All the pixels have not necessarly the same size in (theta, phi)326 // because of the projection scheme which is not yet fixed.327 //--328 277 { 329 278 int_4 i,j; … … 355 304 } 356 305 357 //++ 306 /*! \fn void SOPHYA::LocalMap::SetOrigin(double theta0,double phi0,double angle) 307 308 set the referential of the map (angles in degrees) 309 310 (default x0=siz_x/2, y0=siz_y/2) 311 */ 358 312 template<class T> 359 313 void LocalMap<T>::SetOrigin(double theta0,double phi0,double angle) 360 //361 // set the referential of the map (angles in degrees)362 // (default x0=siz_x/2, y0=siz_y/2)363 //--364 314 { 365 315 theta0_= theta0; … … 374 324 } 375 325 376 //++ 326 /*! \fn void SOPHYA::LocalMap::SetOrigin(double theta0,double phi0,int_4 x0,int_4 y0,double angle) 327 328 set the referential of the map (angles in degrees) 329 */ 377 330 template<class T> 378 331 void LocalMap<T>::SetOrigin(double theta0,double phi0,int_4 x0,int_4 y0,double angle) 379 //380 // set the referential of the map (angles in degrees)381 //--382 332 { 383 333 theta0_= theta0; … … 392 342 } 393 343 394 //++ 344 /*! \fn void SOPHYA::LocalMap::SetSize(double angleX,double angleY) 345 346 angle range of tthe map (angles in degrees) 347 */ 395 348 template<class T> 396 349 void LocalMap<T>::SetSize(double angleX,double angleY) 397 //398 // angle range of tthe map (angles in degrees)399 //--400 350 { 401 351 angleX_= angleX; … … 410 360 } 411 361 412 //++ 362 /*! \fn void SOPHYA::LocalMap::Project(SphericalMap<T>& sphere) const 363 364 Projection to a spherical map 365 */ 413 366 template<class T> 414 367 void LocalMap<T>::Project(SphericalMap<T>& sphere) const 415 //416 // Projection to a spherical map417 //--418 368 { 419 369 for(int m = 0; m < nPix_; m++) … … 440 390 } 441 391 442 //++ 392 393 /*! \fn void SOPHYA::LocalMap::Getij(int_4 k,int_4& i,int_4& j) const 394 395 \return 2 indices corresponding to the pixel number k 396 */ 443 397 template<class T> 444 398 void LocalMap<T>::Getij(int_4 k,int_4& i,int_4& j) const 445 //446 // Return 2 indices corresponding to the pixel number k447 //--448 399 { 449 400 i= (k+1)%nSzX_-1; … … 452 403 } 453 404 454 //++ 405 /*! \fn void SOPHYA::LocalMap::ReferenceToUser(double& theta,double& phi) const 406 407 Transform a pair of coordinates (theta, phi) given in 408 reference coordinates into map coordinates 409 */ 455 410 template<class T> 456 411 void LocalMap<T>::ReferenceToUser(double& theta,double& phi) const 457 //458 // Transform a pair of coordinates (theta, phi) given in459 // reference coordinates into map coordinates460 //--461 412 { 462 413 if(theta > Pi || theta < 0. || phi < 0. || phi >= 2*Pi) … … 491 442 } 492 443 493 //++ 444 /*! \fn void SOPHYA::LocalMap::UserToReference(double& theta,double& phi) const 445 446 Transform a pair of coordinates (theta, phi) given in 447 map coordinates into reference coordinates 448 */ 494 449 template<class T> 495 450 void LocalMap<T>::UserToReference(double& theta,double& phi) const 496 //497 // Transform a pair of coordinates (theta, phi) given in498 // map coordinates into reference coordinates499 //--500 451 { 501 452 if(theta > Pi || theta < 0. || phi < 0. || phi >= 2*Pi) … … 534 485 } 535 486 536 //++ 487 /*! \fn void SOPHYA::LocalMap::PixProjToAngle(double x,double y,double& theta,double& phi) const 488 489 Given coordinates in pixel units in the REFERENCE PLANE, return 490 (theta, phi) in "absolute" referential theta=pi/2 ,phi=0. 491 */ 537 492 template<class T> 538 493 void LocalMap<T>::PixProjToAngle(double x,double y,double& theta,double& phi) const 539 //540 //541 // Given coordinates in pixel units in the REFERENCE PLANE, return542 // (theta, phi) in "absolute" referential theta=pi/2 ,phi=0.543 //--544 494 { 545 495 theta= Pi*0.5-atan(2.*y*tgAngleY_/(double)nSzY_); … … 548 498 } 549 499 550 //++ 500 /*! \fn void SOPHYA::LocalMap::AngleProjToPix(double theta,double phi,double& x,double& y) const 501 502 Given coordinates (theta, phi) in "absolute" referential 503 theta=pi/2 ,phi=0 return pixel indices (i,j) in the REFERENCE PLANE. 504 */ 551 505 template<class T> 552 506 void LocalMap<T>::AngleProjToPix(double theta,double phi,double& x,double& y) const 553 //554 // Given coordinates (theta, phi) in "absolute" referential555 // theta=pi/2 ,phi=0 return pixel indices (i,j) in the REFERENCE PLANE.556 //--557 507 { 558 508 if(phi >= Pi) phi-= DeuxPi;
Note:
See TracChangeset
for help on using the changeset viewer.