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