| 1 | #include "Slalib.h"
|
|---|
| 2 |
|
|---|
| 3 | #include <time.h>
|
|---|
| 4 | #include <iostream.h> // cout
|
|---|
| 5 |
|
|---|
| 6 | #include "coord.h"
|
|---|
| 7 |
|
|---|
| 8 | #include "slalib.h"
|
|---|
| 9 |
|
|---|
| 10 | ClassImp(Slalib);
|
|---|
| 11 |
|
|---|
| 12 | Slalib::Slalib() : Timer()
|
|---|
| 13 | {
|
|---|
| 14 | // p = pointer to MainFrame (not owner)
|
|---|
| 15 |
|
|---|
| 16 | //
|
|---|
| 17 | // calculate observers location (goe)
|
|---|
| 18 | //
|
|---|
| 19 | int status;
|
|---|
| 20 | slaDaf2r(51, 38, 48.0, &fPhi, &status);
|
|---|
| 21 | slaDaf2r( 9, 56, 36.0, &fElong, &status);
|
|---|
| 22 |
|
|---|
| 23 | cout << "Latitude: 51\x9c 38'48.0\" = " << kRad2Deg*fPhi << " ";
|
|---|
| 24 | cout << "Longitude: 9\x9c 56'36.0\" = " << kRad2Deg*fElong << endl;
|
|---|
| 25 | }
|
|---|
| 26 |
|
|---|
| 27 | Slalib::~Slalib()
|
|---|
| 28 | {
|
|---|
| 29 | }
|
|---|
| 30 |
|
|---|
| 31 | void Slalib::SetMjd(const double mjd)
|
|---|
| 32 | {
|
|---|
| 33 | fMjd = mjd;
|
|---|
| 34 | fAlpha = slaGmst(fMjd) + fElong;
|
|---|
| 35 | }
|
|---|
| 36 |
|
|---|
| 37 | void Slalib::SetMjd2Now()
|
|---|
| 38 | {
|
|---|
| 39 | Now();
|
|---|
| 40 | SetMjd(CalcMjd());
|
|---|
| 41 | // cout << "GetMjd: "<< (*this)() << " " << GetMjd() << endl;
|
|---|
| 42 | }
|
|---|
| 43 |
|
|---|
| 44 | void Slalib::SetMjd(const struct timeval *tm)
|
|---|
| 45 | {
|
|---|
| 46 | SetTimer(tm);
|
|---|
| 47 | SetMjd(CalcMjd());
|
|---|
| 48 | }
|
|---|
| 49 |
|
|---|
| 50 |
|
|---|
| 51 | ZdAz Slalib::XYZ2ZdAz(double coord[3]) const
|
|---|
| 52 | {
|
|---|
| 53 | //
|
|---|
| 54 | // -- xyz to spherical coordinates --
|
|---|
| 55 | //
|
|---|
| 56 | double ra, dec;
|
|---|
| 57 | slaDcc2s(coord, &ra, &dec);
|
|---|
| 58 |
|
|---|
| 59 | //
|
|---|
| 60 | // radec[rad] -> hadec[rad]
|
|---|
| 61 | //
|
|---|
| 62 | const double ha = fAlpha-ra;
|
|---|
| 63 |
|
|---|
| 64 | //
|
|---|
| 65 | // hadec[rad] -> altaz[rad]
|
|---|
| 66 | //
|
|---|
| 67 | double alt, az;
|
|---|
| 68 | slaDe2h(ha, dec, fPhi, &az, &alt);
|
|---|
| 69 |
|
|---|
| 70 | return ZdAz(kPiDiv2-alt, az);
|
|---|
| 71 | } |
|---|