ROOT   Reference Guide
REveTrans.hxx
Go to the documentation of this file.
1// @(#)root/eve7:$Id$
3
4/*************************************************************************
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
18class TGeoMatrix;
19class TGeoHMatrix;
20class TBuffer3D;
21
22namespace ROOT {
23namespace Experimental {
24
25/******************************************************************************/
26// REveTrans -- 3D transformation in generalised coordinates
27/******************************************************************************/
28
29class REveTrans : public TObject
30{
31protected:
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
47
48public:
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 }
69 void SetupFromToVec(const REveVector &from, const REveVector &to);
70
71 void OrtoNorm3();
73
74 void MultLeft(const REveTrans &t);
75 void MultRight(const REveTrans &t);
76 void operator*=(const REveTrans &t) { MultRight(t); }
77
79
81
82 // Move & Rotate
83
84 void MoveLF(Int_t ai, Double_t amount);
86 void RotateLF(Int_t i1, Int_t i2, Double_t amount);
87
88 void MovePF(Int_t ai, Double_t amount);
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
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);
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
193std::ostream &operator<<(std::ostream &s, const REveTrans &t);
194
195} // namespace Experimental
196} // namespace ROOT
197
198#endif
#define b(i)
Definition: RSha256.hxx:100
#define f(i)
Definition: RSha256.hxx:104
double Double32_t
Definition: RtypesCore.h:56
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
double Double_t
Definition: RtypesCore.h:55
float Float_t
Definition: RtypesCore.h:53
const Bool_t kTRUE
Definition: RtypesCore.h:87
const char Option_t
Definition: RtypesCore.h:62
#define ClassDef(name, id)
Definition: Rtypes.h:326
REveTrans operator*(const REveTrans &t)
Copy, multiply from right and return product.
Definition: REveTrans.cxx:335
const Double_t * ArrT() const
Definition: REveTrans.hxx:107
void UnitRot()
Reset rotation part of the matrix to unity.
Definition: REveTrans.cxx:154
void SetBuffer3D(TBuffer3D &buff)
Fill transformation part TBuffer3D core section.
Definition: REveTrans.cxx:1050
void SetupRotation(Int_t i, Int_t j, Double_t f)
Setup the matrix as an elementary rotation.
Definition: REveTrans.cxx:200
Double_t Norm3Column(Int_t col)
Norm 3-vector in column col.
Definition: REveTrans.cxx:826
virtual void Print(Option_t *option="") const
Print in reasonable format.
Definition: REveTrans.cxx:957
void SetScaleY(Double_t sy)
Change y scaling.
Definition: REveTrans.cxx:712
void SetEditRotation(Bool_t x)
Definition: REveTrans.hxx:180
void RotatePF(Int_t i1, Int_t i2, Double_t amount)
Rotate in parent frame. Does optimised version of MultLeft.
Definition: REveTrans.cxx:414
Double_t Invert()
Invert matrix.
Definition: REveTrans.cxx:864
void MultiplyIP(TVector3 &v, Double_t w=1) const
Multiply vector in-place.
Definition: REveTrans.cxx:730
void RotateLF(Int_t i1, Int_t i2, Double_t amount)
Rotate in local frame. Does optimised version of MultRight.
Definition: REveTrans.cxx:376
void operator*=(const REveTrans &t)
Definition: REveTrans.hxx:76
Double_t & CM(Int_t i, Int_t j)
Definition: REveTrans.hxx:113
const Double_t * ArrX() const
Definition: REveTrans.hxx:101
void GetScale(Double_t &sx, Double_t &sy, Double_t &sz) const
Deduce scales from sizes of base vectors.
Definition: REveTrans.cxx:679
REveTrans()
Default constructor.
Definition: REveTrans.cxx:75
void TransposeRotationPart()
Transpose 3x3 rotation sub-matrix.
Definition: REveTrans.cxx:345
Double_t & operator[](Int_t i)
Definition: REveTrans.hxx:110
REveTrans & operator=(const REveTrans &t)
Definition: REveTrans.hxx:63
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
void Move3PF(Double_t x, Double_t y, Double_t z)
General move in parent-frame.
Definition: REveTrans.cxx:404
void SetTrans(const REveTrans &t, Bool_t copyAngles=kTRUE)
Set matrix from another,.
Definition: REveTrans.cxx:165
void SetFromArray(const Double_t arr[16])
Set matrix from Double_t array.
Definition: REveTrans.cxx:179
void MovePF(Int_t ai, Double_t amount)
Move in parent-frame along axis index ai.
Definition: REveTrans.cxx:396
void SetBaseVec(Int_t b, Double_t x, Double_t y, Double_t z)
Set base-vector with index b.
Definition: REveTrans.cxx:472
void SetScaleX(Double_t sx)
Change x scaling.
Definition: REveTrans.cxx:703
void MoveLF(Int_t ai, Double_t amount)
Move in local-frame along axis with index ai.
Definition: REveTrans.cxx:357
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
Double_t operator()(Int_t i, Int_t j) const
Definition: REveTrans.hxx:115
void SetGeoHMatrix(TGeoHMatrix &mat)
Set TGeoHMatrix mat.
Definition: REveTrans.cxx:1021
void SetScale(Double_t sx, Double_t sy, Double_t sz)
Set scaling.
Definition: REveTrans.cxx:689
void OrtoNorm3()
Orto-norm columns 1 to 3.
Definition: REveTrans.cxx:849
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
void SetFrom(Double_t *carr)
Definition: REveTrans.cxx:982
void Move3LF(Double_t x, Double_t y, Double_t z)
General move in local-frame.
Definition: REveTrans.cxx:366
void GetRotAngles(Float_t *x) const
Get Cardan rotation angles (pattern xYz above).
Definition: REveTrans.cxx:624
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
Double_t CM(Int_t i, Int_t j) const
Definition: REveTrans.hxx:112
TVector3 Multiply(const TVector3 &v, Double_t w=1) const
Multiply vector and return it.
Definition: REveTrans.cxx:762
const Double_t * Array() const
Definition: REveTrans.hxx:99
const Double_t * ArrZ() const
Definition: REveTrans.hxx:105
void SetPos(Double_t x, Double_t y, Double_t z)
Set position (base-vec 4).
Definition: REveTrans.cxx:508
void Scale(Double_t sx, Double_t sy, Double_t sz)
Scale matrix. Translation part untouched.
Definition: REveTrans.cxx:648
const Double_t * ArrY() const
Definition: REveTrans.hxx:103
Double_t & operator()(Int_t i, Int_t j)
Definition: REveTrans.hxx:116
void UnitTrans()
Reset matrix to unity.
Definition: REveTrans.cxx:131
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
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
void RotateIP(TVector3 &v) const
Rotate vector in-place. Translation is NOT applied.
Definition: REveTrans.cxx:782
void MultRight(const REveTrans &t)
Multiply from right: this = this * t.
Definition: REveTrans.cxx:318
Double_t Unscale()
Remove scaling, make all base vectors of unit length.
Definition: REveTrans.cxx:658
void SetScaleZ(Double_t sz)
Change z scaling.
Definition: REveTrans.cxx:721
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
void SetRotByAngles(Float_t a1, Float_t a2, Float_t a3)
Definition: REveTrans.cxx:573
void MultLeft(const REveTrans &t)
Multiply from left: this = t * this.
Definition: REveTrans.cxx:302
Double_t operator[](Int_t i) const
Definition: REveTrans.hxx:109
TVector3 GetBaseVec(Int_t b) const
Get base-vector with index b.
Definition: REveTrans.cxx:492
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
Generic 3D primitive description class.
Definition: TBuffer3D.h:18
Matrix class used for computing global transformations Should NOT be used for node definition.
Definition: TGeoMatrix.h:421
Geometrical transformation package.
Definition: TGeoMatrix.h:41
Mother of all ROOT objects.
Definition: TObject.h:37
TVector3 is a general three vector class, which can be used for the description of different vectors ...
Definition: TVector3.h:22
Double_t y[n]
Definition: legend1.C:17
Double_t x[n]
Definition: legend1.C:17
std::ostream & operator<<(std::ostream &s, const REveTrans &t)
VSD Structures.
Definition: StringConv.hxx:21
static constexpr double s
auto * a
Definition: textangle.C:12