Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/root/TEveTrans.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // @(#)root/eve:$Id$
0002 // Authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007
0003 
0004 /*************************************************************************
0005  * Copyright (C) 1995-2007, Rene Brun and Fons Rademakers.               *
0006  * All rights reserved.                                                  *
0007  *                                                                       *
0008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
0010  *************************************************************************/
0011 
0012 #ifndef ROOT_TEveTrans
0013 #define ROOT_TEveTrans
0014 
0015 #include "TEveVector.h"
0016 #include "TVector3.h"
0017 
0018 class TGeoMatrix;
0019 class TGeoHMatrix;
0020 class TBuffer3D;
0021 
0022 /******************************************************************************/
0023 // TEveTrans -- 3D transformation in generalised coordinates
0024 /******************************************************************************/
0025 
0026 class TEveTrans : public TObject
0027 {
0028    friend class TEveTransSubEditor;
0029    friend class TEveTransEditor;
0030 
0031 protected:
0032    Double32_t            fM[16];
0033 
0034    mutable Float_t       fA1;   //!
0035    mutable Float_t       fA2;   //!
0036    mutable Float_t       fA3;   //!
0037    mutable Bool_t        fAsOK; //!
0038 
0039    // TEveUtil
0040    Bool_t                fUseTrans;       // use transformation matrix
0041    Bool_t                fEditTrans;      // edit transformation in TGedFrame
0042    Bool_t                fEditRotation;   // edit rotation
0043    Bool_t                fEditScale;      // edit scale
0044 
0045    Double_t Norm3Column(Int_t col);
0046    Double_t Orto3Column(Int_t col, Int_t ref);
0047 
0048 public:
0049    TEveTrans();
0050    TEveTrans(const TEveTrans& t);
0051    TEveTrans(const Double_t arr[16]);
0052    TEveTrans(const Float_t  arr[16]);
0053    ~TEveTrans() override {}
0054 
0055    // General operations
0056 
0057    void     UnitTrans();
0058    void     ZeroTrans(Double_t w=1.0);
0059    void     UnitRot();
0060    void     SetTrans(const TEveTrans& t, Bool_t copyAngles=kTRUE);
0061    void     SetFromArray(const Double_t arr[16]);
0062    void     SetFromArray(const Float_t  arr[16]);
0063    TEveTrans&  operator=(const TEveTrans& t) { SetTrans(t); return *this; }
0064    void     SetupRotation(Int_t i, Int_t j, Double_t f);
0065    void     SetupFromToVec(const TEveVector& from, const TEveVector& to);
0066 
0067    void     OrtoNorm3();
0068    Double_t Invert();
0069 
0070    void MultLeft(const TEveTrans& t);
0071    void MultRight(const TEveTrans& t);
0072    void operator*=(const TEveTrans& t) { MultRight(t); }
0073 
0074    void TransposeRotationPart();
0075 
0076    TEveTrans operator*(const TEveTrans& t);
0077 
0078    // Move & Rotate
0079 
0080    void MoveLF(Int_t ai, Double_t amount);
0081    void Move3LF(Double_t x, Double_t y, Double_t z);
0082    void RotateLF(Int_t i1, Int_t i2, Double_t amount);
0083 
0084    void MovePF(Int_t ai, Double_t amount);
0085    void Move3PF(Double_t x, Double_t y, Double_t z);
0086    void RotatePF(Int_t i1, Int_t i2, Double_t amount);
0087 
0088    void Move(const TEveTrans& a, Int_t ai, Double_t amount);
0089    void Move3(const TEveTrans& a, Double_t x, Double_t y, Double_t z);
0090    void Rotate(const TEveTrans& a, Int_t i1, Int_t i2, Double_t amount);
0091 
0092    // Element access
0093 
0094    Double_t* Array() { return fM; }      const Double_t* Array() const { return fM; }
0095    Double_t* ArrX()  { return fM; }      const Double_t* ArrX()  const { return fM; }
0096    Double_t* ArrY()  { return fM +  4; } const Double_t* ArrY()  const { return fM +  4; }
0097    Double_t* ArrZ()  { return fM +  8; } const Double_t* ArrZ()  const { return fM +  8; }
0098    Double_t* ArrT()  { return fM + 12; } const Double_t* ArrT()  const { return fM + 12; }
0099 
0100    Double_t  operator[](Int_t i) const { return fM[i]; }
0101    Double_t& operator[](Int_t i)       { return fM[i]; }
0102 
0103    Double_t  CM(Int_t i, Int_t j) const { return fM[4*j + i]; }
0104    Double_t& CM(Int_t i, Int_t j)       { return fM[4*j + i]; }
0105 
0106    Double_t  operator()(Int_t i, Int_t j) const { return fM[4*j + i - 5]; }
0107    Double_t& operator()(Int_t i, Int_t j)       { return fM[4*j + i - 5]; }
0108 
0109    // Base-vector interface
0110 
0111    void SetBaseVec(Int_t b, Double_t x, Double_t y, Double_t z);
0112    void SetBaseVec(Int_t b, const TVector3& v);
0113 
0114    TVector3 GetBaseVec(Int_t b) const;
0115    void     GetBaseVec(Int_t b, TVector3& v) const;
0116 
0117    // Position interface
0118 
0119    void SetPos(Double_t x, Double_t y, Double_t z);
0120    void SetPos(Double_t* x);
0121    void SetPos(Float_t * x);
0122    void SetPos(const TEveTrans& t);
0123 
0124    void GetPos(Double_t& x, Double_t& y, Double_t& z) const;
0125    void GetPos(Double_t* x) const;
0126    void GetPos(Float_t * x) const;
0127    void GetPos(TVector3& v) const;
0128    TVector3 GetPos() const;
0129 
0130    // Cardan angle interface
0131 
0132    void SetRotByAngles(Float_t a1, Float_t a2, Float_t a3);
0133    void SetRotByAnyAngles(Float_t a1, Float_t a2, Float_t a3, const char* pat);
0134    void GetRotAngles(Float_t* x) const;
0135 
0136    // Scaling
0137 
0138    void     Scale(Double_t sx, Double_t sy, Double_t sz);
0139    Double_t Unscale();
0140    void     Unscale(Double_t& sx, Double_t& sy, Double_t& sz);
0141    void     GetScale(Double_t& sx, Double_t& sy, Double_t& sz) const;
0142    void     SetScale(Double_t  sx, Double_t  sy, Double_t  sz);
0143    void     SetScaleX(Double_t sx);
0144    void     SetScaleY(Double_t sy);
0145    void     SetScaleZ(Double_t sz);
0146 
0147    // Operations on vectors
0148 
0149    void     MultiplyIP(TVector3& v, Double_t w=1) const;
0150    void     MultiplyIP(Double_t* v, Double_t w=1) const;
0151    void     MultiplyIP(Float_t*  v, Double_t w=1) const;
0152    TVector3 Multiply(const TVector3& v, Double_t w=1) const;
0153    void     Multiply(const Double_t *vin, Double_t* vout, Double_t w=1) const;
0154    void     RotateIP(TVector3& v) const;
0155    void     RotateIP(Double_t* v) const;
0156    void     RotateIP(Float_t*  v) const;
0157    TVector3 Rotate(const TVector3& v) const;
0158 
0159    void Print(Option_t* option = "") const override;
0160 
0161    // TEveUtil stuff
0162 
0163    void SetFrom(Double_t* carr);
0164    void SetFrom(const TGeoMatrix& mat);
0165    void SetGeoHMatrix(TGeoHMatrix& mat);
0166    void SetBuffer3D(TBuffer3D& buff);
0167 
0168    Bool_t GetUseTrans()  const { return fUseTrans; }
0169    void SetUseTrans(Bool_t v)  { fUseTrans = v;    }
0170 
0171    void SetEditRotation(Bool_t x){ fEditRotation = x; }
0172    void SetEditScale(Bool_t x)   { fEditScale = x; }
0173    Bool_t GetEditRotation()      { return fEditRotation; }
0174    Bool_t GetEditScale()         { return fEditScale; }
0175 
0176    Bool_t GetEditTrans() const { return fEditTrans; }
0177    void SetEditTrans(Bool_t v) { fEditTrans = v;    }
0178 
0179    Bool_t IsScale(Double_t low=0.9, Double_t high=1.1) const;
0180 
0181    ClassDefOverride(TEveTrans, 1); // Column-major 4x4 transforamtion matrix for homogeneous coordinates.
0182 };
0183 
0184 std::ostream& operator<<(std::ostream& s, const TEveTrans& t);
0185 
0186 #endif