Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
LorentzRotation.h
이 파일의 문서화 페이지로 가기
1 // -*- C++ -*-
2 // CLASSDOC OFF
3 // $Id:$
4 // ---------------------------------------------------------------------------
5 // CLASSDOC ON
6 //
7 // This file is a part of the CLHEP - a Class Library for High Energy Physics.
8 //
9 // This is the definition of the HepLorentzRotation class for performing
10 // Lorentz transformations (rotations and boosts) on objects of the
11 // HepLorentzVector class.
12 //
13 // HepLorentzRotation is a concrete implementation of Hep4RotationInterface.
14 //
15 // .SS See Also
16 // RotationInterfaces.h
17 // ThreeVector.h, LorentzVector.h
18 // Rotation.h, Boost.h
19 //
20 // .SS Author
21 // Leif Lonnblad, Mark Fischler
22 
23 #ifndef HEP_LORENTZROTATION_H
24 #define HEP_LORENTZROTATION_H
25 
26 #ifdef GNUPRAGMA
27 #pragma interface
28 #endif
29 
31 #include "CLHEP/Vector/Rotation.h"
32 #include "CLHEP/Vector/Boost.h"
34 
35 namespace CLHEP {
36 
37 // Global methods
38 
39 inline HepLorentzRotation inverseOf ( const HepLorentzRotation & lt );
40 HepLorentzRotation operator * (const HepRotation & r,
41  const HepLorentzRotation & lt);
42 HepLorentzRotation operator * (const HepRotationX & r,
43  const HepLorentzRotation & lt);
44 HepLorentzRotation operator * (const HepRotationY & r,
45  const HepLorentzRotation & lt);
46 HepLorentzRotation operator * (const HepRotationZ & r,
47  const HepLorentzRotation & lt);
48 
54 
55 public:
56  // ---------- Identity HepLorentzRotation:
57 
59 
60  // ---------- Constructors and Assignment:
61 
62  inline HepLorentzRotation();
63  // Default constructor. Gives a unit matrix.
64 
65  inline HepLorentzRotation (const HepLorentzRotation & r);
66  // Copy constructor.
67 
68  inline HepLorentzRotation (const HepRotation & r);
69  inline explicit HepLorentzRotation (const HepRotationX & r);
70  inline explicit HepLorentzRotation (const HepRotationY & r);
71  inline explicit HepLorentzRotation (const HepRotationZ & r);
72  inline HepLorentzRotation (const HepBoost & b);
73  inline explicit HepLorentzRotation (const HepBoostX & b);
74  inline explicit HepLorentzRotation (const HepBoostY & b);
75  inline explicit HepLorentzRotation (const HepBoostZ & b);
76  // Constructors from special cases.
77 
79  inline HepLorentzRotation & operator = (const HepRotation & m);
80  inline HepLorentzRotation & operator = (const HepBoost & m);
81  // Assignment.
82 
83  HepLorentzRotation & set (double bx, double by, double bz);
84  inline HepLorentzRotation & set (const Hep3Vector & p);
85  inline HepLorentzRotation & set (const HepRotation & r);
86  inline HepLorentzRotation & set (const HepRotationX & r);
87  inline HepLorentzRotation & set (const HepRotationY & r);
88  inline HepLorentzRotation & set (const HepRotationZ & r);
89  inline HepLorentzRotation & set (const HepBoost & boost);
90  inline HepLorentzRotation & set (const HepBoostX & boost);
91  inline HepLorentzRotation & set (const HepBoostY & boost);
92  inline HepLorentzRotation & set (const HepBoostZ & boost);
93  inline HepLorentzRotation (double bx, double by, double bz);
94  inline HepLorentzRotation (const Hep3Vector & p);
95  // Other Constructors giving a Lorentz-boost.
96 
97  HepLorentzRotation & set( const HepBoost & B, const HepRotation & R );
98  inline HepLorentzRotation ( const HepBoost & B, const HepRotation & R );
99  // supply B and R: T = B R:
100 
101  HepLorentzRotation & set( const HepRotation & R, const HepBoost & B );
102  inline HepLorentzRotation ( const HepRotation & R, const HepBoost & B );
103  // supply R and B: T = R B:
104 
106  const HepLorentzVector & col2,
107  const HepLorentzVector & col3,
108  const HepLorentzVector & col4 );
109  // Construct from four *orthosymplectic* LorentzVectors for the columns:
110  // NOTE:
111  // This constructor, and the two set methods below,
112  // will check that the columns (or rows) form an orthosymplectic
113  // matrix, and will adjust values so that this relation is
114  // as exact as possible.
115  // Orthosymplectic means the dot product USING THE METRIC
116  // of two different coumns will be 0, and of a column with
117  // itself will be one.
118 
120  const HepLorentzVector & col2,
121  const HepLorentzVector & col3,
122  const HepLorentzVector & col4 );
123  // supply four *orthosymplectic* HepLorentzVectors for the columns
124 
126  const HepLorentzVector & row2,
127  const HepLorentzVector & row3,
128  const HepLorentzVector & row4 );
129  // supply four *orthosymplectic* HepLorentzVectors for the columns
130 
131  inline HepLorentzRotation & set( const HepRep4x4 & rep );
132  inline HepLorentzRotation ( const HepRep4x4 & rep );
133  // supply a HepRep4x4 structure (16 numbers)
134  // WARNING:
135  // This constructor and set method will assume the
136  // HepRep4x4 supplied is in fact an orthosymplectic matrix.
137  // No checking or correction is done. If you are
138  // not certain the matrix is orthosymplectic, break it
139  // into four HepLorentzVector columns and use the form
140  // HepLorentzRotation (col1, col2, col3, col4)
141 
142  // ---------- Accessors:
143 
144  inline double xx() const;
145  inline double xy() const;
146  inline double xz() const;
147  inline double xt() const;
148  inline double yx() const;
149  inline double yy() const;
150  inline double yz() const;
151  inline double yt() const;
152  inline double zx() const;
153  inline double zy() const;
154  inline double zz() const;
155  inline double zt() const;
156  inline double tx() const;
157  inline double ty() const;
158  inline double tz() const;
159  inline double tt() const;
160  // Elements of the matrix.
161 
162  inline HepLorentzVector col1() const;
163  inline HepLorentzVector col2() const;
164  inline HepLorentzVector col3() const;
165  inline HepLorentzVector col4() const;
166  // orthosymplectic column vectors
167 
168  inline HepLorentzVector row1() const;
169  inline HepLorentzVector row2() const;
170  inline HepLorentzVector row3() const;
171  inline HepLorentzVector row4() const;
172  // orthosymplectic row vectors
173 
174  inline HepRep4x4 rep4x4() const;
175  // 4x4 representation:
176 
177  // ------------ Subscripting:
178 
180  public:
181  inline HepLorentzRotation_row(const HepLorentzRotation &, int);
182  inline double operator [] (int) const;
183  private:
185  int ii;
186  };
187  // Helper class for implemention of C-style subscripting r[i][j]
188 
189  inline const HepLorentzRotation_row operator [] (int) const;
190  // Returns object of the helper class for C-style subscripting r[i][j]
191 
192  double operator () (int, int) const;
193  // Fortran-style subscripting: returns (i,j) element of the matrix.
194 
195  // ---------- Decomposition:
196 
197  void decompose (Hep3Vector & boost, HepAxisAngle & rotation) const;
198  void decompose (HepBoost & boost, HepRotation & rotation) const;
199  // Find B and R such that L = B*R
200 
201  void decompose (HepAxisAngle & rotation, Hep3Vector & boost) const;
202  void decompose (HepRotation & rotation, HepBoost & boost) const;
203  // Find R and B such that L = R*B
204 
205  // ---------- Comparisons:
206 
207  int compare( const HepLorentzRotation & m ) const;
208  // Dictionary-order comparison, in order tt,tz,...zt,zz,zy,zx,yt,yz,...,xx
209  // Used in operator<, >, <=, >=
210 
211  inline bool operator == (const HepLorentzRotation &) const;
212  inline bool operator != (const HepLorentzRotation &) const;
213  inline bool operator <= (const HepLorentzRotation &) const;
214  inline bool operator >= (const HepLorentzRotation &) const;
215  inline bool operator < (const HepLorentzRotation &) const;
216  inline bool operator > (const HepLorentzRotation &) const;
217 
218  inline bool isIdentity() const;
219  // Returns true if the Identity matrix.
220 
221  double distance2( const HepBoost & b ) const;
222  double distance2( const HepRotation & r ) const;
223  double distance2( const HepLorentzRotation & lt ) const;
224  // Decomposes L = B*R, returns the sum of distance2 for B and R.
225 
226  double howNear( const HepBoost & b ) const;
227  double howNear( const HepRotation & r) const;
228  double howNear( const HepLorentzRotation & lt ) const;
229 
230  bool isNear(const HepBoost & b,
232  bool isNear(const HepRotation & r,
234  bool isNear(const HepLorentzRotation & lt,
236 
237  // ---------- Properties:
238 
239  double norm2() const;
240  // distance2 (IDENTITY), which involves decomposing into B and R and summing
241  // norm2 for the individual B and R parts.
242 
243  void rectify();
244  // non-const but logically moot correction for accumulated roundoff errors
245  // rectify averages the matrix with the orthotranspose of its actual
246  // inverse (absent accumulated roundoff errors, the orthotranspose IS
247  // the inverse)); this removes to first order those errors.
248  // Then it formally decomposes that, extracts axis and delta for its
249  // Rotation part, forms a LorentzRotation from a true HepRotation
250  // with those values of axis and delta, times the true Boost
251  // with that boost vector.
252 
253  // ---------- Application:
254 
256  inline HepLorentzVector operator()( const HepLorentzVector & w ) const;
257  inline HepLorentzVector operator* ( const HepLorentzVector & p ) const;
258  // Multiplication with a Lorentz Vector.
259 
260  // ---------- Operations in the group of 4-Rotations
261 
263 
264  inline HepLorentzRotation operator * (const HepBoost & b) const;
265  inline HepLorentzRotation operator * (const HepRotation & r) const;
266  inline HepLorentzRotation operator * (const HepLorentzRotation & lt) const;
267  // Product of two Lorentz Rotations (this) * lt - matrix multiplication
268 
269  inline HepLorentzRotation & operator *= (const HepBoost & b);
270  inline HepLorentzRotation & operator *= (const HepRotation & r);
272  inline HepLorentzRotation & transform (const HepBoost & b);
273  inline HepLorentzRotation & transform (const HepRotation & r);
274  inline HepLorentzRotation & transform (const HepLorentzRotation & lt);
275  // Matrix multiplication.
276  // Note a *= b; <=> a = a * b; while a.transform(b); <=> a = b * a;
277 
278  // Here there is an opportunity for speedup by providing specialized forms
279  // of lt * r and lt * b where r is a RotationX Y or Z or b is a BoostX Y or Z
280  // These are, in fact, provided below for the transform() methods.
281 
282  HepLorentzRotation & rotateX(double delta);
283  // Rotation around the x-axis; equivalent to LT = RotationX(delta) * LT
284 
285  HepLorentzRotation & rotateY(double delta);
286  // Rotation around the y-axis; equivalent to LT = RotationY(delta) * LT
287 
288  HepLorentzRotation & rotateZ(double delta);
289  // Rotation around the z-axis; equivalent to LT = RotationZ(delta) * LT
290 
291  inline HepLorentzRotation & rotate(double delta, const Hep3Vector& axis);
292  inline HepLorentzRotation & rotate(double delta, const Hep3Vector *axis);
293  // Rotation around specified vector - LT = Rotation(delta,axis)*LT
294 
295  HepLorentzRotation & boostX(double beta);
296  // Pure boost along the x-axis; equivalent to LT = BoostX(beta) * LT
297 
298  HepLorentzRotation & boostY(double beta);
299  // Pure boost along the y-axis; equivalent to LT = BoostX(beta) * LT
300 
301  HepLorentzRotation & boostZ(double beta);
302  // Pure boost along the z-axis; equivalent to LT = BoostX(beta) * LT
303 
304  inline HepLorentzRotation & boost(double, double, double);
305  inline HepLorentzRotation & boost(const Hep3Vector &);
306  // Lorenz boost.
307 
308  inline HepLorentzRotation inverse() const;
309  // Return the inverse.
310 
311  inline HepLorentzRotation & invert();
312  // Inverts the LorentzRotation matrix.
313 
314  // ---------- I/O:
315 
316  std::ostream & print( std::ostream & os ) const;
317  // Aligned six-digit-accurate output of the transformation matrix.
318 
319  // ---------- Tolerance
320 
321  static inline double getTolerance();
322  static inline double setTolerance(double tol);
323 
324  friend HepLorentzRotation inverseOf ( const HepLorentzRotation & lt );
325 
326 protected:
327 
328  inline HepLorentzRotation
329  (double mxx, double mxy, double mxz, double mxt,
330  double myx, double myy, double myz, double myt,
331  double mzx, double mzy, double mzz, double mzt,
332  double mtx, double mty, double mtz, double mtt);
333  // Protected constructor.
334  // DOES NOT CHECK FOR VALIDITY AS A LORENTZ TRANSFORMATION.
335 
336  inline void setBoost(double, double, double);
337  // Set elements according to a boost vector.
338 
339  double mxx, mxy, mxz, mxt,
340  myx, myy, myz, myt,
341  mzx, mzy, mzz, mzt,
342  mtx, mty, mtz, mtt;
343  // The matrix elements.
344 
345 }; // HepLorentzRotation
346 
347 inline std::ostream & operator<<
348  ( std::ostream & os, const HepLorentzRotation& lt )
349  {return lt.print(os);}
350 
351 inline bool operator==(const HepRotation &r, const HepLorentzRotation & lt)
352  { return lt==r; }
353 inline bool operator!=(const HepRotation &r, const HepLorentzRotation & lt)
354  { return lt!=r; }
355 inline bool operator<=(const HepRotation &r, const HepLorentzRotation & lt)
356  { return lt<=r; }
357 inline bool operator>=(const HepRotation &r, const HepLorentzRotation & lt)
358  { return lt>=r; }
359 inline bool operator<(const HepRotation &r, const HepLorentzRotation & lt)
360  { return lt<r; }
361 inline bool operator>(const HepRotation &r, const HepLorentzRotation & lt)
362  { return lt>r; }
363 
364 inline bool operator==(const HepBoost &b, const HepLorentzRotation & lt)
365  { return lt==b; }
366 inline bool operator!=(const HepBoost &b, const HepLorentzRotation & lt)
367  { return lt!=b; }
368 inline bool operator<=(const HepBoost &b, const HepLorentzRotation & lt)
369  { return lt<=b; }
370 inline bool operator>=(const HepBoost &b, const HepLorentzRotation & lt)
371  { return lt>=b; }
372 inline bool operator<(const HepBoost &b, const HepLorentzRotation & lt)
373  { return lt<b; }
374 inline bool operator>(const HepBoost &b, const HepLorentzRotation & lt)
375  { return lt>b; }
376 
377 } // namespace CLHEP
378 
379 #include "CLHEP/Vector/LorentzRotation.icc"
380 
381 #endif /* HEP_LORENTZROTATION_H */
382 
HepLorentzRotation & boost(double, double, double)
HepLorentzRotation & setRows(const HepLorentzVector &row1, const HepLorentzVector &row2, const HepLorentzVector &row3, const HepLorentzVector &row4)
HepLorentzRotation & rotate(double delta, const Hep3Vector &axis)
bool operator>(const HepRotation &r, const HepLorentzRotation &lt)
const HepLorentzRotation_row operator[](int) const
bool operator<=(const HepLorentzRotation &) const
HepLorentzVector vectorMultiplication(const HepLorentzVector &) const
HepLorentzVector col3() const
bool operator<(const HepRotation &r, const HepLorentzRotation &lt)
const char * p
Definition: xmltok.h:285
HepLorentzVector col1() const
HepLorentzRotation matrixMultiplication(const HepRep4x4 &m) const
bool operator>(const HepLorentzRotation &) const
bool operator>=(const HepLorentzRotation &) const
bool operator>=(const HepRotation &r, const HepLorentzRotation &lt)
Double_t beta
HepRep4x4 rep4x4() const
double operator()(int, int) const
bool operator<=(const HepRotation &r, const HepLorentzRotation &lt)
HepLorentzRotation operator*(const HepRotation &r, const HepLorentzRotation &lt)
HepLorentzRotation & operator*=(const HepBoost &b)
HepLorentzRotation & boostX(double beta)
bool isNear(const HepBoost &b, double epsilon=Hep4RotationInterface::tolerance) const
HepLorentzRotation & rotateZ(double delta)
HepLorentzVector row4() const
HepLorentzVector col4() const
Double_t R
bool operator<(const HepLorentzRotation &) const
HepLorentzRotation inverse() const
friend HepLorentzRotation inverseOf(const HepLorentzRotation &lt)
HepBoost inverseOf(const HepBoost &lt)
double distance2(const HepBoost &b) const
void setBoost(double, double, double)
#define DLL_API
Definition: defs.h:19
HepLorentzVector row2() const
int compare(const HepLorentzRotation &m) const
static constexpr double m
double epsilon(double density, double temperature)
static double setTolerance(double tol)
static double getTolerance()
bool operator!=(const HepRotation &r, const HepLorentzRotation &lt)
HepLorentzRotation & operator=(const HepLorentzRotation &m)
HepLorentzRotation & boostY(double beta)
HepLorentzVector row3() const
double howNear(const HepBoost &b) const
void decompose(Hep3Vector &boost, HepAxisAngle &rotation) const
static DLL_API const HepLorentzRotation IDENTITY
HepLorentzRotation & set(double bx, double by, double bz)
HepLorentzVector operator*(const HepLorentzVector &p) const
HepLorentzRotation & boostZ(double beta)
bool operator!=(const HepLorentzRotation &) const
HepLorentzVector col2() const
HepLorentzVector row1() const
HepLorentzRotation & rotateY(double delta)
std::ostream & print(std::ostream &os) const
double B(double temperature)
bool operator==(const HepLorentzRotation &) const
HepLorentzRotation & rotateX(double delta)
bool operator==(const HepRotation &r, const HepLorentzRotation &lt)
HepLorentzRotation & transform(const HepBoost &b)
HepLorentzRotation & invert()
static DLL_API double tolerance
HepLorentzRotation_row(const HepLorentzRotation &, int)