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