source: trunk/Mars/mastro/MAstroSky2Local.cc@ 10113

Last change on this file since 10113 was 8765, checked in by tbretz, 17 years ago
*** empty log message ***
File size: 4.4 KB
Line 
1/* ======================================================================== *\
2!
3! *
4! * This file is part of MARS, the MAGIC Analysis and Reconstruction
5! * Software. It is distributed to you in the hope that it can be a useful
6! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
7! * It is distributed WITHOUT ANY WARRANTY.
8! *
9! * Permission to use, copy, modify and distribute this software and its
10! * documentation for any purpose is hereby granted without fee,
11! * provided that the above copyright notice appear in all copies and
12! * that both that copyright notice and this permission notice appear
13! * in supporting documentation. It is provided "as is" without express
14! * or implied warranty.
15! *
16!
17!
18! Author(s): Thomas Bretz, 11/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
19!
20! Copyright: MAGIC Software Development, 2000-2004
21!
22!
23\* ======================================================================== */
24
25/////////////////////////////////////////////////////////////////////////////
26//
27// MAstroSky2Local
28// ---------------
29//
30// Rotation Matrix to convert sky coordinates to ideal local coordinates
31// for example:
32//
33// const Double_t ra = MAstro::Hms2Rad(5, 34, 31.9);
34// const Double_t dec = MAstro::Dms2Rad(22, 0, 52.0);
35//
36// MTime time;
37// time.Set(2004, 1, 26, 00, 20, 00);
38//
39// MObservatory obs(MObservatory::kMagic1);
40//
41// TVector3 v;
42// v.SetMagThetaPhi(1, TMath::Pi()/2-dec, ra);
43//
44// v *= MAstroSky2Local(time, obs);
45//
46// Double_t azimuth = v.Phi();
47// Double_t zdistance = v.Theta();
48//
49// To get the inverse matrix for an inverse transformation you can use:
50//
51// MAstroSky2Local::Invert()
52//
53// or simply do:
54//
55// v *= MAstroSky2Local(time, obs).Inverse();
56//
57// Reminder: This tranformation only does a simple coordinate
58// transformation. It completely ignores all other atrometric
59// effects, like nutation, abberation, precission, ...
60//
61////////////////////////////////////////////////////////////////////////////
62#include "MAstroSky2Local.h"
63
64#include "MAstro.h"
65#include "MTime.h"
66#include "MObservatory.h"
67
68using namespace std;
69
70ClassImp(MAstroSky2Local);
71
72// --------------------------------------------------------------------------
73//
74// Initialize the rotation matrix R as:
75//
76// R = A*B*C*D
77//
78// with
79//
80// |1 0 0|
81// A = |0 -1 0| (Change counting direction of rotation angle)
82// |0 0 1|
83//
84// B = RotZ(r1) (Change rotation angle such, that phi=0 is identical
85// for both coordinate systems)
86//
87// C = RotY(r2) (Make zenith and sky pole the same point)
88//
89// D = RotZ(180deg) (Align rotation angle to N=0, E=90)
90//
91// with
92//
93// r1 = gmst + longitude with gmst fraction of day, see MTime::GetGmst
94// logitude of observers location
95//
96// r2 = latitude-90deg with latitude of observers location
97//
98void MAstroSky2Local::Init(Double_t gmst, const MObservatory &obs)
99{
100 RotateZ(gmst + obs.GetElong());
101 RotateY(obs.GetPhi()-TMath::Pi()/2);
102 RotateZ(TMath::Pi());
103}
104
105// --------------------------------------------------------------------------
106//
107// Initialize MAstroSky2Local for a given time an a defined observatory
108// For more information see class description
109// For more information about gmst see MTime::GetGmst()
110//
111MAstroSky2Local::MAstroSky2Local(Double_t gmst, const MObservatory &obs) : TRotation(1, 0, 0, 0, -1, 0, 0, 0, 1)
112{
113 Init(gmst, obs);
114}
115
116// --------------------------------------------------------------------------
117//
118// Initialize MAstroSky2Local for a given time an a defined observatory
119// For more information see class description
120//
121MAstroSky2Local::MAstroSky2Local(const MTime &t, const MObservatory &obs) : TRotation(1, 0, 0, 0, -1, 0, 0, 0, 1)
122{
123 Init(t.GetGmst(), obs);
124}
125
126// --------------------------------------------------------------------------
127//
128// Get the corresponding rotation angle of the sky coordinate system
129// seen with an Alt/Az telescope.
130//
131// dzd and daz is a pointing offset, which is subtracted from the
132// calculated local coordinates correspoding to time, observatory
133// and ra/dec.
134//
135// For more information see MAstro::RotationAngle
136//
137Double_t MAstroSky2Local::RotationAngle(Double_t ra, Double_t dec, Double_t dzd, Double_t daz) const
138{
139 TVector3 v;
140 v.SetMagThetaPhi(1, TMath::Pi()/2-dec, ra);
141 v *= *this;
142
143 return MAstro::RotationAngle(ZZ(), XZ(), v.Theta()-dzd, v.Phi()-daz);
144}
Note: See TracBrowser for help on using the repository browser.