// $Id: EsafRefFrame.hh,v 1.3 2005/10/04 02:50:53 thea Exp $ // Author: Alessandro Thea 2005/03/21 /***************************************************************************** * ESAF: Euso Simulation and Analysis Framework * * * * Id: EsafRefFrame * * Package: Base * * Coordinator: Marco.Pallavicini, Alessandro.Thea * * * *****************************************************************************/ #ifndef __ESAFREFFRAME_HH__ #define __ESAFREFFRAME_HH__ #include "euso.hh" #include #include //////////////////////////////////////////////////////////////////////////////// // // // EsafRefFrame // // // // Base class for all the objects which have a local coordinate reference // // frame // // // //////////////////////////////////////////////////////////////////////////////// class EsafRefFrame { public: EsafRefFrame(); virtual ~EsafRefFrame(); virtual void Copy( EsafRefFrame& ) const; virtual const TVector3& GetPos() const { return fPos; } virtual const TVector3& GetXaxis() const { return fXaxis; } virtual const TVector3& GetYaxis() const { return fYaxis; } virtual const TVector3& GetZaxis() const { return fZaxis; } virtual void SetPos( const TVector3& p ) { fPos=p; } virtual void SetPos( Double_t x, Double_t y, Double_t z ) { fPos.SetXYZ(x,y,z); } virtual void SetAxes( const TVector3& x, const TVector3& y, const TVector3& z); virtual void SetXEulerRotation( Double_t phi, Double_t theta, Double_t psi); virtual void SetYEulerRotation( Double_t phi, Double_t theta, Double_t psi); inline TVector3 ToLocal( const TVector3& ) const; inline TVector3 ToGlobal( const TVector3& ) const; const TRotation* GetToGlobal() const { return &fRot2Global; } const TRotation* GetToLocal() const { return &fRot2Local; } protected: // EsafRefFrame( const TVector3& p, const TVector3& x, const TVector3& y, const TVector3& z ); TVector3 fPos; // position in a reference system to be assigned TVector3 fXaxis; TVector3 fYaxis; TVector3 fZaxis; TRotation fRot2Global; // rotation from local coodinate to global. TRotation fRot2Local; ClassDef(EsafRefFrame,0) }; inline void EsafRefFrame::SetAxes( const TVector3& x, const TVector3& y, const TVector3& z) { fXaxis = x; fYaxis = y; fZaxis = z; fRot2Global = fRot2Global.RotateAxes(fXaxis, fYaxis, fZaxis); fRot2Local = fRot2Global.Inverse(); } inline TVector3 EsafRefFrame::ToLocal( const TVector3& v ) const { TVector3 nv = v-fPos; if ( !fRot2Local.IsIdentity() ) nv.Transform(fRot2Local); return nv; } inline TVector3 EsafRefFrame::ToGlobal( const TVector3& v ) const { TVector3 nv = v; if ( !fRot2Global.IsIdentity() ) nv.Transform(fRot2Global); nv += fPos; return nv; } #endif /* __ESAFREFFRAME_HH__ */