CLHEP VERSION Reference Documentation
   
CLHEP Home Page     CLHEP Documentation     CLHEP Bug Reports

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