Logo ROOT  
Reference Guide
No Matches
Go to the documentation of this file.
1// @(#)root/eve:$Id$
2// Authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007
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 *************************************************************************/
12#ifndef ROOT_TEveTrans
13#define ROOT_TEveTrans
15#include "TEveVector.h"
16#include "TVector3.h"
18class TGeoMatrix;
19class TGeoHMatrix;
20class TBuffer3D;
23// TEveTrans -- 3D transformation in generalised coordinates
26class TEveTrans : public TObject
28 friend class TEveTransSubEditor;
29 friend class TEveTransEditor;
34 mutable Float_t fA1; //!
35 mutable Float_t fA2; //!
36 mutable Float_t fA3; //!
37 mutable Bool_t fAsOK; //!
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
49 TEveTrans();
50 TEveTrans(const TEveTrans& t);
51 TEveTrans(const Double_t arr[16]);
52 TEveTrans(const Float_t arr[16]);
53 ~TEveTrans() override {}
55 // General operations
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);
67 void OrtoNorm3();
70 void MultLeft(const TEveTrans& t);
71 void MultRight(const TEveTrans& t);
72 void operator*=(const TEveTrans& t) { MultRight(t); }
78 // Move & Rotate
80 void MoveLF(Int_t ai, Double_t amount);
82 void RotateLF(Int_t i1, Int_t i2, Double_t amount);
84 void MovePF(Int_t ai, Double_t amount);
86 void RotatePF(Int_t i1, Int_t i2, Double_t amount);
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);
92 // Element access
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; }
100 Double_t operator[](Int_t i) const { return fM[i]; }
101 Double_t& operator[](Int_t i) { return fM[i]; }
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]; }
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]; }
109 // Base-vector interface
112 void SetBaseVec(Int_t b, const TVector3& v);
114 TVector3 GetBaseVec(Int_t b) const;
115 void GetBaseVec(Int_t b, TVector3& v) const;
117 // Position interface
120 void SetPos(Double_t* x);
121 void SetPos(Float_t * x);
122 void SetPos(const TEveTrans& t);
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;
130 // Cardan angle interface
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;
136 // Scaling
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);
147 // Operations on vectors
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;
159 void Print(Option_t* option = "") const override;
161 // TEveUtil stuff
163 void SetFrom(Double_t* carr);
164 void SetFrom(const TGeoMatrix& mat);
165 void SetGeoHMatrix(TGeoHMatrix& mat);
166 void SetBuffer3D(TBuffer3D& buff);
168 Bool_t GetUseTrans() const { return fUseTrans; }
176 Bool_t GetEditTrans() const { return fEditTrans; }
179 Bool_t IsScale(Double_t low=0.9, Double_t high=1.1) const;
181 ClassDefOverride(TEveTrans, 1); // Column-major 4x4 transforamtion matrix for homogeneous coordinates.
184std::ostream& operator<<(std::ostream& s, const TEveTrans& t);
#define b(i)
Definition RSha256.hxx:100
#define f(i)
Definition RSha256.hxx:104
#define a(i)
Definition RSha256.hxx:99
bool Bool_t
Definition RtypesCore.h:63
int Int_t
Definition RtypesCore.h:45
float Float_t
Definition RtypesCore.h:57
double Double_t
Definition RtypesCore.h:59
constexpr Bool_t kTRUE
Definition RtypesCore.h:100
const char Option_t
Definition RtypesCore.h:66
TBuffer & operator<<(TBuffer &buf, const Tmpl *obj)
Definition TBuffer.h:397
#define ClassDefOverride(name, id)
Definition Rtypes.h:341
Option_t Option_t option
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.
void OrtoNorm3()
Orto-norm columns 1 to 3.
void MultLeft(const TEveTrans &t)
Multiply from left: this = t * this.
void UnitRot()
Reset rotation part of the matrix to unity.
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.
void SetBaseVec(Int_t b, Double_t x, Double_t y, Double_t z)
Set base-vector with index b.
Double_t Orto3Column(Int_t col, Int_t ref)
Orto-norm 3-vector in column col with respect to column ref.
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.
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.
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.
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.
Bool_t fUseTrans
Definition TEveTrans.h:40
void Print(Option_t *option="") const override
Print in reasonable format.
Bool_t fEditRotation
Definition TEveTrans.h:42
void Scale(Double_t sx, Double_t sy, Double_t sz)
Scale matrix. Translation part untouched.
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.
void MultRight(const TEveTrans &t)
Multiply from right: this = this * t.
void RotateIP(TVector3 &v) const
Rotate vector in-place. Translation is NOT applied.
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.
TVector3 Multiply(const TVector3 &v, Double_t w=1) const
Multiply vector and return it.
void Move3(const TEveTrans &a, Double_t x, Double_t y, Double_t z)
General move in a's coord-system.
void RotatePF(Int_t i1, Int_t i2, Double_t amount)
Rotate in parent frame. Does optimised version of MultLeft.
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.
void SetRotByAngles(Float_t a1, Float_t a2, Float_t a3)
void SetScaleX(Double_t sx)
Change x scaling.
void RotateLF(Int_t i1, Int_t i2, Double_t amount)
Rotate in local frame. Does optimised version of MultRight.
void UnitTrans()
Reset matrix to unity.
void SetScaleY(Double_t sy)
Change y scaling.
Double_t Norm3Column(Int_t col)
Norm 3-vector in column col.
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.
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...
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.
Double_t Invert()
Invert matrix.
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.
TVector3 GetPos() const
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.
void SetupRotation(Int_t i, Int_t j, Double_t f)
Setup the matrix as an elementary rotation.
~TEveTrans() override
Definition TEveTrans.h:53
void SetBuffer3D(TBuffer3D &buff)
Fill transformation part TBuffer3D core section.
void GetScale(Double_t &sx, Double_t &sy, Double_t &sz) const
Deduce scales from sizes of base vectors.
void MultiplyIP(TVector3 &v, Double_t w=1) const
Multiply vector in-place.
Double_t Unscale()
Remove scaling, make all base vectors of unit length.
void SetFrom(Double_t *carr)
void SetTrans(const TEveTrans &t, Bool_t copyAngles=kTRUE)
Set matrix from another,.
Bool_t fEditTrans
Definition TEveTrans.h:41
void Move3PF(Double_t x, Double_t y, Double_t z)
General move in parent-frame.
Double_t * ArrZ()
Definition TEveTrans.h:97
Double_t * Array()
Definition TEveTrans.h:94
void SetScaleZ(Double_t sz)
Change z scaling.
void GetRotAngles(Float_t *x) const
Get Cardan rotation angles (pattern xYz above).
void SetPos(Double_t x, Double_t y, Double_t z)
Set position (base-vec 4).
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).
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:458
Geometrical transformation package.
Definition TGeoMatrix.h:38
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