Logo ROOT   6.18/05
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
SVector< double, 2 > v
Definition: Dict.h:5
#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
std::ostream & operator<<(std::ostream &s, const TEveTrans &t)
Print to std::ostream.
Definition: TEveTrans.cxx:968
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:1020
void OrtoNorm3()
Orto-norm columns 1 to 3.
Definition: TEveTrans.cxx:848
virtual ~TEveTrans()
Definition: TEveTrans.h:53
void MultLeft(const TEveTrans &t)
Multiply from left: this = t * this.
Definition: TEveTrans.cxx:301
void UnitRot()
Reset rotation part of the matrix to unity.
Definition: TEveTrans.cxx:153
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:1074
void SetBaseVec(Int_t b, Double_t x, Double_t y, Double_t z)
Set base-vector with index b.
Definition: TEveTrans.cxx:471
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 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:356
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:334
TEveTrans()
Default constructor.
Definition: TEveTrans.cxx:74
void Move(const TEveTrans &a, Int_t ai, Double_t amount)
Move in a's coord-system along axis-index ai.
Definition: TEveTrans.cxx:434
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:178
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:647
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:457
void MultRight(const TEveTrans &t)
Multiply from right: this = this * t.
Definition: TEveTrans.cxx:317
void RotateIP(TVector3 &v) const
Rotate vector in-place. Translation is NOT applied.
Definition: TEveTrans.cxx:781
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:491
TVector3 Multiply(const TVector3 &v, Double_t w=1) const
Multiply vector and return it.
Definition: TEveTrans.cxx:761
void Move3(const TEveTrans &a, Double_t x, Double_t y, Double_t z)
General move in a's coord-system.
Definition: TEveTrans.cxx:445
void RotatePF(Int_t i1, Int_t i2, Double_t amount)
Rotate in parent frame. Does optimised version of MultLeft.
Definition: TEveTrans.cxx:413
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:688
void SetRotByAngles(Float_t a1, Float_t a2, Float_t a3)
Definition: TEveTrans.cxx:572
void SetScaleX(Double_t sx)
Change x scaling.
Definition: TEveTrans.cxx:702
void RotateLF(Int_t i1, Int_t i2, Double_t amount)
Rotate in local frame. Does optimised version of MultRight.
Definition: TEveTrans.cxx:375
void UnitTrans()
Reset matrix to unity.
Definition: TEveTrans.cxx:130
void SetScaleY(Double_t sy)
Change y scaling.
Definition: TEveTrans.cxx:711
Double_t Norm3Column(Int_t col)
Norm 3-vector in column col.
Definition: TEveTrans.cxx:825
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
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
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:395
Double_t Invert()
Invert matrix.
Definition: TEveTrans.cxx:863
virtual void Print(Option_t *option="") const
Print in reasonable format.
Definition: TEveTrans.cxx:956
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:365
TVector3 GetPos() const
Definition: TEveTrans.cxx:557
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:344
void SetupRotation(Int_t i, Int_t j, Double_t f)
Setup the matrix as an elementary rotation.
Definition: TEveTrans.cxx:199
void SetBuffer3D(TBuffer3D &buff)
Fill transformation part TBuffer3D core section.
Definition: TEveTrans.cxx:1049
void GetScale(Double_t &sx, Double_t &sy, Double_t &sz) const
Deduce scales from sizes of base vectors.
Definition: TEveTrans.cxx:678
void MultiplyIP(TVector3 &v, Double_t w=1) const
Multiply vector in-place.
Definition: TEveTrans.cxx:729
Double_t Unscale()
Remove scaling, make all base vectors of unit length.
Definition: TEveTrans.cxx:657
void SetFrom(Double_t *carr)
Definition: TEveTrans.cxx:981
void SetTrans(const TEveTrans &t, Bool_t copyAngles=kTRUE)
Set matrix from another,.
Definition: TEveTrans.cxx:164
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:403
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:720
void GetRotAngles(Float_t *x) const
Get Cardan rotation angles (pattern xYz above).
Definition: TEveTrans.cxx:623
void SetPos(Double_t x, Double_t y, Double_t z)
Set position (base-vec 4).
Definition: TEveTrans.cxx:507
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:142
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
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
static constexpr double s
auto * a
Definition: textangle.C:12