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 f(i)
Definition: RSha256.hxx:104
bool Bool_t
Definition: RtypesCore.h:63
float Float_t
Definition: RtypesCore.h:57
const Bool_t kTRUE
Definition: RtypesCore.h:100
const char Option_t
Definition: RtypesCore.h:66
Option_t Option_t option
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t b
REveTrans operator*(const REveTrans &t)
Copy, multiply from right and return product.
Definition: REveTrans.cxx:332
const Double_t * ArrT() const
Definition: REveTrans.hxx:107
void UnitRot()
Reset rotation part of the matrix to unity.
Definition: REveTrans.cxx:151
void SetBuffer3D(TBuffer3D &buff)
Fill transformation part TBuffer3D core section.
Definition: REveTrans.cxx:1047
void SetupRotation(Int_t i, Int_t j, Double_t f)
Setup the matrix as an elementary rotation.
Definition: REveTrans.cxx:197
Double_t Norm3Column(Int_t col)
Norm 3-vector in column col.
Definition: REveTrans.cxx:823
virtual void Print(Option_t *option="") const
Print in reasonable format.
Definition: REveTrans.cxx:954
void SetScaleY(Double_t sy)
Change y scaling.
Definition: REveTrans.cxx:709
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:411
Double_t Invert()
Invert matrix.
Definition: REveTrans.cxx:861
void MultiplyIP(TVector3 &v, Double_t w=1) const
Multiply vector in-place.
Definition: REveTrans.cxx:727
void RotateLF(Int_t i1, Int_t i2, Double_t amount)
Rotate in local frame. Does optimised version of MultRight.
Definition: REveTrans.cxx:373
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:676
REveTrans()
Default constructor.
Definition: REveTrans.cxx:72
void TransposeRotationPart()
Transpose 3x3 rotation sub-matrix.
Definition: REveTrans.cxx:342
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:140
void Move3PF(Double_t x, Double_t y, Double_t z)
General move in parent-frame.
Definition: REveTrans.cxx:401
void SetTrans(const REveTrans &t, Bool_t copyAngles=kTRUE)
Set matrix from another,.
Definition: REveTrans.cxx:162
void SetFromArray(const Double_t arr[16])
Set matrix from Double_t array.
Definition: REveTrans.cxx:176
void MovePF(Int_t ai, Double_t amount)
Move in parent-frame along axis index ai.
Definition: REveTrans.cxx:393
void SetBaseVec(Int_t b, Double_t x, Double_t y, Double_t z)
Set base-vector with index b.
Definition: REveTrans.cxx:469
void SetScaleX(Double_t sx)
Change x scaling.
Definition: REveTrans.cxx:700
void MoveLF(Int_t ai, Double_t amount)
Move in local-frame along axis with index ai.
Definition: REveTrans.cxx:354
Double_t Orto3Column(Int_t col, Int_t ref)
Orto-norm 3-vector in column col with respect to column ref.
Definition: REveTrans.cxx:834
Double_t operator()(Int_t i, Int_t j) const
Definition: REveTrans.hxx:115
void SetGeoHMatrix(TGeoHMatrix &mat)
Set TGeoHMatrix mat.
Definition: REveTrans.cxx:1018
void SetScale(Double_t sx, Double_t sy, Double_t sz)
Set scaling.
Definition: REveTrans.cxx:686
void OrtoNorm3()
Orto-norm columns 1 to 3.
Definition: REveTrans.cxx:846
void Move(const REveTrans &a, Int_t ai, Double_t amount)
Move in a's coord-system along axis-index ai.
Definition: REveTrans.cxx:432
void SetFrom(Double_t *carr)
Definition: REveTrans.cxx:979
void Move3LF(Double_t x, Double_t y, Double_t z)
General move in local-frame.
Definition: REveTrans.cxx:363
void GetRotAngles(Float_t *x) const
Get Cardan rotation angles (pattern xYz above).
Definition: REveTrans.cxx:621
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:217
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:759
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:505
void Scale(Double_t sx, Double_t sy, Double_t sz)
Scale matrix. Translation part untouched.
Definition: REveTrans.cxx:645
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:128
Bool_t IsScale(Double_t low=0.9, Double_t high=1.1) const
Test if the transformation is a scale.
Definition: REveTrans.cxx:1072
void Move3(const REveTrans &a, Double_t x, Double_t y, Double_t z)
General move in a's coord-system.
Definition: REveTrans.cxx:443
void RotateIP(TVector3 &v) const
Rotate vector in-place. Translation is NOT applied.
Definition: REveTrans.cxx:779
void MultRight(const REveTrans &t)
Multiply from right: this = this * t.
Definition: REveTrans.cxx:315
Double_t Unscale()
Remove scaling, make all base vectors of unit length.
Definition: REveTrans.cxx:655
void SetScaleZ(Double_t sz)
Change z scaling.
Definition: REveTrans.cxx:718
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:600
void SetRotByAngles(Float_t a1, Float_t a2, Float_t a3)
Definition: REveTrans.cxx:570
void MultLeft(const REveTrans &t)
Multiply from left: this = t * this.
Definition: REveTrans.cxx:299
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:489
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:455
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:41
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)
This file contains a specialised ROOT message handler to test for diagnostic in unit tests.
static constexpr double s
TArc a
Definition: textangle.C:12