Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
REveTrans.hxx
Go to the documentation of this file.
1// @(#)root/eve7:$Id$
2// Authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007, 2018
3
4/*************************************************************************
5 * Copyright (C) 1995-2019, 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 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 ~REveTrans() override {}
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 void Print(Option_t *option = "") const override;
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 ClassDefOverride(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 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
float Float_t
Definition RtypesCore.h:57
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
REveTrans operator*(const REveTrans &t)
Copy, multiply from right and return product.
const Double_t * ArrT() const
void UnitRot()
Reset rotation part of the matrix to unity.
void SetBuffer3D(TBuffer3D &buff)
Fill transformation part TBuffer3D core section.
void SetupRotation(Int_t i, Int_t j, Double_t f)
Setup the matrix as an elementary rotation.
Double_t Norm3Column(Int_t col)
Norm 3-vector in column col.
void SetScaleY(Double_t sy)
Change y scaling.
void RotatePF(Int_t i1, Int_t i2, Double_t amount)
Rotate in parent frame. Does optimised version of MultLeft.
Double_t Invert()
Invert matrix.
void MultiplyIP(TVector3 &v, Double_t w=1) const
Multiply vector in-place.
void RotateLF(Int_t i1, Int_t i2, Double_t amount)
Rotate in local frame. Does optimised version of MultRight.
void operator*=(const REveTrans &t)
Definition REveTrans.hxx:76
Double_t & CM(Int_t i, Int_t j)
const Double_t * ArrX() const
void GetScale(Double_t &sx, Double_t &sy, Double_t &sz) const
Deduce scales from sizes of base vectors.
REveTrans()
Default constructor.
Definition REveTrans.cxx:72
void TransposeRotationPart()
Transpose 3x3 rotation sub-matrix.
Double_t & operator[](Int_t i)
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).
void Move3PF(Double_t x, Double_t y, Double_t z)
General move in parent-frame.
void SetTrans(const REveTrans &t, Bool_t copyAngles=kTRUE)
Set matrix from another,.
void SetFromArray(const Double_t arr[16])
Set matrix from Double_t array.
void MovePF(Int_t ai, Double_t amount)
Move in parent-frame along axis index ai.
void SetBaseVec(Int_t b, Double_t x, Double_t y, Double_t z)
Set base-vector with index b.
void SetScaleX(Double_t sx)
Change x scaling.
void MoveLF(Int_t ai, Double_t amount)
Move in local-frame along axis with index ai.
Double_t Orto3Column(Int_t col, Int_t ref)
Orto-norm 3-vector in column col with respect to column ref.
Double_t operator()(Int_t i, Int_t j) const
void SetGeoHMatrix(TGeoHMatrix &mat)
Set TGeoHMatrix mat.
void SetScale(Double_t sx, Double_t sy, Double_t sz)
Set scaling.
void OrtoNorm3()
Orto-norm columns 1 to 3.
void Move(const REveTrans &a, Int_t ai, Double_t amount)
Move in a's coord-system along axis-index ai.
void SetFrom(Double_t *carr)
void Move3LF(Double_t x, Double_t y, Double_t z)
General move in local-frame.
void GetRotAngles(Float_t *x) const
Get Cardan rotation angles (pattern xYz above).
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...
Double_t CM(Int_t i, Int_t j) const
void Print(Option_t *option="") const override
Print in reasonable format.
TVector3 Multiply(const TVector3 &v, Double_t w=1) const
Multiply vector and return it.
const Double_t * Array() const
Definition REveTrans.hxx:99
const Double_t * ArrZ() const
void SetPos(Double_t x, Double_t y, Double_t z)
Set position (base-vec 4).
void Scale(Double_t sx, Double_t sy, Double_t sz)
Scale matrix. Translation part untouched.
const Double_t * ArrY() const
Double_t & operator()(Int_t i, Int_t j)
void UnitTrans()
Reset matrix to unity.
Bool_t IsScale(Double_t low=0.9, Double_t high=1.1) const
Test if the transformation is a scale.
void Move3(const REveTrans &a, Double_t x, Double_t y, Double_t z)
General move in a's coord-system.
void RotateIP(TVector3 &v) const
Rotate vector in-place. Translation is NOT applied.
void MultRight(const REveTrans &t)
Multiply from right: this = this * t.
Double_t Unscale()
Remove scaling, make all base vectors of unit length.
void SetScaleZ(Double_t sz)
Change z scaling.
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 SetRotByAngles(Float_t a1, Float_t a2, Float_t a3)
void MultLeft(const REveTrans &t)
Multiply from left: this = t * this.
Double_t operator[](Int_t i) const
TVector3 GetBaseVec(Int_t b) const
Get base-vector with index b.
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.
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: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
This file contains a specialised ROOT message handler to test for diagnostic in unit tests.