TEveTrans.h

Go to the documentation of this file.
00001 // @(#)root/eve:$Id: TEveTrans.h 32931 2010-04-09 16:29:40Z matevz $
00002 // Authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2007, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 #ifndef ROOT_TEveTrans
00013 #define ROOT_TEveTrans
00014 
00015 #include "TEveVector.h"
00016 #include "TVector3.h"
00017 
00018 class TGeoMatrix;
00019 class TGeoHMatrix;
00020 class TBuffer3D;
00021 
00022 /******************************************************************************/
00023 // TEveTrans -- 3D transformation in generalised coordinates
00024 /******************************************************************************/
00025 
00026 class TEveTrans : public TObject
00027 {
00028    friend class TEveTransSubEditor;
00029    friend class TEveTransEditor;
00030 
00031 protected:
00032    Double32_t            fM[16];
00033 
00034    mutable Float_t       fA1;   //!
00035    mutable Float_t       fA2;   //!
00036    mutable Float_t       fA3;   //!
00037    mutable Bool_t        fAsOK; //!
00038 
00039    // TEveUtil
00040    Bool_t                fUseTrans;       // use transformation matrix
00041    Bool_t                fEditTrans;      // edit transformation in TGedFrame
00042    Bool_t                fEditRotation;   // edit rotation
00043    Bool_t                fEditScale;      // edit scale
00044 
00045    Double_t Norm3Column(Int_t col);
00046    Double_t Orto3Column(Int_t col, Int_t ref);
00047 
00048 public:
00049    TEveTrans();
00050    TEveTrans(const TEveTrans& t);
00051    TEveTrans(const Double_t arr[16]);
00052    TEveTrans(const Float_t  arr[16]);
00053    virtual ~TEveTrans() {}
00054 
00055    // General operations
00056 
00057    void     UnitTrans();
00058    void     ZeroTrans(Double_t w=1.0);
00059    void     UnitRot();
00060    void     SetTrans(const TEveTrans& t, Bool_t copyAngles=kTRUE);
00061    void     SetFromArray(const Double_t arr[16]);
00062    void     SetFromArray(const Float_t  arr[16]);
00063    TEveTrans&  operator=(const TEveTrans& t) { SetTrans(t); return *this; }
00064    void     SetupRotation(Int_t i, Int_t j, Double_t f);
00065    void     SetupFromToVec(const TEveVector& from, const TEveVector& to);
00066 
00067    void     OrtoNorm3();
00068    Double_t Invert();
00069 
00070    void MultLeft(const TEveTrans& t);
00071    void MultRight(const TEveTrans& t);
00072    void operator*=(const TEveTrans& t) { MultRight(t); }
00073 
00074    void TransposeRotationPart();
00075 
00076    TEveTrans operator*(const TEveTrans& t);
00077 
00078    // Move & Rotate
00079 
00080    void MoveLF(Int_t ai, Double_t amount);
00081    void Move3LF(Double_t x, Double_t y, Double_t z);
00082    void RotateLF(Int_t i1, Int_t i2, Double_t amount);
00083 
00084    void MovePF(Int_t ai, Double_t amount);
00085    void Move3PF(Double_t x, Double_t y, Double_t z);
00086    void RotatePF(Int_t i1, Int_t i2, Double_t amount);
00087 
00088    void Move(const TEveTrans& a, Int_t ai, Double_t amount);
00089    void Move3(const TEveTrans& a, Double_t x, Double_t y, Double_t z);
00090    void Rotate(const TEveTrans& a, Int_t i1, Int_t i2, Double_t amount);
00091 
00092    // Element access
00093 
00094    Double_t* Array() { return fM; }      const Double_t* Array() const { return fM; }
00095    Double_t* ArrX()  { return fM; }      const Double_t* ArrX()  const { return fM; }
00096    Double_t* ArrY()  { return fM +  4; } const Double_t* ArrY()  const { return fM +  4; }
00097    Double_t* ArrZ()  { return fM +  8; } const Double_t* ArrZ()  const { return fM +  8; }
00098    Double_t* ArrT()  { return fM + 12; } const Double_t* ArrT()  const { return fM + 12; }
00099 
00100    Double_t  operator[](Int_t i) const { return fM[i]; }
00101    Double_t& operator[](Int_t i)       { return fM[i]; }
00102 
00103    Double_t  CM(Int_t i, Int_t j) const { return fM[4*j + i]; }
00104    Double_t& CM(Int_t i, Int_t j)       { return fM[4*j + i]; }
00105 
00106    Double_t  operator()(Int_t i, Int_t j) const { return fM[4*j + i - 5]; }
00107    Double_t& operator()(Int_t i, Int_t j)       { return fM[4*j + i - 5]; }
00108 
00109    // Base-vector interface
00110 
00111    void SetBaseVec(Int_t b, Double_t x, Double_t y, Double_t z);
00112    void SetBaseVec(Int_t b, const TVector3& v);
00113 
00114    TVector3 GetBaseVec(Int_t b) const;
00115    void     GetBaseVec(Int_t b, TVector3& v) const;
00116 
00117    // Position interface
00118 
00119    void SetPos(Double_t x, Double_t y, Double_t z);
00120    void SetPos(Double_t* x);
00121    void SetPos(Float_t * x);
00122    void SetPos(const TEveTrans& t);
00123 
00124    void GetPos(Double_t& x, Double_t& y, Double_t& z) const;
00125    void GetPos(Double_t* x) const;
00126    void GetPos(Float_t * x) const;
00127    void GetPos(TVector3& v) const;
00128    TVector3 GetPos() const;
00129 
00130    // Cardan angle interface
00131 
00132    void SetRotByAngles(Float_t a1, Float_t a2, Float_t a3);
00133    void SetRotByAnyAngles(Float_t a1, Float_t a2, Float_t a3, const char* pat);
00134    void GetRotAngles(Float_t* x) const;
00135 
00136    // Scaling
00137 
00138    void     Scale(Double_t sx, Double_t sy, Double_t sz);
00139    Double_t Unscale();
00140    void     Unscale(Double_t& sx, Double_t& sy, Double_t& sz);
00141    void     GetScale(Double_t& sx, Double_t& sy, Double_t& sz) const;
00142    void     SetScale(Double_t  sx, Double_t  sy, Double_t  sz);
00143    void     SetScaleX(Double_t sx);
00144    void     SetScaleY(Double_t sy);
00145    void     SetScaleZ(Double_t sz);
00146 
00147    // Operations on vectors
00148 
00149    void     MultiplyIP(TVector3& v, Double_t w=1) const;
00150    void     MultiplyIP(Double_t* v, Double_t w=1) const;
00151    void     MultiplyIP(Float_t*  v, Double_t w=1) const;
00152    TVector3 Multiply(const TVector3& v, Double_t w=1) const;
00153    void     Multiply(const Double_t *vin, Double_t* vout, Double_t w=1) const;
00154    void     RotateIP(TVector3& v) const;
00155    void     RotateIP(Double_t* v) const;
00156    void     RotateIP(Float_t*  v) const;
00157    TVector3 Rotate(const TVector3& v) const;
00158 
00159    virtual void Print(Option_t* option = "") const;
00160 
00161    // TEveUtil stuff
00162 
00163    void SetFrom(Double_t* carr);
00164    void SetFrom(const TGeoMatrix& mat);
00165    void SetGeoHMatrix(TGeoHMatrix& mat);
00166    void SetBuffer3D(TBuffer3D& buff);
00167 
00168    Bool_t GetUseTrans()  const { return fUseTrans; }
00169    void SetUseTrans(Bool_t v)  { fUseTrans = v;    }
00170 
00171    void SetEditRotation(Bool_t x){ fEditRotation = x; }
00172    void SetEditScale(Bool_t x)   { fEditScale = x; }
00173    Bool_t GetEditRotation()      { return fEditRotation; }
00174    Bool_t GetEditScale()         { return fEditScale; }
00175 
00176    Bool_t GetEditTrans() const { return fEditTrans; }
00177    void SetEditTrans(Bool_t v) { fEditTrans = v;    }
00178 
00179    Bool_t IsScale(Double_t low=0.9, Double_t high=1.1) const;
00180 
00181    ClassDef(TEveTrans, 1); // Column-major 4x4 transforamtion matrix for homogeneous coordinates.
00182 };
00183 
00184 ostream& operator<<(ostream& s, const TEveTrans& t);
00185 
00186 #endif

Generated on Tue Jul 5 14:15:03 2011 for ROOT_528-00b_version by  doxygen 1.5.1