]> git.uio.no Git - u/mrichter/AliRoot.git/blame - EVE/Reve/ZTrans.h
Merged EVE-dev-after-merge to EVE-dev into HEAD. Requires ROOT-5.17.04.
[u/mrichter/AliRoot.git] / EVE / Reve / ZTrans.h
CommitLineData
76082cd6 1// $Header$
2
3// Copyright (C) 1999-2005, Matevz Tadel. All rights reserved.
4// This file is part of GLED, released under GNU General Public License version 2.
5// For the licensing terms see $GLEDSYS/LICENSE or http://www.gnu.org/.
6//
7// Taken from Gled, main changes:
8// 1. Put into namespace Reve.
9// 2. Remove references to ZNode.
10// 3. Added bool-members fApplyTrans, fEditTrans
11// 4. Added set-from-TGeoMatrix
12// 5. Added method SetupBuffer3D()
13
14#ifndef REVE_ZTrans_H
15#define REVE_ZTrans_H
16
17#include <TVector3.h>
18
19class TGeoMatrix;
a3975d20 20class TGeoHMatrix;
76082cd6 21class TBuffer3D;
22
23namespace Reve {
24
25/**************************************************************************/
26// ZTrans -- 3D transformation in generalised coordinates
27/**************************************************************************/
28
29class ZTrans : public TObject
30{
31 friend class ZTransSubEditor;
32 friend class ZTransEditor;
33
34protected:
35 Double32_t M[16];
36
37 mutable Float_t mA1; //!
38 mutable Float_t mA2; //!
39 mutable Float_t mA3; //!
40 mutable Bool_t bAsOK; //!
41
42 // Reve
43 Bool_t fUseTrans;
44 Bool_t fEditTrans;
45
46 Double_t norm3_column(Int_t col);
47 Double_t orto3_column(Int_t col, Int_t ref);
48
49public:
50 ZTrans();
3c67f72c 51 ZTrans(const ZTrans& t);
56c08b98 52 ZTrans(const Double_t arr[16]);
53 ZTrans(const Float_t arr[16]);
76082cd6 54 virtual ~ZTrans() {}
55
56 // General operations
57
58 void UnitTrans();
59 void UnitRot();
3c67f72c 60 void SetTrans(const ZTrans& t, Bool_t copyAngles=kTRUE);
56c08b98 61 void SetFromArray(const Double_t arr[16]);
62 void SetFromArray(const Float_t arr[16]);
76082cd6 63 ZTrans& operator=(const ZTrans& t) { SetTrans(t); return *this; }
64 void SetupRotation(Int_t i, Int_t j, Double_t f);
65
66 void OrtoNorm3();
67 Double_t Invert();
68
69 void MultLeft(const ZTrans& t);
70 void MultRight(const ZTrans& t);
71 void operator*=(const ZTrans& t) { MultRight(t); }
72
56c08b98 73 void TransposeRotationPart();
74
76082cd6 75 ZTrans operator*(const ZTrans& t);
76
77 // Move & Rotate
78
79 void MoveLF(Int_t ai, Double_t amount);
80 void Move3LF(Double_t x, Double_t y, Double_t z);
81 void RotateLF(Int_t i1, Int_t i2, Double_t amount);
82
83 void MovePF(Int_t ai, Double_t amount);
84 void Move3PF(Double_t x, Double_t y, Double_t z);
85 void RotatePF(Int_t i1, Int_t i2, Double_t amount);
86
87 void Move(const ZTrans& a, Int_t ai, Double_t amount);
88 void Move3(const ZTrans& a, Double_t x, Double_t y, Double_t z);
89 void Rotate(const ZTrans& a, Int_t i1, Int_t i2, Double_t amount);
90
91 // Element access
92
93 Double_t* Array() { return M; } const Double_t* Array() const { return M; }
94 Double_t* ArrX() { return M; } const Double_t* ArrX() const { return M; }
95 Double_t* ArrY() { return M + 4; } const Double_t* ArrY() const { return M + 4; }
96 Double_t* ArrZ() { return M + 8; } const Double_t* ArrZ() const { return M + 8; }
97 Double_t* ArrT() { return M + 12; } const Double_t* ArrT() const { return M + 12; }
98
99 Double_t operator[](Int_t i) const { return M[i]; }
100 Double_t& operator[](Int_t i) { return M[i]; }
101
102 Double_t CM(Int_t i, Int_t j) const { return M[4*j + i]; }
103 Double_t& CM(Int_t i, Int_t j) { return M[4*j + i]; }
104
105 Double_t operator()(Int_t i, Int_t j) const { return M[4*j + i - 5]; }
106 Double_t& operator()(Int_t i, Int_t j) { return M[4*j + i - 5]; }
107
108 // Base-vector interface
109
110 void SetBaseVec(Int_t b, Double_t x, Double_t y, Double_t z);
111 void SetBaseVec(Int_t b, const TVector3& v);
112
113 TVector3 GetBaseVec(Int_t b) const;
114 void GetBaseVec(Int_t b, TVector3& v) const;
115
116 // Position interface
117
118 void SetPos(Double_t x, Double_t y, Double_t z);
119 void SetPos(Double_t* x);
32e219c2 120 void SetPos(Float_t * x);
76082cd6 121 void SetPos(const ZTrans& t);
122
123 void GetPos(Double_t& x, Double_t& y, Double_t& z) const;
124 void GetPos(Double_t* x) const;
32e219c2 125 void GetPos(Float_t * x) const;
76082cd6 126 void GetPos(TVector3& v) const;
127 TVector3 GetPos() const;
128
129 // Cardan angle interface
130
131 void SetRotByAngles(Float_t a1, Float_t a2, Float_t a3);
132 void SetRotByAnyAngles(Float_t a1, Float_t a2, Float_t a3, const Text_t* pat);
133 void GetRotAngles(Float_t* x) const;
134
135 // Scaling
136
137 void Scale(Double_t sx, Double_t sy, Double_t sz);
138 void GetScale(Double_t& sx, Double_t& sy, Double_t& sz) const;
139 void Unscale(Double_t& sx, Double_t& sy, Double_t& sz);
140 Double_t Unscale();
141
142
143 // Operations on vectors
144
145 void MultiplyIP(TVector3& v, Double_t w=1) const;
32e219c2 146 void MultiplyIP(Double_t* v, Double_t w=1) const;
147 void MultiplyIP(Float_t* v, Double_t w=1) const;
76082cd6 148 TVector3 Multiply(const TVector3& v, Double_t w=1) const;
32e219c2 149 void Multiply(const Double_t *vin, Double_t* vout, Double_t w=1) const;
76082cd6 150 void RotateIP(TVector3& v) const;
151 TVector3 Rotate(const TVector3& v) const;
152
153
154 virtual void Print(Option_t* option = "") const;
155
156
157 // Reve stuff
158
159 void SetFrom(Double_t* carr);
160 void SetFrom(const TGeoMatrix& mat);
a3975d20 161 void SetGeoHMatrix(TGeoHMatrix& mat);
76082cd6 162 void SetBuffer3D(TBuffer3D& buff);
163
164 Bool_t GetUseTrans() const { return fUseTrans; }
165 void SetUseTrans(Bool_t v) { fUseTrans = v; }
166 Bool_t GetEditTrans() const { return fEditTrans; }
167 void SetEditTrans(Bool_t v) { fEditTrans = v; }
168
169 Bool_t IsScale(Double_t low=0.9, Double_t high=1.1) const;
170
171 ClassDef(ZTrans, 1) // Column-major 4x4 matrix for homogeneous coordinates.
172};
173
174ostream& operator<<(ostream& s, const ZTrans& t);
175
176}
177
178#endif