Ignore:
Timestamp:
03/01/04 11:36:44 (21 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/mastro
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/mastro/MAstro.cc

    r3326 r3366  
    3131#include "MAstro.h"
    3232
     33#include <TVector3.h> // TVector3
     34
    3335ClassImp(MAstro);
    3436
     
    183185}
    184186
     187// --------------------------------------------------------------------------
     188//
     189// Interpretes a string ' - 12 30 00.0' or '+ 12 30 00.0'
     190// as floating point value -12.5 or 12.5. If interpretation is
     191// successfull kTRUE is returned, otherwise kFALSE. ret is not
     192// touched if interpretation was not successfull. The successfull
     193// interpreted part is removed from the TString.
     194//
    185195Bool_t MAstro::String2Angle(TString &str, Double_t &ret)
    186196{
     
    202212}
    203213
     214// --------------------------------------------------------------------------
     215//
     216// Interpretes a string '-12:30:00.0', '12:30:00.0' or '+12:30:00.0'
     217// as floating point value -12.5, 12.5 or 12.5. If interpretation is
     218// successfull kTRUE is returned, otherwise kFALSE. ret is not
     219// touched if interpretation was not successfull.
     220//
     221Bool_t MAstro::Coordinate2Angle(const TString &str, Double_t &ret)
     222{
     223    Char_t  sgn = str[0]=='-' ? '-' : '+';
     224    Int_t   d;
     225    UInt_t  m;
     226    Float_t s;
     227
     228    const int n=sscanf(str[0]=='+'||str[0]=='-' ? str.Data()+1 : str.Data(), "%d:%d:%f", &d, &m, &s);
     229
     230    if (n!=3)
     231        return kFALSE;
     232
     233    ret = Dms2Deg(d, m, s, sgn);
     234    return kTRUE;
     235}
     236
     237// --------------------------------------------------------------------------
     238//
     239//  Return year y, month m and day d corresponding to Mjd.
     240//
    204241void MAstro::Mjd2Ymd(UInt_t mjd, UShort_t &y, Byte_t &m, Byte_t &d)
    205242{
     
    214251}
    215252
     253// --------------------------------------------------------------------------
     254//
     255//  Return Mjd corresponding to year y, month m and day d.
     256//
    216257Int_t MAstro::Ymd2Mjd(UShort_t y, Byte_t m, Byte_t d)
    217258{
     
    237278    return 1461L*lm10/4 + (306*((m+9)%12)+5)/10 - (3*((lm10+188)/100))/4 + d - 2399904;
    238279}
     280
     281// --------------------------------------------------------------------------
     282//
     283//  theta0, phi0    [rad]: polar angle/zenith distance, azimuth of 1st object
     284//  theta1, phi1    [rad]: polar angle/zenith distance, azimuth of 2nd object
     285//  AngularDistance [rad]: Angular distance between two objects
     286//
     287Double_t MAstro::AngularDistance(Double_t theta0, Double_t phi0, Double_t theta1, Double_t phi1)
     288{
     289    TVector3 v0(1);
     290    v0.Rotate(phi0, theta0);
     291
     292    TVector3 v1(1);
     293    v1.Rotate(phi1, theta1);
     294
     295    return v0.Angle(v1);
     296}
  • trunk/MagicSoft/Mars/mastro/MAstro.h

    r3326 r3366  
    3838
    3939    static Bool_t String2Angle(TString &str, Double_t &ret);
     40    static Bool_t Coordinate2Angle(const TString &str, Double_t &ret);
    4041
     42    static Double_t AngularDistance(Double_t theta0, Double_t phi0, Double_t theta1, Double_t phi1);
     43 
    4144    static void  Mjd2Ymd(UInt_t mjd, UShort_t &y, Byte_t &m, Byte_t &d);
    4245    static Int_t Ymd2Mjd(UShort_t y, Byte_t m, Byte_t d);
  • trunk/MagicSoft/Mars/mastro/MObservatory.cc

    r3328 r3366  
    8181        fHeight    = 2196.5; // m
    8282        fObservatoryName = "Observatorio del Roque de los Muchachos (Magic1)";
    83         return;
     83        break;
    8484
    8585    case kWuerzburgCity:
     
    8888        fHeight    = 300;
    8989        fObservatoryName = "Wuerzburg City";
    90         return;
     90        break;
     91    }
    9192
    92     }
     93    fSinLatitude = TMath::Sin(fLatitude);
     94    fCosLatitude = TMath::Cos(fLatitude);
    9395}
    9496
     
    102104}
    103105
     106// --------------------------------------------------------------------------
     107//
     108// RotationAngle
     109//
     110// calculates the angle for the rotation of the sky image in the camera;
     111// this angle is a function of the local coordinates
     112//
     113//  theta [rad]: polar angle/zenith distance
     114//  phi   [rad]: rotation angle/azimuth
     115//
     116// Return sin/cos component of angle
     117//
     118// calculate rotation angle alpha of sky image in camera
     119// (see TDAS 00-11, eqs. (18) and (20))
     120//
     121void MObservatory::RotationAngle(Double_t theta, Double_t phi, Double_t &sin, Double_t &cos) const
     122{
     123    const Double_t sint = TMath::Sin(theta);
     124    const Double_t cost = TMath::Cos(theta);
     125
     126    const Double_t sinl = fSinLatitude*sint;
     127    const Double_t cosl = fCosLatitude*cost;
     128
     129    const Double_t sinp = TMath::Sin(phi);
     130    const Double_t cosp = TMath::Cos(phi);
     131
     132    const Double_t v1 = sint*sinp;
     133    const Double_t v2 = cosl - sinl*cosp;
     134
     135    const Double_t denom = TMath::Sqrt(v1*v1 + v2*v2);
     136
     137    sin = (fCosLatitude*sinp) / denom;
     138    cos = sinl + cosl*cosp / denom;
     139}
     140
     141// --------------------------------------------------------------------------
     142//
     143// RotationAngle
     144//
     145// calculates the angle for the rotation of the sky image in the camera;
     146// this angle is a function of the local coordinates
     147//
     148//  theta [rad]: polar angle/zenith distance
     149//  phi   [rad]: rotation angle/azimuth
     150//
     151// Return RotationAngle in rad
     152//
     153// calculate rotation angle alpha of sky image in camera
     154// (see TDAS 00-11, eqs. (18) and (20))
     155//
     156Double_t MObservatory::RotationAngle(Double_t theta, Double_t phi) const
     157{
     158    const Double_t sint = TMath::Sin(theta);
     159    const Double_t cost = TMath::Cos(theta);
     160
     161    const Double_t sinp = TMath::Sin(phi);
     162    const Double_t cosp = TMath::Cos(phi);
     163
     164    const Double_t v1 = sint*sinp;
     165    const Double_t v2 = fCosLatitude*cost - fSinLatitude*sint*cosp;
     166
     167    const Double_t denom = TMath::Sqrt(v1*v1 + v2*v2);
     168
     169    return TMath::ASin((fCosLatitude*sinp) / denom);
     170}
  • trunk/MagicSoft/Mars/mastro/MObservatory.h

    r3326 r3366  
    2323    Double_t fLatitude;              //! [rad] Latitude of observatory (+ north)
    2424
     25    Double_t fSinLatitude;           //! Sin component for faster access
     26    Double_t fCosLatitude;           //! Cos component for faster access
     27
    2528    Double_t fHeight;                //! [m] height of observatory
    2629
     
    4649    Double_t GetElong() const           { return fLongitude; }          //[rad]
    4750
     51    Double_t GetSinPhi() const          { return fSinLatitude; }
     52    Double_t GetCosPhi() const          { return fCosLatitude; }
     53
    4854    Double_t GetHeight() const          { return fHeight; }
     55
     56    void RotationAngle(Double_t theta, Double_t phi, Double_t &sin, Double_t &cos) const;
     57    Double_t RotationAngle(Double_t theta, Double_t phi) const;
    4958
    5059    LocationName_t GetObservatoryKey() const { return fObservatoryKey; }
Note: See TracChangeset for help on using the changeset viewer.