Logo ROOT   6.10/09
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 
18 class TGeoMatrix;
19 class TGeoHMatrix;
20 class TBuffer3D;
21 
22 /******************************************************************************/
23 // TEveTrans -- 3D transformation in generalised coordinates
24 /******************************************************************************/
25 
26 class TEveTrans : public TObject
27 {
28  friend class TEveTransSubEditor;
29  friend class TEveTransEditor;
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  // 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 
46  Double_t Orto3Column(Int_t col, Int_t ref);
47 
48 public:
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; }
64  void SetupRotation(Int_t i, Int_t j, Double_t f);
65  void SetupFromToVec(const TEveVector& from, const TEveVector& to);
66 
67  void OrtoNorm3();
68  Double_t Invert();
69 
70  void MultLeft(const TEveTrans& t);
71  void MultRight(const TEveTrans& t);
72  void operator*=(const TEveTrans& t) { MultRight(t); }
73 
74  void TransposeRotationPart();
75 
76  TEveTrans operator*(const TEveTrans& t);
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);
85  void Move3PF(Double_t x, Double_t y, Double_t z);
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 
111  void SetBaseVec(Int_t b, Double_t x, Double_t y, Double_t z);
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 
119  void SetPos(Double_t x, Double_t y, Double_t z);
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);
139  Double_t Unscale();
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; }
169  void SetUseTrans(Bool_t v) { fUseTrans = v; }
170 
171  void SetEditRotation(Bool_t x){ fEditRotation = x; }
172  void SetEditScale(Bool_t x) { fEditScale = x; }
175 
176  Bool_t GetEditTrans() const { return fEditTrans; }
177  void SetEditTrans(Bool_t v) { fEditTrans = v; }
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 
184 std::ostream& operator<<(std::ostream& s, const TEveTrans& t);
185 
186 #endif
TEveTrans is a 4x4 transformation matrix for homogeneous coordinates stored internally in a column-ma...
Definition: TEveTrans.h:26
void MultLeft(const TEveTrans &t)
Multiply from left: this = t * this.
Definition: TEveTrans.cxx:301
TEveTrans()
Default constructor.
Definition: TEveTrans.cxx:74
Bool_t GetEditRotation()
Definition: TEveTrans.h:173
void OrtoNorm3()
Orto-norm columns 1 to 3.
Definition: TEveTrans.cxx:848
Double_t & operator()(Int_t i, Int_t j)
Definition: TEveTrans.h:107
float Float_t
Definition: RtypesCore.h:53
const char Option_t
Definition: RtypesCore.h:62
void MultRight(const TEveTrans &t)
Multiply from right: this = this * t.
Definition: TEveTrans.cxx:317
Geometrical transformation package.
Definition: TGeoMatrix.h:38
void SetScale(Double_t sx, Double_t sy, Double_t sz)
Set scaling.
Definition: TEveTrans.cxx:688
Bool_t fUseTrans
Definition: TEveTrans.h:40
void operator*=(const TEveTrans &t)
Definition: TEveTrans.h:72
void SetScaleX(Double_t sx)
Change x scaling.
Definition: TEveTrans.cxx:702
void SetScaleZ(Double_t sz)
Change z scaling.
Definition: TEveTrans.cxx:720
Double_t & CM(Int_t i, Int_t j)
Definition: TEveTrans.h:104
Matrix class used for computing global transformations Should NOT be used for node definition...
Definition: TGeoMatrix.h:408
void UnitRot()
Reset rotation part of the matrix to unity.
Definition: TEveTrans.cxx:153
Double_t & operator[](Int_t i)
Definition: TEveTrans.h:101
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
TArc * a
Definition: textangle.C:12
TVector3 GetBaseVec(Int_t b) const
Get base-vector with index b.
Definition: TEveTrans.cxx:491
void MultiplyIP(TVector3 &v, Double_t w=1) const
Multiply vector in-place.
Definition: TEveTrans.cxx:729
const Double_t * ArrZ() const
Definition: TEveTrans.h:97
void SetUseTrans(Bool_t v)
Definition: TEveTrans.h:169
Double_t x[n]
Definition: legend1.C:17
#define ClassDef(name, id)
Definition: Rtypes.h:297
Double_t Unscale()
Remove scaling, make all base vectors of unit length.
Definition: TEveTrans.cxx:657
const Double_t * ArrX() const
Definition: TEveTrans.h:95
TEveTrans operator*(const TEveTrans &t)
Copy, multiply from right and return product.
Definition: TEveTrans.cxx:334
void Move3LF(Double_t x, Double_t y, Double_t z)
General move in local-frame.
Definition: TEveTrans.cxx:365
void SetEditScale(Bool_t x)
Definition: TEveTrans.h:172
void SetRotByAngles(Float_t a1, Float_t a2, Float_t a3)
Definition: TEveTrans.cxx:572
std::ostream & operator<<(std::ostream &s, const TEveTrans &t)
Print to std::ostream.
Definition: TEveTrans.cxx:968
Double_t Orto3Column(Int_t col, Int_t ref)
Orto-norm 3-vector in column col with respect to column ref.
Definition: TEveTrans.cxx:836
void Move(const TEveTrans &a, Int_t ai, Double_t amount)
Move in a&#39;s coord-system along axis-index ai.
Definition: TEveTrans.cxx:434
const Double_t * Array() const
Definition: TEveTrans.h:94
const Double_t * ArrY() const
Definition: TEveTrans.h:96
Bool_t GetUseTrans() const
Definition: TEveTrans.h:168
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:142
const Double_t * ArrT() const
Definition: TEveTrans.h:98
void Scale(Double_t sx, Double_t sy, Double_t sz)
Scale matrix. Translation part untouched.
Definition: TEveTrans.cxx:647
virtual void Print(Option_t *option="") const
Print in reasonable format.
Definition: TEveTrans.cxx:956
void SetScaleY(Double_t sy)
Change y scaling.
Definition: TEveTrans.cxx:711
double Double32_t
Definition: RtypesCore.h:56
Float_t fA2
Definition: TEveTrans.h:35
void SetupRotation(Int_t i, Int_t j, Double_t f)
Setup the matrix as an elementary rotation.
Definition: TEveTrans.cxx:199
void SetEditRotation(Bool_t x)
Definition: TEveTrans.h:171
void SetFrom(Double_t *carr)
Definition: TEveTrans.cxx:981
Bool_t fEditTrans
Definition: TEveTrans.h:41
Bool_t IsScale(Double_t low=0.9, Double_t high=1.1) const
Test if the transformation is a scale.
Definition: TEveTrans.cxx:1074
void RotatePF(Int_t i1, Int_t i2, Double_t amount)
Rotate in parent frame. Does optimised version of MultLeft.
Definition: TEveTrans.cxx:413
TVector3 is a general three vector class, which can be used for the description of different vectors ...
Definition: TVector3.h:22
Double_t CM(Int_t i, Int_t j) const
Definition: TEveTrans.h:103
Bool_t fEditRotation
Definition: TEveTrans.h:42
TEveTrans & operator=(const TEveTrans &t)
Definition: TEveTrans.h:63
Float_t fA1
Definition: TEveTrans.h:34
SVector< double, 2 > v
Definition: Dict.h:5
Bool_t fEditScale
Definition: TEveTrans.h:43
void RotateIP(TVector3 &v) const
Rotate vector in-place. Translation is NOT applied.
Definition: TEveTrans.cxx:781
void SetBuffer3D(TBuffer3D &buff)
Fill transformation part TBuffer3D core section.
Definition: TEveTrans.cxx:1049
void TransposeRotationPart()
Transpose 3x3 rotation sub-matrix.
Definition: TEveTrans.cxx:344
void SetBaseVec(Int_t b, Double_t x, Double_t y, Double_t z)
Set base-vector with index b.
Definition: TEveTrans.cxx:471
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:602
Editor for TEveTrans class.
Generic 3D primitive description class.
Definition: TBuffer3D.h:17
void GetScale(Double_t &sx, Double_t &sy, Double_t &sz) const
Deduce scales from sizes of base vectors.
Definition: TEveTrans.cxx:678
void SetTrans(const TEveTrans &t, Bool_t copyAngles=kTRUE)
Set matrix from another,.
Definition: TEveTrans.cxx:164
virtual ~TEveTrans()
Definition: TEveTrans.h:53
void MovePF(Int_t ai, Double_t amount)
Move in parent-frame along axis index ai.
Definition: TEveTrans.cxx:395
Bool_t fAsOK
Definition: TEveTrans.h:37
void SetPos(Double_t x, Double_t y, Double_t z)
Set position (base-vec 4).
Definition: TEveTrans.cxx:507
double f(double x)
double Double_t
Definition: RtypesCore.h:55
Sub-editor for TEveTrans class.
void MoveLF(Int_t ai, Double_t amount)
Move in local-frame along axis with index ai.
Definition: TEveTrans.cxx:356
Double_t y[n]
Definition: legend1.C:17
Double_t Invert()
Invert matrix.
Definition: TEveTrans.cxx:863
Float_t fA3
Definition: TEveTrans.h:36
TVector3 Multiply(const TVector3 &v, Double_t w=1) const
Multiply vector and return it.
Definition: TEveTrans.cxx:761
Double_t operator()(Int_t i, Int_t j) const
Definition: TEveTrans.h:106
void RotateLF(Int_t i1, Int_t i2, Double_t amount)
Rotate in local frame. Does optimised version of MultRight.
Definition: TEveTrans.cxx:375
Mother of all ROOT objects.
Definition: TObject.h:37
you should not use this method at all Int_t Int_t z
Definition: TRolke.cxx:630
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:219
you should not use this method at all Int_t Int_t Double_t Double_t Double_t Int_t Double_t Double_t Double_t Double_t b
Definition: TRolke.cxx:630
void SetGeoHMatrix(TGeoHMatrix &mat)
Set TGeoHMatrix mat.
Definition: TEveTrans.cxx:1020
void Move3(const TEveTrans &a, Double_t x, Double_t y, Double_t z)
General move in a&#39;s coord-system.
Definition: TEveTrans.cxx:445
Double32_t fM[16]
Definition: TEveTrans.h:32
void Rotate(const TEveTrans &a, Int_t i1, Int_t i2, Double_t amount)
Rotate in a&#39;s coord-system, rotating base vector with index i1 into i2.
Definition: TEveTrans.cxx:457
void SetFromArray(const Double_t arr[16])
Set matrix from Double_t array.
Definition: TEveTrans.cxx:178
Double_t Norm3Column(Int_t col)
Norm 3-vector in column col.
Definition: TEveTrans.cxx:825
Double_t operator[](Int_t i) const
Definition: TEveTrans.h:100
Bool_t GetEditScale()
Definition: TEveTrans.h:174
const Bool_t kTRUE
Definition: RtypesCore.h:91
Bool_t GetEditTrans() const
Definition: TEveTrans.h:176
void GetRotAngles(Float_t *x) const
Get Cardan rotation angles (pattern xYz above).
Definition: TEveTrans.cxx:623
void SetEditTrans(Bool_t v)
Definition: TEveTrans.h:177
void UnitTrans()
Reset matrix to unity.
Definition: TEveTrans.cxx:130
void Move3PF(Double_t x, Double_t y, Double_t z)
General move in parent-frame.
Definition: TEveTrans.cxx:403
TVector3 GetPos() const
Definition: TEveTrans.cxx:557