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