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