Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
REveTrans.hxx
Go to the documentation of this file.
1 // @(#)root/eve7:$Id$
2 // Authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007, 2018
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2019, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef ROOT7_REveTrans
13 #define ROOT7_REveTrans
14 
15 #include <ROOT/REveVector.hxx>
16 #include "TVector3.h"
17 
18 class TGeoMatrix;
19 class TGeoHMatrix;
20 class TBuffer3D;
21 
22 namespace ROOT {
23 namespace Experimental {
24 
25 /******************************************************************************/
26 // REveTrans -- 3D transformation in generalised coordinates
27 /******************************************************************************/
28 
29 class REveTrans : public TObject
30 {
31 protected:
32  Double32_t fM[16];
33 
34  mutable Float_t fA1; //!
35  mutable Float_t fA2; //!
36  mutable Float_t fA3; //!
37  mutable Bool_t fAsOK; //!
38 
39  // REveUtil
40  Bool_t fUseTrans; // use transformation matrix
41  Bool_t fEditTrans; // edit transformation in TGedFrame
42  Bool_t fEditRotation; // edit rotation
43  Bool_t fEditScale; // edit scale
44 
45  Double_t Norm3Column(Int_t col);
46  Double_t Orto3Column(Int_t col, Int_t ref);
47 
48 public:
49  REveTrans();
50  REveTrans(const REveTrans &t);
51  REveTrans(const Double_t arr[16]);
52  REveTrans(const Float_t arr[16]);
53  virtual ~REveTrans() {}
54 
55  // General operations
56 
57  void UnitTrans();
58  void ZeroTrans(Double_t w = 1.0);
59  void UnitRot();
60  void SetTrans(const REveTrans &t, Bool_t copyAngles = kTRUE);
61  void SetFromArray(const Double_t arr[16]);
62  void SetFromArray(const Float_t arr[16]);
63  REveTrans &operator=(const REveTrans &t)
64  {
65  SetTrans(t);
66  return *this;
67  }
68  void SetupRotation(Int_t i, Int_t j, Double_t f);
69  void SetupFromToVec(const REveVector &from, const REveVector &to);
70 
71  void OrtoNorm3();
72  Double_t Invert();
73 
74  void MultLeft(const REveTrans &t);
75  void MultRight(const REveTrans &t);
76  void operator*=(const REveTrans &t) { MultRight(t); }
77 
78  void TransposeRotationPart();
79 
80  REveTrans operator*(const REveTrans &t);
81 
82  // Move & Rotate
83 
84  void MoveLF(Int_t ai, Double_t amount);
85  void Move3LF(Double_t x, Double_t y, Double_t z);
86  void RotateLF(Int_t i1, Int_t i2, Double_t amount);
87 
88  void MovePF(Int_t ai, Double_t amount);
89  void Move3PF(Double_t x, Double_t y, Double_t z);
90  void RotatePF(Int_t i1, Int_t i2, Double_t amount);
91 
92  void Move(const REveTrans &a, Int_t ai, Double_t amount);
93  void Move3(const REveTrans &a, Double_t x, Double_t y, Double_t z);
94  void Rotate(const REveTrans &a, Int_t i1, Int_t i2, Double_t amount);
95 
96  // Element access
97 
98  Double_t *Array() { return fM; }
99  const Double_t *Array() const { return fM; }
100  Double_t *ArrX() { return fM; }
101  const Double_t *ArrX() const { return fM; }
102  Double_t *ArrY() { return fM + 4; }
103  const Double_t *ArrY() const { return fM + 4; }
104  Double_t *ArrZ() { return fM + 8; }
105  const Double_t *ArrZ() const { return fM + 8; }
106  Double_t *ArrT() { return fM + 12; }
107  const Double_t *ArrT() const { return fM + 12; }
108 
109  Double_t operator[](Int_t i) const { return fM[i]; }
110  Double_t &operator[](Int_t i) { return fM[i]; }
111 
112  Double_t CM(Int_t i, Int_t j) const { return fM[4 * j + i]; }
113  Double_t &CM(Int_t i, Int_t j) { return fM[4 * j + i]; }
114 
115  Double_t operator()(Int_t i, Int_t j) const { return fM[4 * j + i - 5]; }
116  Double_t &operator()(Int_t i, Int_t j) { return fM[4 * j + i - 5]; }
117 
118  // Base-vector interface
119 
120  void SetBaseVec(Int_t b, Double_t x, Double_t y, Double_t z);
121  void SetBaseVec(Int_t b, const TVector3 &v);
122 
123  TVector3 GetBaseVec(Int_t b) const;
124  void GetBaseVec(Int_t b, TVector3 &v) const;
125 
126  // Position interface
127 
128  void SetPos(Double_t x, Double_t y, Double_t z);
129  void SetPos(Double_t *x);
130  void SetPos(Float_t *x);
131  void SetPos(const REveTrans &t);
132 
133  void GetPos(Double_t &x, Double_t &y, Double_t &z) const;
134  void GetPos(Double_t *x) const;
135  void GetPos(Float_t *x) const;
136  void GetPos(TVector3 &v) const;
137  TVector3 GetPos() const;
138 
139  // Cardan angle interface
140 
141  void SetRotByAngles(Float_t a1, Float_t a2, Float_t a3);
142  void SetRotByAnyAngles(Float_t a1, Float_t a2, Float_t a3, const char *pat);
143  void GetRotAngles(Float_t *x) const;
144 
145  // Scaling
146 
147  void Scale(Double_t sx, Double_t sy, Double_t sz);
148  Double_t Unscale();
149  void Unscale(Double_t &sx, Double_t &sy, Double_t &sz);
150  void GetScale(Double_t &sx, Double_t &sy, Double_t &sz) const;
151  void SetScale(Double_t sx, Double_t sy, Double_t sz);
152  void SetScaleX(Double_t sx);
153  void SetScaleY(Double_t sy);
154  void SetScaleZ(Double_t sz);
155 
156  // Operations on vectors
157 
158  void MultiplyIP(TVector3 &v, Double_t w = 1) const;
159  void MultiplyIP(Double_t *v, Double_t w = 1) const;
160  void MultiplyIP(Float_t *v, Double_t w = 1) const;
161  TVector3 Multiply(const TVector3 &v, Double_t w = 1) const;
162  void Multiply(const Double_t *vin, Double_t *vout, Double_t w = 1) const;
163  void RotateIP(TVector3 &v) const;
164  void RotateIP(Double_t *v) const;
165  void RotateIP(Float_t *v) const;
166  TVector3 Rotate(const TVector3 &v) const;
167 
168  virtual void Print(Option_t *option = "") const;
169 
170  // REveUtil stuff
171 
172  void SetFrom(Double_t *carr);
173  void SetFrom(const TGeoMatrix &mat);
174  void SetGeoHMatrix(TGeoHMatrix &mat);
175  void SetBuffer3D(TBuffer3D &buff);
176 
177  Bool_t GetUseTrans() const { return fUseTrans; }
178  void SetUseTrans(Bool_t v) { fUseTrans = v; }
179 
180  void SetEditRotation(Bool_t x) { fEditRotation = x; }
181  void SetEditScale(Bool_t x) { fEditScale = x; }
182  Bool_t GetEditRotation() { return fEditRotation; }
183  Bool_t GetEditScale() { return fEditScale; }
184 
185  Bool_t GetEditTrans() const { return fEditTrans; }
186  void SetEditTrans(Bool_t v) { fEditTrans = v; }
187 
188  Bool_t IsScale(Double_t low = 0.9, Double_t high = 1.1) const;
189 
190  ClassDef(REveTrans, 1); // Column-major 4x4 transforamtion matrix for homogeneous coordinates.
191 };
192 
193 std::ostream &operator<<(std::ostream &s, const REveTrans &t);
194 
195 } // namespace Experimental
196 } // namespace ROOT
197 
198 #endif