Logo ROOT  
Reference Guide
TEveTrans.h
Go to the documentation of this file.
1// @(#)root/eve:$Id$
2// Authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007
3
4/*************************************************************************
5 * Copyright (C) 1995-2007, 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 ROOT_TEveTrans
13#define ROOT_TEveTrans
14
15#include "TEveVector.h"
16#include "TVector3.h"
17
18class TGeoMatrix;
19class TGeoHMatrix;
20class TBuffer3D;
21
22/******************************************************************************/
23// TEveTrans -- 3D transformation in generalised coordinates
24/******************************************************************************/
25
26class TEveTrans : public TObject
27{
28 friend class TEveTransSubEditor;
29 friend class TEveTransEditor;
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 // TEveUtil
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 TEveTrans();
50 TEveTrans(const TEveTrans& t);
51 TEveTrans(const Double_t arr[16]);
52 TEveTrans(const Float_t arr[16]);
53 virtual ~TEveTrans() {}
54
55 // General operations
56
57 void UnitTrans();
58 void ZeroTrans(Double_t w=1.0);
59 void UnitRot();
60 void SetTrans(const TEveTrans& t, Bool_t copyAngles=kTRUE);
61 void SetFromArray(const Double_t arr[16]);
62 void SetFromArray(const Float_t arr[16]);
63 TEveTrans& operator=(const TEveTrans& t) { SetTrans(t); return *this; }
65 void SetupFromToVec(const TEveVector& from, const TEveVector& to);
66
67 void OrtoNorm3();
69
70 void MultLeft(const TEveTrans& t);
71 void MultRight(const TEveTrans& t);
72 void operator*=(const TEveTrans& t) { MultRight(t); }
73
75
77
78 // Move & Rotate
79
80 void MoveLF(Int_t ai, Double_t amount);
82 void RotateLF(Int_t i1, Int_t i2, Double_t amount);
83
84 void MovePF(Int_t ai, Double_t amount);
86 void RotatePF(Int_t i1, Int_t i2, Double_t amount);
87
88 void Move(const TEveTrans& a, Int_t ai, Double_t amount);
89 void Move3(const TEveTrans& a, Double_t x, Double_t y, Double_t z);
90 void Rotate(const TEveTrans& a, Int_t i1, Int_t i2, Double_t amount);
91
92 // Element access
93
94 Double_t* Array() { return fM; } const Double_t* Array() const { return fM; }
95 Double_t* ArrX() { return fM; } const Double_t* ArrX() const { return fM; }
96 Double_t* ArrY() { return fM + 4; } const Double_t* ArrY() const { return fM + 4; }
97 Double_t* ArrZ() { return fM + 8; } const Double_t* ArrZ() const { return fM + 8; }
98 Double_t* ArrT() { return fM + 12; } const Double_t* ArrT() const { return fM + 12; }
99
100 Double_t operator[](Int_t i) const { return fM[i]; }
101 Double_t& operator[](Int_t i) { return fM[i]; }
102
103 Double_t CM(Int_t i, Int_t j) const { return fM[4*j + i]; }
104 Double_t& CM(Int_t i, Int_t j) { return fM[4*j + i]; }
105
106 Double_t operator()(Int_t i, Int_t j) const { return fM[4*j + i - 5]; }
107 Double_t& operator()(Int_t i, Int_t j) { return fM[4*j + i - 5]; }
108
109 // Base-vector interface
110
112 void SetBaseVec(Int_t b, const TVector3& v);
113
114 TVector3 GetBaseVec(Int_t b) const;
115 void GetBaseVec(Int_t b, TVector3& v) const;
116
117 // Position interface
118
120 void SetPos(Double_t* x);
121 void SetPos(Float_t * x);
122 void SetPos(const TEveTrans& t);
123
124 void GetPos(Double_t& x, Double_t& y, Double_t& z) const;
125 void GetPos(Double_t* x) const;
126 void GetPos(Float_t * x) const;
127 void GetPos(TVector3& v) const;
128 TVector3 GetPos() const;
129
130 // Cardan angle interface
131
132 void SetRotByAngles(Float_t a1, Float_t a2, Float_t a3);
133 void SetRotByAnyAngles(Float_t a1, Float_t a2, Float_t a3, const char* pat);
134 void GetRotAngles(Float_t* x) const;
135
136 // Scaling
137
138 void Scale(Double_t sx, Double_t sy, Double_t sz);
140 void Unscale(Double_t& sx, Double_t& sy, Double_t& sz);
141 void GetScale(Double_t& sx, Double_t& sy, Double_t& sz) const;
142 void SetScale(Double_t sx, Double_t sy, Double_t sz);
143 void SetScaleX(Double_t sx);
144 void SetScaleY(Double_t sy);
145 void SetScaleZ(Double_t sz);
146
147 // Operations on vectors
148
149 void MultiplyIP(TVector3& v, Double_t w=1) const;
150 void MultiplyIP(Double_t* v, Double_t w=1) const;
151 void MultiplyIP(Float_t* v, Double_t w=1) const;
152 TVector3 Multiply(const TVector3& v, Double_t w=1) const;
153 void Multiply(const Double_t *vin, Double_t* vout, Double_t w=1) const;
154 void RotateIP(TVector3& v) const;
155 void RotateIP(Double_t* v) const;
156 void RotateIP(Float_t* v) const;
157 TVector3 Rotate(const TVector3& v) const;
158
159 virtual void Print(Option_t* option = "") const;
160
161 // TEveUtil stuff
162
163 void SetFrom(Double_t* carr);
164 void SetFrom(const TGeoMatrix& mat);
165 void SetGeoHMatrix(TGeoHMatrix& mat);
166 void SetBuffer3D(TBuffer3D& buff);
167
168 Bool_t GetUseTrans() const { return fUseTrans; }
170
175
176 Bool_t GetEditTrans() const { return fEditTrans; }
178
179 Bool_t IsScale(Double_t low=0.9, Double_t high=1.1) const;
180
181 ClassDef(TEveTrans, 1); // Column-major 4x4 transforamtion matrix for homogeneous coordinates.
182};
183
184std::ostream& operator<<(std::ostream& s, const TEveTrans& t);
185
186#endif
#define b(i)
Definition: RSha256.hxx:100
#define f(i)
Definition: RSha256.hxx:104
double Double32_t
Definition: RtypesCore.h:60
int Int_t
Definition: RtypesCore.h:45
bool Bool_t
Definition: RtypesCore.h:63
double Double_t
Definition: RtypesCore.h:59
float Float_t
Definition: RtypesCore.h:57
const Bool_t kTRUE
Definition: RtypesCore.h:100
const char Option_t
Definition: RtypesCore.h:66
#define ClassDef(name, id)
Definition: Rtypes.h:325
std::ostream & operator<<(std::ostream &s, const TEveTrans &t)
Print to std::ostream.
Definition: TEveTrans.cxx:967
Generic 3D primitive description class.
Definition: TBuffer3D.h:18
Editor for TEveTrans class.
Sub-editor for TEveTrans class.
TEveTrans is a 4x4 transformation matrix for homogeneous coordinates stored internally in a column-ma...
Definition: TEveTrans.h:27
void SetGeoHMatrix(TGeoHMatrix &mat)
Set TGeoHMatrix mat.
Definition: TEveTrans.cxx:1019
void OrtoNorm3()
Orto-norm columns 1 to 3.
Definition: TEveTrans.cxx:847
virtual ~TEveTrans()
Definition: TEveTrans.h:53
void MultLeft(const TEveTrans &t)
Multiply from left: this = t * this.
Definition: TEveTrans.cxx:300
void UnitRot()
Reset rotation part of the matrix to unity.
Definition: TEveTrans.cxx:152
Bool_t fAsOK
Definition: TEveTrans.h:37
Bool_t IsScale(Double_t low=0.9, Double_t high=1.1) const
Test if the transformation is a scale.
Definition: TEveTrans.cxx:1073
void SetBaseVec(Int_t b, Double_t x, Double_t y, Double_t z)
Set base-vector with index b.
Definition: TEveTrans.cxx:470
Double_t Orto3Column(Int_t col, Int_t ref)
Orto-norm 3-vector in column col with respect to column ref.
Definition: TEveTrans.cxx:835
void SetUseTrans(Bool_t v)
Definition: TEveTrans.h:169
Float_t fA3
Definition: TEveTrans.h:36
void MoveLF(Int_t ai, Double_t amount)
Move in local-frame along axis with index ai.
Definition: TEveTrans.cxx:355
Float_t fA2
Definition: TEveTrans.h:35
Double_t operator()(Int_t i, Int_t j) const
Definition: TEveTrans.h:106
TEveTrans operator*(const TEveTrans &t)
Copy, multiply from right and return product.
Definition: TEveTrans.cxx:333
TEveTrans()
Default constructor.
Definition: TEveTrans.cxx:73
void Move(const TEveTrans &a, Int_t ai, Double_t amount)
Move in a's coord-system along axis-index ai.
Definition: TEveTrans.cxx:433
Bool_t GetEditScale()
Definition: TEveTrans.h:174
Double_t * ArrT()
Definition: TEveTrans.h:98
void SetFromArray(const Double_t arr[16])
Set matrix from Double_t array.
Definition: TEveTrans.cxx:177
Bool_t fUseTrans
Definition: TEveTrans.h:40
Bool_t fEditRotation
Definition: TEveTrans.h:42
void Scale(Double_t sx, Double_t sy, Double_t sz)
Scale matrix. Translation part untouched.
Definition: TEveTrans.cxx:646
Double_t & CM(Int_t i, Int_t j)
Definition: TEveTrans.h:104
void Rotate(const TEveTrans &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: TEveTrans.cxx:456
void MultRight(const TEveTrans &t)
Multiply from right: this = this * t.
Definition: TEveTrans.cxx:316
void RotateIP(TVector3 &v) const
Rotate vector in-place. Translation is NOT applied.
Definition: TEveTrans.cxx:780
Double_t * ArrY()
Definition: TEveTrans.h:96
void SetEditRotation(Bool_t x)
Definition: TEveTrans.h:171
TVector3 GetBaseVec(Int_t b) const
Get base-vector with index b.
Definition: TEveTrans.cxx:490
TVector3 Multiply(const TVector3 &v, Double_t w=1) const
Multiply vector and return it.
Definition: TEveTrans.cxx:760
void Move3(const TEveTrans &a, Double_t x, Double_t y, Double_t z)
General move in a's coord-system.
Definition: TEveTrans.cxx:444
void RotatePF(Int_t i1, Int_t i2, Double_t amount)
Rotate in parent frame. Does optimised version of MultLeft.
Definition: TEveTrans.cxx:412
void operator*=(const TEveTrans &t)
Definition: TEveTrans.h:72
Bool_t fEditScale
Definition: TEveTrans.h:43
void SetScale(Double_t sx, Double_t sy, Double_t sz)
Set scaling.
Definition: TEveTrans.cxx:687
void SetRotByAngles(Float_t a1, Float_t a2, Float_t a3)
Definition: TEveTrans.cxx:571
void SetScaleX(Double_t sx)
Change x scaling.
Definition: TEveTrans.cxx:701
void RotateLF(Int_t i1, Int_t i2, Double_t amount)
Rotate in local frame. Does optimised version of MultRight.
Definition: TEveTrans.cxx:374
void UnitTrans()
Reset matrix to unity.
Definition: TEveTrans.cxx:129
void SetScaleY(Double_t sy)
Change y scaling.
Definition: TEveTrans.cxx:710
Double_t Norm3Column(Int_t col)
Norm 3-vector in column col.
Definition: TEveTrans.cxx:824
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: TEveTrans.cxx:601
void SetupFromToVec(const TEveVector &from, const TEveVector &to)
A function for creating a rotation matrix that rotates a vector called "from" into another vector cal...
Definition: TEveTrans.cxx:218
Double_t & operator()(Int_t i, Int_t j)
Definition: TEveTrans.h:107
TEveTrans & operator=(const TEveTrans &t)
Definition: TEveTrans.h:63
void SetEditScale(Bool_t x)
Definition: TEveTrans.h:172
void MovePF(Int_t ai, Double_t amount)
Move in parent-frame along axis index ai.
Definition: TEveTrans.cxx:394
Double_t Invert()
Invert matrix.
Definition: TEveTrans.cxx:862
virtual void Print(Option_t *option="") const
Print in reasonable format.
Definition: TEveTrans.cxx:955
Bool_t GetUseTrans() const
Definition: TEveTrans.h:168
Float_t fA1
Definition: TEveTrans.h:34
void SetEditTrans(Bool_t v)
Definition: TEveTrans.h:177
void Move3LF(Double_t x, Double_t y, Double_t z)
General move in local-frame.
Definition: TEveTrans.cxx:364
TVector3 GetPos() const
Definition: TEveTrans.cxx:556
Double_t & operator[](Int_t i)
Definition: TEveTrans.h:101
Double32_t fM[16]
Definition: TEveTrans.h:32
Bool_t GetEditTrans() const
Definition: TEveTrans.h:176
void TransposeRotationPart()
Transpose 3x3 rotation sub-matrix.
Definition: TEveTrans.cxx:343
void SetupRotation(Int_t i, Int_t j, Double_t f)
Setup the matrix as an elementary rotation.
Definition: TEveTrans.cxx:198
void SetBuffer3D(TBuffer3D &buff)
Fill transformation part TBuffer3D core section.
Definition: TEveTrans.cxx:1048
void GetScale(Double_t &sx, Double_t &sy, Double_t &sz) const
Deduce scales from sizes of base vectors.
Definition: TEveTrans.cxx:677
void MultiplyIP(TVector3 &v, Double_t w=1) const
Multiply vector in-place.
Definition: TEveTrans.cxx:728
Double_t Unscale()
Remove scaling, make all base vectors of unit length.
Definition: TEveTrans.cxx:656
void SetFrom(Double_t *carr)
Definition: TEveTrans.cxx:980
void SetTrans(const TEveTrans &t, Bool_t copyAngles=kTRUE)
Set matrix from another,.
Definition: TEveTrans.cxx:163
Bool_t fEditTrans
Definition: TEveTrans.h:41
void Move3PF(Double_t x, Double_t y, Double_t z)
General move in parent-frame.
Definition: TEveTrans.cxx:402
Double_t * ArrZ()
Definition: TEveTrans.h:97
Double_t * Array()
Definition: TEveTrans.h:94
void SetScaleZ(Double_t sz)
Change z scaling.
Definition: TEveTrans.cxx:719
void GetRotAngles(Float_t *x) const
Get Cardan rotation angles (pattern xYz above).
Definition: TEveTrans.cxx:622
void SetPos(Double_t x, Double_t y, Double_t z)
Set position (base-vec 4).
Definition: TEveTrans.cxx:506
Double_t * ArrX()
Definition: TEveTrans.h:95
Double_t CM(Int_t i, Int_t j) const
Definition: TEveTrans.h:103
Bool_t GetEditRotation()
Definition: TEveTrans.h:173
void ZeroTrans(Double_t w=1.0)
Reset matrix to zero, only the perspective scaling is set to w (1 by default).
Definition: TEveTrans.cxx:141
Double_t operator[](Int_t i) const
Definition: TEveTrans.h:100
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
Double_t y[n]
Definition: legend1.C:17
Double_t x[n]
Definition: legend1.C:17
static constexpr double s
auto * a
Definition: textangle.C:12