CLHEP 2.4.7.1
C++ Class Library for High Energy Physics
RotationInterfaces.h
Go to the documentation of this file.
1// -*- C++ -*-
2// CLASSDOC OFF
3// ---------------------------------------------------------------------------
4// CLASSDOC ON
5
6#ifndef HEP_ROTATION_INTERFACES_H
7#define HEP_ROTATION_INTERFACES_H
8
9// This file is a part of the CLHEP - a Class Library for High Energy Physics.
10//
11// This contains the definition of two abstract interface classes:
12// Hep4RotationInterface
13// Hep3RotationInterface.
14// However, these are mostly for defining methods which should be present in
15// any 4- or 3-rotation class, however specialized. The actual classes do
16// not inherit from these. The virtual function overhead turns out
17// to be too steep for that to be practical.
18//
19// It may be desirable in the future to turn these classes into constraints
20// in the Stroustrup sense, so as to enforce this interface, still without
21// inheritance. However, they do contain an important static:
22// static double tolerance to set criteria for relative nearness.
23//
24// This file also defines structs
25// HepRep3x3;
26// HepRep4x4;
27// HepRep4x4Symmetric;
28// which are used by various Rotation classes.
29//
30// Hep4RotationInterface
31// contains all the methods to get attributes of either a
32// HepLorentzRotation or a HepRotation -- any information
33// that pertains to a LorentzRotation can also be defined
34// for a HepRotation.(For example, the 4x4 representation
35// would just have 0's in the space-time entries and 1 in
36// the time-time entry.)
37//
38// Hep3RotationInterface
39// inherits from Hep4RotationInterface, and adds methods
40// which are well-defined only in the case of a Rotation.
41// For example, a 3x3 representation is an attribute only
42// if the generic LorentzRotation involves no boost.
43//
44// In terms of classes in the ZOOM PhysicsVectors package,
45// Hep4RotationInterface <--> LorentzTransformationInterface
46// Hep3RotationInterface <--> RotationInterface
47//
48// Hep4RotationInterface defines the required methods for:
49// HepLorentzRotation
50// HepBoost
51// HepBoostX
52// HepBoostY
53// HepBoostZ
54//
55// Hep3RotationInterface defines the required methods for:
56// HepRotation
57// HepRotationX
58// HepRotationY
59// HepRotationZ
60//
61// .SS See Also
62// Rotation.h, LorentzRotation.h
63//
64// .SS Author
65// Mark Fischler
66//
67
68#include "CLHEP/Vector/defs.h"
72
73namespace CLHEP {
74
75struct HepRep3x3;
76struct HepRep4x4;
77struct HepRep4x4Symmetric;
78
79class HepRotation;
80class HepRotationX;
81class HepRotationY;
82class HepRotationZ;
83class HepLorentzRotation;
84class HepBoost;
85class HepBoostX;
86class HepBoostY;
87class HepBoostZ;
88
89//-******************************
90//
91// Hep4RotationInterface
92//
93//-******************************
94
100
101 // All attributes of shared by HepLorentzRotation, HepBoost,
102 // HepBoostX, HepBoostY, HepBoostZ. HepRotation, HepRotationX,
103 // HepRotationY, HepRotationZ also share this attribute interface.
104
105 friend class HepRotation;
106 friend class HepRotationX;
107 friend class HepRotationY;
108 friend class HepRotationZ;
109 friend class HepLorentzRotation;
110 friend class HepBoost;
111 friend class HepBoostX;
112 friend class HepBoostY;
113 friend class HepBoostZ;
114
115public:
116
117 static double tolerance; // to determine relative nearness
118
119 // ---------- Accessors:
120
121#ifdef ONLY_IN_CONCRETE_CLASSES
122 // orthosymplectic 4-vectors:
123 HepLorentzVector col1() const;
124 HepLorentzVector col2() const;
125 HepLorentzVector col3() const;
126 HepLorentzVector col4() const;
127 HepLorentzVector row1() const;
128 HepLorentzVector row2() const;
129 HepLorentzVector row3() const;
130 HepLorentzVector row4() const;
131
132 // individual elements:
133 double xx() const ;
134 double xy() const ;
135 double xz() const ;
136 double xt() const ;
137 double yx() const ;
138 double yy() const ;
139 double yz() const ;
140 double yt() const ;
141 double zx() const ;
142 double zy() const ;
143 double zz() const ;
144 double zt() const ;
145 double tx() const ;
146 double ty() const ;
147 double tz() const ;
148 double tt() const ;
149
150 // 4x4 representation:
151//HepRep4x4 rep4x4() const; JMM Declared here but not defined anywhere!
152
153 // ---------- Operations:
154 // comparisons:
155
156 inline int compare( const Hep4RotationInterface & lt ) const;
157 // Dictionary-order comparisons, utilizing the decompose(b,r) method
158
159 // decomposition:
160
161 void decompose (HepAxisAngle & rotation, Hep3Vector & boost)const;
162 // Decompose as T= R * B, where R is pure rotation, B is pure boost.
163
164 void decompose (Hep3Vector & boost, HepAxisAngle & rotation)const;
165 // Decompose as T= B * R, where R is pure rotation, B is pure boost.
166
167 bool operator == (const Hep4RotationInterface & r) const;
168 bool operator != (const Hep4RotationInterface & r) const;
169
170 // relative comparison:
171
172 double norm2() const ;
173 double distance2( const Hep4RotationInterface & lt ) const ;
174 double howNear( const Hep4RotationInterface & lt ) const ;
175 bool isNear (const Hep4RotationInterface & lt,
176 double epsilon=tolerance) const ;
177
178 void rectify() ;
179 // non-const but logically const correction for accumulated roundoff errors
180
181 // ---------- Apply LorentzTransformations:
182
183 HepLorentzVector operator* ( const HepLorentzVector & w ) const ;
184 HepLorentzVector operator()( const HepLorentzVector & w ) const ;
185 // Apply to a 4-vector
186
187 // ---------- I/O:
188
189 std::ostream & print( std::ostream & os ) const;
190
191#endif /* ONLY_IN_CONCRETE_CLASSES */
192
193 static double getTolerance();
194 static double setTolerance( double tol );
195
196 static const int ToleranceTicks = 100;
197
198protected:
199
200 ~Hep4RotationInterface() {} // protect destructor to forbid instatiation
201
202}; // Hep4RotationInterface
203
204
205//-******************************
206//
207// Hep3RotationInterface
208//
209//-******************************
210
216
217 // All attributes of HepRotation, HepRotationX, HepRotationY, HepRotationZ
218 // beyond those available by virtue of being a Hep3RotationInterface.
219
220 friend class HepRotation;
221 friend class HepRotationX;
222 friend class HepRotationY;
223 friend class HepRotationZ;
224
225public:
226
227#ifdef ONLY_IN_CONCRETE_CLASSES
228
229 // Euler angles:
230 double getPhi () const ;
231 double getTheta() const ;
232 double getPsi () const ;
233 double phi () const ;
234 double theta() const ;
235 double psi () const ;
236 HepEulerAngles eulerAngles() const ;
237
238 // axis & angle of rotation:
239 double getDelta() const ;
240 Hep3Vector getAxis () const ;
241 double delta() const ;
242 Hep3Vector axis () const ;
243 HepAxisAngle axisAngle() const ;
244
245 // orthogonal unit-length vectors:
246 Hep3Vector rowX() const;
247 Hep3Vector rowY() const;
248 Hep3Vector rowZ() const;
249
250 Hep3Vector colX() const;
251 Hep3Vector colY() const;
252 Hep3Vector colZ() const;
253
254//HepRep3x3 rep3x3() const; JMM Declared here but not defined anywhere!
255 // 3x3 representation
256
257 // orthosymplectic 4-vectors treating this as a 4-rotation:
258 HepLorentzVector col1() const;
259 HepLorentzVector col2() const;
260 HepLorentzVector col3() const;
261 HepLorentzVector col4() const;
262 HepLorentzVector row1() const;
263 HepLorentzVector row2() const;
264 HepLorentzVector row3() const;
265 HepLorentzVector row4() const;
266
267 // individual elements treating this as a 4-rotation:
268 double xt() const;
269 double yt() const;
270 double zt() const;
271 double tx() const;
272 double ty() const;
273 double tz() const;
274 double tt() const;
275
276 // ---------- Operations in the Rotation group
277
279
280 // ---------- Application
281
282 HepLorentzVector operator* ( const HepLorentzVector & w ) const ;
283 HepLorentzVector operator()( const HepLorentzVector & w ) const ;
284 // apply to HepLorentzVector
285
286 Hep3Vector operator* ( const Hep3Vector & v ) const ;
287 Hep3Vector operator()( const Hep3Vector & v ) const ;
288 // apply to Hep3Vector
289
290 // ---------- I/O and a helper method
291
292 std::ostream & print( std::ostream & os ) const;
293
294#endif /* ONLY_IN_CONCRETE_CLASSES */
295
296private:
297
298 ~Hep3RotationInterface() {} // private destructor to forbid instatiation
299
300}; // Hep3RotationInterface
301
302//-***************************
303// 3x3 and 4x4 representations
304//-***************************
305
306struct HepRep3x3 {
307
308 // ----- Constructors:
309
310 inline HepRep3x3();
311
312 inline HepRep3x3( double xx, double xy, double xz
313 , double yx, double yy, double yz
314 , double zx, double zy, double zz
315 );
316
317 inline HepRep3x3( const double * array );
318 // construct from an array of doubles, holding the rotation matrix
319 // in ROW order (xx, xy, ...)
320
321 inline void setToIdentity();
322
323 // ----- The data members are public:
324 double xx_, xy_, xz_,
327
328 inline void getArray ( double * array ) const;
329 // fill array with the NINE doubles xx, xy, xz ... zz
330
331}; // HepRep3x3
332
333struct HepRep4x4 {
334
335 // ----- Constructors:
336 inline HepRep4x4();
337
338 inline HepRep4x4( double xx, double xy, double xz, double xt
339 , double yx, double yy, double yz, double yt
340 , double zx, double zy, double zz, double zt
341 , double tx, double ty, double tz, double tt
342 );
343
344 inline HepRep4x4( const HepRep4x4Symmetric & rep );
345
346 inline HepRep4x4( const double * array );
347 // construct from an array of doubles, holding the transformation matrix
348 // in ROW order xx, xy, ...
349
350 inline void setToIdentity();
351
352 // ----- The data members are public:
353 double xx_, xy_, xz_, xt_,
357
358 inline void getArray ( double * array ) const;
359 // fill array with the SIXTEEN doubles xx, xy, xz ... tz, tt
360
361 inline bool operator==(HepRep4x4 const & r) const;
362 inline bool operator!=(HepRep4x4 const & r) const;
363
364
365}; // HepRep4x4
366
368
369 // ----- Constructors:
370
371 inline HepRep4x4Symmetric();
372
373 inline HepRep4x4Symmetric
374 ( double xx, double xy, double xz, double xt
375 , double yy, double yz, double yt
376 , double zz, double zt
377 , double tt );
378
379 inline HepRep4x4Symmetric( const double * array );
380 // construct from an array of doubles, holding the transformation matrix
381 // elements in this order: xx, xy, xz, xt, yy, yz, yt, zz, zt, tt
382
383 inline void setToIdentity();
384
385 // ----- The data members are public:
386 double xx_, xy_, xz_, xt_,
390
391 inline void getArray ( double * array ) const;
392 // fill array with the TEN doubles xx, xy, xz, xt, yy, yz, yt, zz, zt, tt
393
394};
395
396} // namespace CLHEP
397
399
400#ifdef ENABLE_BACKWARDS_COMPATIBILITY
401// backwards compatibility will be enabled ONLY in CLHEP 1.9
402using namespace CLHEP;
403#endif
404
405#endif // ROTATION_INTERFACES_H
static double getTolerance()
static double setTolerance(double tol)
bool operator!=(const HepRotation &r, const HepLorentzRotation &lt)
bool operator==(const HepRotation &r, const HepLorentzRotation &lt)
HepMatrix operator*(const HepMatrix &hm1, const HepDiagMatrix &hm2)
void getArray(double *array) const
void getArray(double *array) const
bool operator!=(HepRep4x4 const &r) const
bool operator==(HepRep4x4 const &r) const
void getArray(double *array) const