]> git.uio.no Git - u/mrichter/AliRoot.git/blame - EVE/Reve/ZTrans.h
Record changes.
[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;
20class TBuffer3D;
21
22namespace Reve {
23
24/**************************************************************************/
25// ZTrans -- 3D transformation in generalised coordinates
26/**************************************************************************/
27
28class ZTrans : public TObject
29{
30 friend class ZTransSubEditor;
31 friend class ZTransEditor;
32
33protected:
34 Double32_t M[16];
35
36 mutable Float_t mA1; //!
37 mutable Float_t mA2; //!
38 mutable Float_t mA3; //!
39 mutable Bool_t bAsOK; //!
40
41 // Reve
42 Bool_t fUseTrans;
43 Bool_t fEditTrans;
44
45 Double_t norm3_column(Int_t col);
46 Double_t orto3_column(Int_t col, Int_t ref);
47
48public:
49 ZTrans();
3c67f72c 50 ZTrans(const ZTrans& t);
56c08b98 51 ZTrans(const Double_t arr[16]);
52 ZTrans(const Float_t arr[16]);
76082cd6 53 virtual ~ZTrans() {}
54
55 // General operations
56
57 void UnitTrans();
58 void UnitRot();
3c67f72c 59 void SetTrans(const ZTrans& t, Bool_t copyAngles=kTRUE);
56c08b98 60 void SetFromArray(const Double_t arr[16]);
61 void SetFromArray(const Float_t arr[16]);
76082cd6 62 ZTrans& operator=(const ZTrans& t) { SetTrans(t); return *this; }
63 void SetupRotation(Int_t i, Int_t j, Double_t f);
64
65 void OrtoNorm3();
66 Double_t Invert();
67
68 void MultLeft(const ZTrans& t);
69 void MultRight(const ZTrans& t);
70 void operator*=(const ZTrans& t) { MultRight(t); }
71
56c08b98 72 void TransposeRotationPart();
73
76082cd6 74 ZTrans operator*(const ZTrans& t);
75
76 // Move & Rotate
77
78 void MoveLF(Int_t ai, Double_t amount);
79 void Move3LF(Double_t x, Double_t y, Double_t z);
80 void RotateLF(Int_t i1, Int_t i2, Double_t amount);
81
82 void MovePF(Int_t ai, Double_t amount);
83 void Move3PF(Double_t x, Double_t y, Double_t z);
84 void RotatePF(Int_t i1, Int_t i2, Double_t amount);
85
86 void Move(const ZTrans& a, Int_t ai, Double_t amount);
87 void Move3(const ZTrans& a, Double_t x, Double_t y, Double_t z);
88 void Rotate(const ZTrans& a, Int_t i1, Int_t i2, Double_t amount);
89
90 // Element access
91
92 Double_t* Array() { return M; } const Double_t* Array() const { return M; }
93 Double_t* ArrX() { return M; } const Double_t* ArrX() const { return M; }
94 Double_t* ArrY() { return M + 4; } const Double_t* ArrY() const { return M + 4; }
95 Double_t* ArrZ() { return M + 8; } const Double_t* ArrZ() const { return M + 8; }
96 Double_t* ArrT() { return M + 12; } const Double_t* ArrT() const { return M + 12; }
97
98 Double_t operator[](Int_t i) const { return M[i]; }
99 Double_t& operator[](Int_t i) { return M[i]; }
100
101 Double_t CM(Int_t i, Int_t j) const { return M[4*j + i]; }
102 Double_t& CM(Int_t i, Int_t j) { return M[4*j + i]; }
103
104 Double_t operator()(Int_t i, Int_t j) const { return M[4*j + i - 5]; }
105 Double_t& operator()(Int_t i, Int_t j) { return M[4*j + i - 5]; }
106
107 // Base-vector interface
108
109 void SetBaseVec(Int_t b, Double_t x, Double_t y, Double_t z);
110 void SetBaseVec(Int_t b, const TVector3& v);
111
112 TVector3 GetBaseVec(Int_t b) const;
113 void GetBaseVec(Int_t b, TVector3& v) const;
114
115 // Position interface
116
117 void SetPos(Double_t x, Double_t y, Double_t z);
118 void SetPos(Double_t* x);
119 void SetPos(const ZTrans& t);
120
121 void GetPos(Double_t& x, Double_t& y, Double_t& z) const;
122 void GetPos(Double_t* x) const;
123 void GetPos(TVector3& v) const;
124 TVector3 GetPos() const;
125
126 // Cardan angle interface
127
128 void SetRotByAngles(Float_t a1, Float_t a2, Float_t a3);
129 void SetRotByAnyAngles(Float_t a1, Float_t a2, Float_t a3, const Text_t* pat);
130 void GetRotAngles(Float_t* x) const;
131
132 // Scaling
133
134 void Scale(Double_t sx, Double_t sy, Double_t sz);
135 void GetScale(Double_t& sx, Double_t& sy, Double_t& sz) const;
136 void Unscale(Double_t& sx, Double_t& sy, Double_t& sz);
137 Double_t Unscale();
138
139
140 // Operations on vectors
141
142 void MultiplyIP(TVector3& v, Double_t w=1) const;
143 TVector3 Multiply(const TVector3& v, Double_t w=1) const;
144 void RotateIP(TVector3& v) const;
145 TVector3 Rotate(const TVector3& v) const;
146
147
148 virtual void Print(Option_t* option = "") const;
149
150
151 // Reve stuff
152
153 void SetFrom(Double_t* carr);
154 void SetFrom(const TGeoMatrix& mat);
155 void SetBuffer3D(TBuffer3D& buff);
156
157 Bool_t GetUseTrans() const { return fUseTrans; }
158 void SetUseTrans(Bool_t v) { fUseTrans = v; }
159 Bool_t GetEditTrans() const { return fEditTrans; }
160 void SetEditTrans(Bool_t v) { fEditTrans = v; }
161
162 Bool_t IsScale(Double_t low=0.9, Double_t high=1.1) const;
163
164 ClassDef(ZTrans, 1) // Column-major 4x4 matrix for homogeneous coordinates.
165};
166
167ostream& operator<<(ostream& s, const ZTrans& t);
168
169}
170
171#endif