Logo ROOT  
Reference Guide
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:
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 
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]);
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 
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; }
179 
184 
185  Bool_t GetEditTrans() const { return fEditTrans; }
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
ROOT::Experimental::REveTrans::RotatePF
void RotatePF(Int_t i1, Int_t i2, Double_t amount)
Rotate in parent frame. Does optimised version of MultLeft.
Definition: REveTrans.cxx:414
TVector3
TVector3 is a general three vector class, which can be used for the description of different vectors ...
Definition: TVector3.h:22
ROOT::Experimental::REveTrans::fEditRotation
Bool_t fEditRotation
Definition: REveTrans.hxx:42
ROOT::Experimental::REveTrans::Norm3Column
Double_t Norm3Column(Int_t col)
Norm 3-vector in column col.
Definition: REveTrans.cxx:826
ROOT::Experimental::REveTrans::ArrZ
Double_t * ArrZ()
Definition: REveTrans.hxx:104
ROOT::Experimental::REveTrans::fAsOK
Bool_t fAsOK
Definition: REveTrans.hxx:37
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:91
ROOT::Experimental::REveTrans::GetScale
void GetScale(Double_t &sx, Double_t &sy, Double_t &sz) const
Deduce scales from sizes of base vectors.
Definition: REveTrans.cxx:679
f
#define f(i)
Definition: RSha256.hxx:104
Option_t
const char Option_t
Definition: RtypesCore.h:66
ROOT::Experimental::REveTrans::REveTrans
REveTrans()
Default constructor.
Definition: REveTrans.cxx:75
ROOT::Experimental::REveTrans::GetEditTrans
Bool_t GetEditTrans() const
Definition: REveTrans.hxx:185
ROOT::Experimental::REveTrans::ArrY
const Double_t * ArrY() const
Definition: REveTrans.hxx:103
ROOT::Experimental::REveTrans::Move3PF
void Move3PF(Double_t x, Double_t y, Double_t z)
General move in parent-frame.
Definition: REveTrans.cxx:404
ROOT::Experimental::operator<<
std::ostream & operator<<(std::ostream &s, const REveTrans &t)
ROOT::Experimental::REveTrans::SetBuffer3D
void SetBuffer3D(TBuffer3D &buff)
Fill transformation part TBuffer3D core section.
Definition: REveTrans.cxx:1050
ROOT::Experimental::REveTrans::SetScaleZ
void SetScaleZ(Double_t sz)
Change z scaling.
Definition: REveTrans.cxx:721
ROOT::Experimental::REveTrans::OrtoNorm3
void OrtoNorm3()
Orto-norm columns 1 to 3.
Definition: REveTrans.cxx:849
ROOT::Experimental::REveTrans::Move3LF
void Move3LF(Double_t x, Double_t y, Double_t z)
General move in local-frame.
Definition: REveTrans.cxx:366
ROOT::Experimental::REveTrans::SetPos
void SetPos(Double_t x, Double_t y, Double_t z)
Set position (base-vec 4).
Definition: REveTrans.cxx:508
Float_t
float Float_t
Definition: RtypesCore.h:57
TGeant4Unit::s
static constexpr double s
Definition: TGeant4SystemOfUnits.h:162
Int_t
int Int_t
Definition: RtypesCore.h:45
ROOT::Experimental::REveTrans::GetRotAngles
void GetRotAngles(Float_t *x) const
Get Cardan rotation angles (pattern xYz above).
Definition: REveTrans.cxx:624
x
Double_t x[n]
Definition: legend1.C:17
ROOT::Experimental::REveTrans
Definition: REveTrans.hxx:30
ROOT::Experimental::REveTrans::Rotate
void Rotate(const REveTrans &a, Int_t i1, Int_t i2, Double_t amount)
Rotate in a's coord-system, rotating base vector with index i1 into i2.
Definition: REveTrans.cxx:458
ROOT::Experimental::REveTrans::SetTrans
void SetTrans(const REveTrans &t, Bool_t copyAngles=kTRUE)
Set matrix from another,.
Definition: REveTrans.cxx:165
ROOT::Experimental::REveTrans::operator*
REveTrans operator*(const REveTrans &t)
Copy, multiply from right and return product.
Definition: REveTrans.cxx:335
ROOT::Experimental::REveVectorT< Float_t >
ROOT::Experimental::REveTrans::ArrX
const Double_t * ArrX() const
Definition: REveTrans.hxx:101
Bool_t
bool Bool_t
Definition: RtypesCore.h:63
v
@ v
Definition: rootcling_impl.cxx:3635
b
#define b(i)
Definition: RSha256.hxx:100
bool
ROOT::Experimental::REveTrans::RotateIP
void RotateIP(TVector3 &v) const
Rotate vector in-place. Translation is NOT applied.
Definition: REveTrans.cxx:782
ROOT::Experimental::REveTrans::fA2
Float_t fA2
Definition: REveTrans.hxx:35
TVector3.h
ROOT::Experimental::REveTrans::SetUseTrans
void SetUseTrans(Bool_t v)
Definition: REveTrans.hxx:178
ROOT::Experimental::REveTrans::GetBaseVec
TVector3 GetBaseVec(Int_t b) const
Get base-vector with index b.
Definition: REveTrans.cxx:492
ROOT::Experimental::REveTrans::operator=
REveTrans & operator=(const REveTrans &t)
Definition: REveTrans.hxx:63
ROOT::Experimental::REveTrans::Unscale
Double_t Unscale()
Remove scaling, make all base vectors of unit length.
Definition: REveTrans.cxx:658
ROOT::Experimental::REveTrans::Move
void Move(const REveTrans &a, Int_t ai, Double_t amount)
Move in a's coord-system along axis-index ai.
Definition: REveTrans.cxx:435
ROOT::Experimental::REveTrans::RotateLF
void RotateLF(Int_t i1, Int_t i2, Double_t amount)
Rotate in local frame. Does optimised version of MultRight.
Definition: REveTrans.cxx:376
TBuffer3D
Generic 3D primitive description class.
Definition: TBuffer3D.h:18
ROOT::Experimental::REveTrans::CM
Double_t CM(Int_t i, Int_t j) const
Definition: REveTrans.hxx:112
ROOT::Experimental::REveTrans::ArrX
Double_t * ArrX()
Definition: REveTrans.hxx:100
ROOT::Experimental::REveTrans::fA3
Float_t fA3
Definition: REveTrans.hxx:36
ROOT::Experimental::REveTrans::Orto3Column
Double_t Orto3Column(Int_t col, Int_t ref)
Orto-norm 3-vector in column col with respect to column ref.
Definition: REveTrans.cxx:837
ROOT::Experimental::REveTrans::TransposeRotationPart
void TransposeRotationPart()
Transpose 3x3 rotation sub-matrix.
Definition: REveTrans.cxx:345
TGeoHMatrix
Matrix class used for computing global transformations Should NOT be used for node definition.
Definition: TGeoMatrix.h:421
ROOT::Experimental::REveTrans::SetRotByAngles
void SetRotByAngles(Float_t a1, Float_t a2, Float_t a3)
Definition: REveTrans.cxx:573
ROOT::Experimental::REveTrans::fUseTrans
Bool_t fUseTrans
Definition: REveTrans.hxx:40
a
auto * a
Definition: textangle.C:12
ROOT::Experimental::REveTrans::Array
const Double_t * Array() const
Definition: REveTrans.hxx:99
ROOT::Experimental::REveTrans::SetFrom
void SetFrom(Double_t *carr)
Definition: REveTrans.cxx:982
Double32_t
double Double32_t
Definition: RtypesCore.h:60
ROOT::Experimental::REveTrans::SetEditRotation
void SetEditRotation(Bool_t x)
Definition: REveTrans.hxx:180
ROOT::Experimental::REveTrans::Scale
void Scale(Double_t sx, Double_t sy, Double_t sz)
Scale matrix. Translation part untouched.
Definition: REveTrans.cxx:648
ROOT::Experimental::REveTrans::SetScaleX
void SetScaleX(Double_t sx)
Change x scaling.
Definition: REveTrans.cxx:703
ROOT::Experimental::REveTrans::MultLeft
void MultLeft(const REveTrans &t)
Multiply from left: this = t * this.
Definition: REveTrans.cxx:302
ROOT::Experimental::REveTrans::MultiplyIP
void MultiplyIP(TVector3 &v, Double_t w=1) const
Multiply vector in-place.
Definition: REveTrans.cxx:730
y
Double_t y[n]
Definition: legend1.C:17
ROOT::Experimental::REveTrans::GetUseTrans
Bool_t GetUseTrans() const
Definition: REveTrans.hxx:177
ROOT::Experimental::REveTrans::SetFromArray
void SetFromArray(const Double_t arr[16])
Set matrix from Double_t array.
Definition: REveTrans.cxx:179
ROOT::Experimental::REveTrans::MoveLF
void MoveLF(Int_t ai, Double_t amount)
Move in local-frame along axis with index ai.
Definition: REveTrans.cxx:357
ROOT::Experimental::REveTrans::SetRotByAnyAngles
void SetRotByAnyAngles(Float_t a1, Float_t a2, Float_t a3, const char *pat)
Sets Rotation part as given by angles a1, a1, a3 and pattern pat.
Definition: REveTrans.cxx:603
ROOT::Experimental::REveTrans::Move3
void Move3(const REveTrans &a, Double_t x, Double_t y, Double_t z)
General move in a's coord-system.
Definition: REveTrans.cxx:446
ROOT::Experimental::REveTrans::ZeroTrans
void ZeroTrans(Double_t w=1.0)
Reset matrix to zero, only the perspective scaling is set to w (1 by default).
Definition: REveTrans.cxx:143
ROOT::Experimental::REveTrans::Multiply
TVector3 Multiply(const TVector3 &v, Double_t w=1) const
Multiply vector and return it.
Definition: REveTrans.cxx:762
ROOT::Experimental::REveTrans::SetEditScale
void SetEditScale(Bool_t x)
Definition: REveTrans.hxx:181
ROOT::Experimental::REveTrans::UnitRot
void UnitRot()
Reset rotation part of the matrix to unity.
Definition: REveTrans.cxx:154
ROOT::Experimental::REveTrans::MovePF
void MovePF(Int_t ai, Double_t amount)
Move in parent-frame along axis index ai.
Definition: REveTrans.cxx:396
Double_t
double Double_t
Definition: RtypesCore.h:59
TGeoMatrix
Geometrical transformation package.
Definition: TGeoMatrix.h:41
ROOT::Experimental::REveTrans::SetEditTrans
void SetEditTrans(Bool_t v)
Definition: REveTrans.hxx:186
ROOT::Experimental::REveTrans::fM
Double32_t fM[16]
Definition: REveTrans.hxx:32
ROOT::Experimental::REveTrans::SetScale
void SetScale(Double_t sx, Double_t sy, Double_t sz)
Set scaling.
Definition: REveTrans.cxx:689
ROOT::Experimental::REveTrans::GetPos
TVector3 GetPos() const
Definition: REveTrans.cxx:558
ROOT::Experimental::REveTrans::SetBaseVec
void SetBaseVec(Int_t b, Double_t x, Double_t y, Double_t z)
Set base-vector with index b.
Definition: REveTrans.cxx:472
ROOT::Experimental::REveTrans::fEditTrans
Bool_t fEditTrans
Definition: REveTrans.hxx:41
TObject
Mother of all ROOT objects.
Definition: TObject.h:37
ClassDef
#define ClassDef(name, id)
Definition: Rtypes.h:325
ROOT::Experimental::REveTrans::fEditScale
Bool_t fEditScale
Definition: REveTrans.hxx:43
REveVector.hxx
ROOT::Experimental::REveTrans::Invert
Double_t Invert()
Invert matrix.
Definition: REveTrans.cxx:864
ROOT::Experimental::REveTrans::ArrY
Double_t * ArrY()
Definition: REveTrans.hxx:102
ROOT::Experimental::REveTrans::operator()
Double_t & operator()(Int_t i, Int_t j)
Definition: REveTrans.hxx:116
ROOT::Experimental::REveTrans::operator[]
Double_t operator[](Int_t i) const
Definition: REveTrans.hxx:109
ROOT::Experimental::REveTrans::SetGeoHMatrix
void SetGeoHMatrix(TGeoHMatrix &mat)
Set TGeoHMatrix mat.
Definition: REveTrans.cxx:1021
ROOT::Experimental::REveTrans::ArrT
const Double_t * ArrT() const
Definition: REveTrans.hxx:107
ROOT::Experimental::REveTrans::SetScaleY
void SetScaleY(Double_t sy)
Change y scaling.
Definition: REveTrans.cxx:712
ROOT::Experimental::REveTrans::ArrT
Double_t * ArrT()
Definition: REveTrans.hxx:106
ROOT::Experimental::REveTrans::GetEditScale
Bool_t GetEditScale()
Definition: REveTrans.hxx:183
ROOT::Experimental::REveTrans::MultRight
void MultRight(const REveTrans &t)
Multiply from right: this = this * t.
Definition: REveTrans.cxx:318
ROOT::Experimental::REveTrans::SetupFromToVec
void SetupFromToVec(const REveVector &from, const REveVector &to)
A function for creating a rotation matrix that rotates a vector called "from" into another vector cal...
Definition: REveTrans.cxx:220
ROOT::Experimental::REveTrans::operator[]
Double_t & operator[](Int_t i)
Definition: REveTrans.hxx:110
ROOT::Experimental::REveTrans::~REveTrans
virtual ~REveTrans()
Definition: REveTrans.hxx:53
ROOT::Experimental::REveTrans::CM
Double_t & CM(Int_t i, Int_t j)
Definition: REveTrans.hxx:113
ROOT::Experimental::REveTrans::ArrZ
const Double_t * ArrZ() const
Definition: REveTrans.hxx:105
ROOT::Experimental::REveTrans::IsScale
Bool_t IsScale(Double_t low=0.9, Double_t high=1.1) const
Test if the transformation is a scale.
Definition: REveTrans.cxx:1075
ROOT::Experimental::REveTrans::operator*=
void operator*=(const REveTrans &t)
Definition: REveTrans.hxx:76
ROOT::Experimental::REveTrans::Print
virtual void Print(Option_t *option="") const
Print in reasonable format.
Definition: REveTrans.cxx:957
ROOT::Experimental::REveTrans::UnitTrans
void UnitTrans()
Reset matrix to unity.
Definition: REveTrans.cxx:131
ROOT::Experimental::REveTrans::fA1
Float_t fA1
Definition: REveTrans.hxx:34
ROOT
VSD Structures.
Definition: StringConv.hxx:21
ROOT::Experimental::REveTrans::GetEditRotation
Bool_t GetEditRotation()
Definition: REveTrans.hxx:182
ROOT::Experimental::REveTrans::SetupRotation
void SetupRotation(Int_t i, Int_t j, Double_t f)
Setup the matrix as an elementary rotation.
Definition: REveTrans.cxx:200
int
ROOT::Experimental::REveTrans::operator()
Double_t operator()(Int_t i, Int_t j) const
Definition: REveTrans.hxx:115
ROOT::Experimental::REveTrans::Array
Double_t * Array()
Definition: REveTrans.hxx:98