source: JEM-EUSO/esaf_cc_at_lal/packages/common/base/include/EsafRefFrame.hh @ 114

Last change on this file since 114 was 114, checked in by moretto, 11 years ago

actual version of ESAF at CCin2p3

File size: 3.5 KB
Line 
1// $Id: EsafRefFrame.hh 2149 2005-10-04 02:50:53Z thea $
2// Author: Alessandro Thea   2005/03/21
3
4/*****************************************************************************
5 * ESAF: Euso Simulation and Analysis Framework                              *
6 *                                                                           *
7 *  Id: EsafRefFrame                                                         *
8 *  Package: Base                                                            *
9 *  Coordinator: Marco.Pallavicini, Alessandro.Thea                          *
10 *                                                                           *
11 *****************************************************************************/
12
13#ifndef __ESAFREFFRAME_HH__
14#define __ESAFREFFRAME_HH__
15
16#include "euso.hh"
17#include <TVector3.h>
18#include <TRotation.h>
19
20////////////////////////////////////////////////////////////////////////////////
21//                                                                            //
22// EsafRefFrame                                                               //
23//                                                                            //
24// Base class for all the objects which have a local coordinate reference     //
25// frame                                                                      //
26//                                                                            //
27////////////////////////////////////////////////////////////////////////////////
28
29class EsafRefFrame {
30public:
31    EsafRefFrame();
32    virtual ~EsafRefFrame();
33
34    virtual void Copy( EsafRefFrame& ) const;
35    virtual const TVector3& GetPos() const { return fPos; }
36    virtual const TVector3& GetXaxis() const { return fXaxis; }
37    virtual const TVector3& GetYaxis() const { return fYaxis; }
38    virtual const TVector3& GetZaxis() const { return fZaxis; }
39
40    virtual void SetPos( const TVector3& p ) { fPos=p; }
41    virtual void SetPos( Double_t x, Double_t y, Double_t z ) { fPos.SetXYZ(x,y,z); }
42    virtual void SetAxes( const TVector3& x, const TVector3& y, const TVector3& z);
43    virtual void SetXEulerRotation( Double_t phi, Double_t theta, Double_t psi);
44    virtual void SetYEulerRotation( Double_t phi, Double_t theta, Double_t psi);
45
46    inline TVector3 ToLocal( const TVector3& ) const;
47    inline TVector3 ToGlobal( const TVector3& ) const;
48
49    const TRotation* GetToGlobal() const { return &fRot2Global; }
50    const TRotation* GetToLocal() const { return &fRot2Local; }
51
52protected:
53
54//    EsafRefFrame( const TVector3& p, const TVector3& x, const TVector3& y, const TVector3& z );
55    TVector3 fPos;     // position in a reference system to be assigned
56
57    TVector3 fXaxis;
58    TVector3 fYaxis;
59    TVector3 fZaxis;
60   
61    TRotation fRot2Global;    // rotation from local coodinate to global.
62    TRotation fRot2Local;
63       
64    ClassDef(EsafRefFrame,0)
65};
66
67
68inline void EsafRefFrame::SetAxes( const TVector3& x, const TVector3& y, const TVector3& z) {
69    fXaxis = x;
70    fYaxis = y;
71    fZaxis = z;
72
73    fRot2Global = fRot2Global.RotateAxes(fXaxis, fYaxis, fZaxis);
74    fRot2Local = fRot2Global.Inverse();
75}
76
77inline TVector3 EsafRefFrame::ToLocal( const TVector3& v ) const {
78    TVector3 nv = v-fPos;
79    if ( !fRot2Local.IsIdentity() ) nv.Transform(fRot2Local);
80    return nv;
81}
82
83inline TVector3 EsafRefFrame::ToGlobal( const TVector3& v ) const {
84    TVector3 nv = v;
85    if ( !fRot2Global.IsIdentity() ) nv.Transform(fRot2Global);
86    nv += fPos;
87    return nv;
88}
89
90#endif  /* __ESAFREFFRAME_HH__ */
Note: See TracBrowser for help on using the repository browser.