source: trunk/MagicSoft/Cosy/catalog/Slalib.cc@ 9418

Last change on this file since 9418 was 8847, checked in by tbretz, 17 years ago
*** empty log message ***
File size: 1.1 KB
Line 
1#include "Slalib.h"
2
3#include <time.h>
4#include <iostream> // cout
5
6#include "MPointing.h"
7
8#include "slalib.h"
9
10ClassImp(Slalib);
11
12using namespace std;
13
14Slalib::Slalib(MObservatory::LocationName_t key) : MObservatory(key)
15{
16}
17
18Double_t Slalib::Trunc(Double_t val)
19{
20 /* dint(A) - truncate to nearest whole number towards zero (double) */
21 return val<0 ? TMath::Ceil(val) : TMath::Floor(val);
22}
23
24Double_t Slalib::Round(Double_t val)
25{
26 /* dnint(A) - round to nearest whole number (double) */
27 return val<0 ? TMath::Ceil(val-0.5) : TMath::Floor(val+0.5);
28}
29
30void Slalib::SetMjd(double mjd)
31{
32 fTime.SetMjd(mjd);
33
34 fAlpha = slaGmst(GetMjd()) + GetElong();
35}
36
37void Slalib::Now(double offset)
38{
39 fTime.Now();
40 SetMjd(fTime.GetMjd()+offset/(24*60*60));
41}
42
43
44ZdAz Slalib::XYZ2ZdAz(double coord[3]) const
45{
46 //
47 // -- xyz to spherical coordinates --
48 //
49 double ra, dec;
50 slaDcc2s(coord, &ra, &dec);
51
52 //
53 // radec[rad] -> hadec[rad]
54 //
55 const double ha = fAlpha-ra;
56
57 //
58 // hadec[rad] -> altaz[rad]
59 //
60 double alt, az;
61 slaDe2h(ha, dec, GetPhi(), &az, &alt);
62
63 return ZdAz(TMath::Pi()/2-alt, az);
64}
Note: See TracBrowser for help on using the repository browser.