Changeset 2280 for trunk/MagicSoft/Cosy/catalog
- Timestamp:
- 07/17/03 00:25:48 (21 years ago)
- Location:
- trunk/MagicSoft/Cosy/catalog
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Cosy/catalog/Slalib.cc
r1758 r2280 16 16 Slalib::~Slalib() 17 17 { 18 } 19 20 Double_t Slalib::Trunc(Double_t val) 21 { 22 /* dint(A) - truncate to nearest whole number towards zero (double) */ 23 return val<0 ? TMath::Ceil(val) : TMath::Floor(val); 24 } 25 26 Double_t Slalib::Round(Double_t val) 27 { 28 /* dnint(A) - round to nearest whole number (double) */ 29 return val<0 ? TMath::Ceil(val-0.5) : TMath::Floor(val+0.5); 18 30 } 19 31 … … 45 57 return ZdAz(kPiDiv2-alt, az); 46 58 } 59 60 Double_t Slalib::Hms2Sec(Int_t deg, UInt_t min, Double_t sec, Char_t sgn) 61 { 62 const Double_t rc = TMath::Sign((60.0 * (60.0 * (Double_t)TMath::Abs(deg) + (Double_t)min) + sec), (Double_t)deg); 63 return sgn=='-' ? -rc : rc; 64 } 65 66 Double_t Slalib::Dms2Rad(Int_t deg, UInt_t min, Double_t sec, Char_t sgn) 67 { 68 /* pi/(180*3600): arcseconds to radians */ 69 #define DAS2R 4.8481368110953599358991410235794797595635330237270e-6 70 return Hms2Sec(deg, min, sec, sgn)*DAS2R; 71 } 72 73 Double_t Slalib::Hms2Rad(Int_t hor, UInt_t min, Double_t sec, Char_t sgn) 74 { 75 /* pi/(12*3600): seconds of time to radians */ 76 #define DS2R 7.2722052166430399038487115353692196393452995355905e-5 77 return Hms2Sec(hor, min, sec, sgn)*DS2R; 78 } 79 80 Double_t Slalib::Dms2Deg(Int_t deg, UInt_t min, Double_t sec, Char_t sgn) 81 { 82 return Hms2Sec(deg, min, sec, sgn)/3600.; 83 } 84 85 Double_t Slalib::Hms2Deg(Int_t hor, UInt_t min, Double_t sec, Char_t sgn) 86 { 87 return Hms2Sec(hor, min, sec, sgn)/240.; 88 } 89 90 Double_t Slalib::Dms2Hor(Int_t deg, UInt_t min, Double_t sec, Char_t sgn) 91 { 92 return Hms2Sec(deg, min, sec, sgn)/15.; 93 } 94 95 Double_t Slalib::Hms2Hor(Int_t hor, UInt_t min, Double_t sec, Char_t sgn) 96 { 97 return Hms2Sec(hor, min, sec, sgn)/3600.; 98 } 99 100 void Slalib::Day2Hms(Double_t day, Char_t &sgn, UShort_t &hor, UShort_t &min, UShort_t &sec) 101 { 102 /* Handle sign */ 103 sgn = day<0?'-':'+'; 104 105 /* Round interval and express in smallest units required */ 106 Double_t a = Round(86400. * TMath::Abs(day)); // Days to seconds 107 108 /* Separate into fields */ 109 const Double_t ah = Trunc(a/3600.); 110 a -= ah * 3600.; 111 const Double_t am = Trunc(a/60.); 112 a -= am * 60.; 113 const Double_t as = Trunc(a); 114 115 /* Return results */ 116 hor = (UShort_t)ah; 117 min = (UShort_t)am; 118 sec = (UShort_t)as; 119 } 120 121 void Slalib::Rad2Hms(Double_t rad, Char_t &sgn, UShort_t °, UShort_t &min, UShort_t &sec) 122 { 123 Day2Hms(rad/(TMath::Pi()*2), sgn, deg, min, sec); 124 } 125 126 void Slalib::Rad2Dms(Double_t rad, Char_t &sgn, UShort_t °, UShort_t &min, UShort_t &sec) 127 { 128 Rad2Hms(rad*15, sgn, deg, min, sec); 129 } 130 131 void Slalib::Deg2Dms(Double_t d, Char_t &sgn, UShort_t °, UShort_t &min, UShort_t &sec) 132 { 133 Day2Hms(d/24, sgn, deg, min, sec); 134 } 135 136 void Slalib::Deg2Hms(Double_t d, Char_t &sgn, UShort_t °, UShort_t &min, UShort_t &sec) 137 { 138 Rad2Hms(d/360, sgn, deg, min, sec); 139 } 140 141 void Slalib::Hor2Dms(Double_t h, Char_t &sgn, UShort_t °, UShort_t &min, UShort_t &sec) 142 { 143 Day2Hms(h*15/24, sgn, deg, min, sec); 144 } 145 146 void Slalib::Hor2Hms(Double_t h, Char_t &sgn, UShort_t °, UShort_t &min, UShort_t &sec) 147 { 148 Day2Hms(h/24, sgn, deg, min, sec); 149 } 150 151 void Slalib::Day2Hm(Double_t day, Char_t &sgn, UShort_t &hor, Double_t &min) 152 { 153 /* Handle sign */ 154 sgn = day<0?'-':'+'; 155 156 /* Round interval and express in smallest units required */ 157 Double_t a = Round(86400. * TMath::Abs(day)); // Days to seconds 158 159 /* Separate into fields */ 160 const Double_t ah = Trunc(a/3600.); 161 a -= ah * 3600.; 162 163 /* Return results */ 164 hor = (UShort_t)ah; 165 min = a/60.; 166 } 167 168 void Slalib::Rad2Hm(Double_t rad, Char_t &sgn, UShort_t °, Double_t &min) 169 { 170 Day2Hm(rad/(TMath::Pi()*2), sgn, deg, min); 171 } 172 173 void Slalib::Rad2Dm(Double_t rad, Char_t &sgn, UShort_t °, Double_t &min) 174 { 175 Rad2Hm(rad*15, sgn, deg, min); 176 } 177 178 void Slalib::Deg2Dm(Double_t d, Char_t &sgn, UShort_t °, Double_t &min) 179 { 180 Day2Hm(d/24, sgn, deg, min); 181 } 182 183 void Slalib::Deg2Hm(Double_t d, Char_t &sgn, UShort_t °, Double_t &min) 184 { 185 Rad2Hm(d/360, sgn, deg, min); 186 } 187 188 void Slalib::Hor2Dm(Double_t h, Char_t &sgn, UShort_t °, Double_t &min) 189 { 190 Day2Hm(h*15/24, sgn, deg, min); 191 } 192 193 void Slalib::Hor2Hm(Double_t h, Char_t &sgn, UShort_t °, Double_t &min) 194 { 195 Day2Hm(h/24, sgn, deg, min); 196 } 197 -
trunk/MagicSoft/Cosy/catalog/Slalib.h
r1784 r2280 13 13 double fAlpha; 14 14 15 static Double_t Round(Double_t val); 16 static Double_t Trunc(Double_t val); 17 15 18 public: 16 19 Slalib(MObservatory::LocationName_t key); 17 20 virtual ~Slalib(); 18 21 19 static Double_t Dms2Rad(Int_t deg, UInt_t min, Double_t sec) 20 { 21 /* pi/(180*3600): arcseconds to radians */ 22 #define DAS2R 4.8481368110953599358991410235794797595635330237270e-6 23 return DAS2R * (60.0 * (60.0 * (Double_t)deg + (Double_t)min) + sec); 24 } 22 static Double_t Hms2Sec(Int_t deg, UInt_t min, Double_t sec, char sgn='+'); 23 static Double_t Dms2Rad(Int_t deg, UInt_t min, Double_t sec, Char_t sgn='+'); 24 static Double_t Hms2Rad(Int_t hor, UInt_t min, Double_t sec, Char_t sgn='+'); 25 static Double_t Dms2Deg(Int_t deg, UInt_t min, Double_t sec, Char_t sgn='+'); 26 static Double_t Hms2Deg(Int_t hor, UInt_t min, Double_t sec, Char_t sgn='+'); 27 static Double_t Dms2Hor(Int_t deg, UInt_t min, Double_t sec, Char_t sgn='+'); 28 static Double_t Hms2Hor(Int_t hor, UInt_t min, Double_t sec, Char_t sgn='+'); 25 29 26 static Double_t Hms2Rad(Int_t hor, UInt_t min, Double_t sec) 27 { 28 /* pi/(12*3600): seconds of time to radians */ 29 #define DS2R 7.2722052166430399038487115353692196393452995355905e-5 30 return DS2R * (60.0 * (60.0 * (Double_t)hor + (Double_t)min) + sec); 31 } 30 static void Day2Hms(Double_t rad, Char_t &sgn, UShort_t °, UShort_t &min, UShort_t &sec); 31 static void Rad2Dms(Double_t rad, Char_t &sgn, UShort_t °, UShort_t &min, UShort_t &sec); 32 static void Rad2Hms(Double_t rad, Char_t &sgn, UShort_t °, UShort_t &min, UShort_t &sec); 33 static void Deg2Dms(Double_t rad, Char_t &sgn, UShort_t °, UShort_t &min, UShort_t &sec); 34 static void Deg2Hms(Double_t rad, Char_t &sgn, UShort_t °, UShort_t &min, UShort_t &sec); 35 static void Hor2Dms(Double_t rad, Char_t &sgn, UShort_t °, UShort_t &min, UShort_t &sec); 36 static void Hor2Hms(Double_t rad, Char_t &sgn, UShort_t °, UShort_t &min, UShort_t &sec); 37 38 static void Day2Hm(Double_t rad, Char_t &sgn, UShort_t °, Double_t &min); 39 static void Rad2Dm(Double_t rad, Char_t &sgn, UShort_t °, Double_t &min); 40 static void Rad2Hm(Double_t rad, Char_t &sgn, UShort_t °, Double_t &min); 41 static void Deg2Dm(Double_t rad, Char_t &sgn, UShort_t °, Double_t &min); 42 static void Deg2Hm(Double_t rad, Char_t &sgn, UShort_t °, Double_t &min); 43 static void Hor2Dm(Double_t rad, Char_t &sgn, UShort_t °, Double_t &min); 44 static void Hor2Hm(Double_t rad, Char_t &sgn, UShort_t °, Double_t &min); 32 45 33 46 virtual void SetMjd(double mjd);
Note:
See TracChangeset
for help on using the changeset viewer.