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/.
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()
25 /**************************************************************************/
26 // ZTrans -- 3D transformation in generalised coordinates
27 /**************************************************************************/
29 class ZTrans : public TObject
31 friend class ZTransSubEditor;
32 friend class ZTransEditor;
37 mutable Float_t mA1; //!
38 mutable Float_t mA2; //!
39 mutable Float_t mA3; //!
40 mutable Bool_t bAsOK; //!
46 Double_t norm3_column(Int_t col);
47 Double_t orto3_column(Int_t col, Int_t ref);
51 ZTrans(const ZTrans& t);
52 ZTrans(const Double_t arr[16]);
53 ZTrans(const Float_t arr[16]);
60 void SetTrans(const ZTrans& t, Bool_t copyAngles=kTRUE);
61 void SetFromArray(const Double_t arr[16]);
62 void SetFromArray(const Float_t arr[16]);
63 ZTrans& operator=(const ZTrans& t) { SetTrans(t); return *this; }
64 void SetupRotation(Int_t i, Int_t j, Double_t f);
69 void MultLeft(const ZTrans& t);
70 void MultRight(const ZTrans& t);
71 void operator*=(const ZTrans& t) { MultRight(t); }
73 void TransposeRotationPart();
75 ZTrans operator*(const ZTrans& t);
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);
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);
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);
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; }
99 Double_t operator[](Int_t i) const { return M[i]; }
100 Double_t& operator[](Int_t i) { return M[i]; }
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]; }
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]; }
108 // Base-vector interface
110 void SetBaseVec(Int_t b, Double_t x, Double_t y, Double_t z);
111 void SetBaseVec(Int_t b, const TVector3& v);
113 TVector3 GetBaseVec(Int_t b) const;
114 void GetBaseVec(Int_t b, TVector3& v) const;
116 // Position interface
118 void SetPos(Double_t x, Double_t y, Double_t z);
119 void SetPos(Double_t* x);
120 void SetPos(Float_t * x);
121 void SetPos(const ZTrans& t);
123 void GetPos(Double_t& x, Double_t& y, Double_t& z) const;
124 void GetPos(Double_t* x) const;
125 void GetPos(Float_t * x) const;
126 void GetPos(TVector3& v) const;
127 TVector3 GetPos() const;
129 // Cardan angle interface
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;
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);
143 // Operations on vectors
145 void MultiplyIP(TVector3& v, Double_t w=1) const;
146 void MultiplyIP(Double_t* v, Double_t w=1) const;
147 void MultiplyIP(Float_t* v, Double_t w=1) const;
148 TVector3 Multiply(const TVector3& v, Double_t w=1) const;
149 void Multiply(const Double_t *vin, Double_t* vout, Double_t w=1) const;
150 void RotateIP(TVector3& v) const;
151 TVector3 Rotate(const TVector3& v) const;
154 virtual void Print(Option_t* option = "") const;
159 void SetFrom(Double_t* carr);
160 void SetFrom(const TGeoMatrix& mat);
161 void SetGeoHMatrix(TGeoHMatrix& mat);
162 void SetBuffer3D(TBuffer3D& buff);
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; }
169 Bool_t IsScale(Double_t low=0.9, Double_t high=1.1) const;
171 ClassDef(ZTrans, 1) // Column-major 4x4 matrix for homogeneous coordinates.
174 ostream& operator<<(ostream& s, const ZTrans& t);