| 
            Last change
 on this file since 2033 was             764, checked in by ansari, 26 years ago           | 
        
        
          | 
             
Reorganisation - Creation du module SkyMap (Loacl/Spherical maps ...) - Reza 2/3/2000 
 
           | 
        
        
          | 
            File size:
            1.6 KB
           | 
        
      
      
| Line |   | 
|---|
| 1 | #include "longlat.h"
 | 
|---|
| 2 | //++ 
 | 
|---|
| 3 | // Class        LongLat
 | 
|---|
| 4 | //
 | 
|---|
| 5 | // include      longlat.h
 | 
|---|
| 6 | //
 | 
|---|
| 7 | //    translation from  coordinates (longitude, latitude) 
 | 
|---|
| 8 | //    to theta,phi
 | 
|---|
| 9 | //
 | 
|---|
| 10 | //    longitude=phi
 | 
|---|
| 11 | //
 | 
|---|
| 12 | //    latitude=Pi/2-theta
 | 
|---|
| 13 | //
 | 
|---|
| 14 | //--
 | 
|---|
| 15 | //++
 | 
|---|
| 16 | // Titre        Constructors
 | 
|---|
| 17 | //--
 | 
|---|
| 18 | //++
 | 
|---|
| 19 | LongLat::LongLat()
 | 
|---|
| 20 | //
 | 
|---|
| 21 | //--
 | 
|---|
| 22 | {
 | 
|---|
| 23 |   _lon=0.;
 | 
|---|
| 24 |   _lat=0.;
 | 
|---|
| 25 | }
 | 
|---|
| 26 | //++
 | 
|---|
| 27 | LongLat::LongLat(double longitude, double latitude)
 | 
|---|
| 28 | //
 | 
|---|
| 29 | //--
 | 
|---|
| 30 | {
 | 
|---|
| 31 |   _lon=mod(longitude,pi2);
 | 
|---|
| 32 |   if( latitude == pi_over_2 ) _lat=latitude;
 | 
|---|
| 33 |   else _lat=mod(latitude+pi_over_2,M_PI)-pi_over_2; // dans [-Pi/2,Pi/2]
 | 
|---|
| 34 | }
 | 
|---|
| 35 | //++
 | 
|---|
| 36 | LongLat::LongLat(double x, double y, double z)
 | 
|---|
| 37 | //
 | 
|---|
| 38 | //--
 | 
|---|
| 39 | {
 | 
|---|
| 40 |   double norm=sqrt(x*x+y*y+z*z);
 | 
|---|
| 41 |   double theta;
 | 
|---|
| 42 |   if( norm != 0. ) 
 | 
|---|
| 43 |     {
 | 
|---|
| 44 |       theta=acos(z/norm); // dans [0,Pi]
 | 
|---|
| 45 |       if( mod(theta,M_PI) == 0. ) _lon=0.; // on est sur +-Oz, le vecteur z est en phi=0
 | 
|---|
| 46 |       //      else _lon=acos(x/sin(theta)/norm)+M_PI*(y<0);
 | 
|---|
| 47 |       else _lon=scangle(y/sin(theta)/norm,x/sin(theta)/norm);
 | 
|---|
| 48 |     }
 | 
|---|
| 49 |   else // vecteur nul
 | 
|---|
| 50 |     {
 | 
|---|
| 51 |       theta=0.;
 | 
|---|
| 52 |       _lon=0.;
 | 
|---|
| 53 |     }
 | 
|---|
| 54 |   _lat=pi_over_2-theta;
 | 
|---|
| 55 | }
 | 
|---|
| 56 | //++
 | 
|---|
| 57 | // Titre        Public Methods
 | 
|---|
| 58 | //--
 | 
|---|
| 59 | //++
 | 
|---|
| 60 | void LongLat::Set(double longitude, double latitude)
 | 
|---|
| 61 | //
 | 
|---|
| 62 | //--
 | 
|---|
| 63 | {
 | 
|---|
| 64 |   _lon=mod(longitude,pi2);
 | 
|---|
| 65 |   if( latitude == pi_over_2 ) _lat=latitude;
 | 
|---|
| 66 |   else _lat=mod(latitude+pi_over_2,M_PI)-pi_over_2; // dans [-Pi/2,Pi/2]
 | 
|---|
| 67 | }
 | 
|---|
| 68 | //++
 | 
|---|
| 69 | void LongLat::Print(ostream& os) const
 | 
|---|
| 70 | //
 | 
|---|
| 71 | //--
 | 
|---|
| 72 | {
 | 
|---|
| 73 |   os << "LongLat : longitude = " << _lon << " phi   = " << this->Phi() << endl;
 | 
|---|
| 74 |   os << "LongLat : latitude    = " << _lat << " theta = " << this->Theta() << endl;
 | 
|---|
| 75 | }
 | 
|---|
| 76 | //++
 | 
|---|
| 77 | //
 | 
|---|
| 78 | //  double Longitude() const 
 | 
|---|
| 79 | //  double Phi() const 
 | 
|---|
| 80 | //  double Latitude() 
 | 
|---|
| 81 | //  double Theta() const 
 | 
|---|
| 82 | //--
 | 
|---|
       
      
  Note:
 See   
TracBrowser
 for help on using the repository browser.