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

Geometry/CLHEP/Vector/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"
69 #include "CLHEP/Vector/ThreeVector.h"
70 #include "CLHEP/Vector/LorentzVector.h"
71 #include "CLHEP/Vector/AxisAngle.h"
72 
73 namespace CLHEP {
74 
75 struct HepRep3x3;
76 struct HepRep4x4;
77 struct HepRep4x4Symmetric;
78 
79 class HepRotation;
80 class HepRotationX;
81 class HepRotationY;
82 class HepRotationZ;
83 class HepLorentzRotation;
84 class HepBoost;
85 class HepBoostX;
86 class HepBoostY;
87 class HepBoostZ;
88 
89 
90 //-******************************
91 //
92 // Hep4RotationInterface
93 //
94 //-******************************
95 
101 
102  // All attributes of shared by HepLorentzRotation, HepBoost,
103  // HepBoostX, HepBoostY, HepBoostZ. HepRotation, HepRotationX,
104  // HepRotationY, HepRotationZ also share this attribute interface.
105 
106  friend class HepRotation;
107  friend class HepRotationX;
108  friend class HepRotationY;
109  friend class HepRotationZ;
110  friend class HepLorentzRotation;
111  friend class HepBoost;
112  friend class HepBoostX;
113  friend class HepBoostY;
114  friend class HepBoostZ;
115 
116 public:
117 
118  static double tolerance; // to determine relative nearness
119 
120  // ---------- Accessors:
121 
122 #ifdef ONLY_IN_CONCRETE_CLASSES
123  // orthosymplectic 4-vectors:
124  HepLorentzVector col1() const;
125  HepLorentzVector col2() const;
126  HepLorentzVector col3() const;
127  HepLorentzVector col4() const;
128  HepLorentzVector row1() const;
129  HepLorentzVector row2() const;
130  HepLorentzVector row3() const;
131  HepLorentzVector row4() const;
132 
133  // individual elements:
134  double xx() const ;
135  double xy() const ;
136  double xz() const ;
137  double xt() const ;
138  double yx() const ;
139  double yy() const ;
140  double yz() const ;
141  double yt() const ;
142  double zx() const ;
143  double zy() const ;
144  double zz() const ;
145  double zt() const ;
146  double tx() const ;
147  double ty() const ;
148  double tz() const ;
149  double tt() const ;
150 
151  // 4x4 representation:
152 //HepRep4x4 rep4x4() const; JMM Declared here but not defined anywhere!
153 
154  // ---------- Operations:
155  // comparisons:
156 
157  inline int compare( const Hep4RotationInterface & lt ) const;
158  // Dictionary-order comparisons, utilizing the decompose(b,r) method
159 
160  // decomposition:
161 
162  void decompose (HepAxisAngle & rotation, Hep3Vector & boost)const;
163  // Decompose as T= R * B, where R is pure rotation, B is pure boost.
164 
165  void decompose (Hep3Vector & boost, HepAxisAngle & rotation)const;
166  // Decompose as T= B * R, where R is pure rotation, B is pure boost.
167 
168  bool operator == (const Hep4RotationInterface & r) const;
169  bool operator != (const Hep4RotationInterface & r) const;
170 
171  // relative comparison:
172 
173  double norm2() const ;
174  double distance2( const Hep4RotationInterface & lt ) const ;
175  double howNear( const Hep4RotationInterface & lt ) const ;
176  bool isNear (const Hep4RotationInterface & lt,
177  double epsilon=tolerance) const ;
178 
179  void rectify() ;
180  // non-const but logically const correction for accumulated roundoff errors
181 
182  // ---------- Apply LorentzTransformations:
183 
184  HepLorentzVector operator* ( const HepLorentzVector & w ) const ;
185  HepLorentzVector operator()( const HepLorentzVector & w ) const ;
186  // Apply to a 4-vector
187 
188  // ---------- I/O:
189 
190  std::ostream & print( std::ostream & os ) const;
191 
192 #endif /* ONLY_IN_CONCRETE_CLASSES */
193 
194  static double getTolerance();
195  static double setTolerance( double tol );
196 
197  enum { ToleranceTicks = 100 };
198 
199 protected:
200 
201  ~Hep4RotationInterface() {} // protect destructor to forbid instatiation
202 
203 }; // Hep4RotationInterface
204 
205 
206 
207 //-******************************
208 //
209 // Hep3RotationInterface
210 //
211 //-******************************
212 
218 
219  // All attributes of HepRotation, HepRotationX, HepRotationY, HepRotationZ
220  // beyond those available by virtue of being a Hep3RotationInterface.
221 
222  friend class HepRotation;
223  friend class HepRotationX;
224  friend class HepRotationY;
225  friend class HepRotationZ;
226 
227 public:
228 
229 #ifdef ONLY_IN_CONCRETE_CLASSES
230 
231  // Euler angles:
232  double getPhi () const ;
233  double getTheta() const ;
234  double getPsi () const ;
235  double phi () const ;
236  double theta() const ;
237  double psi () const ;
238  HepEulerAngles eulerAngles() const ;
239 
240  // axis & angle of rotation:
241  double getDelta() const ;
242  Hep3Vector getAxis () const ;
243  double delta() const ;
244  Hep3Vector axis () const ;
245  HepAxisAngle axisAngle() const ;
246 
247  // orthogonal unit-length vectors:
248  Hep3Vector rowX() const;
249  Hep3Vector rowY() const;
250  Hep3Vector rowZ() const;
251 
252  Hep3Vector colX() const;
253  Hep3Vector colY() const;
254  Hep3Vector colZ() const;
255 
256 //HepRep3x3 rep3x3() const; JMM Declared here but not defined anywhere!
257  // 3x3 representation
258 
259  // orthosymplectic 4-vectors treating this as a 4-rotation:
260  HepLorentzVector col1() const;
261  HepLorentzVector col2() const;
262  HepLorentzVector col3() const;
263  HepLorentzVector col4() const;
264  HepLorentzVector row1() const;
265  HepLorentzVector row2() const;
266  HepLorentzVector row3() const;
267  HepLorentzVector row4() const;
268 
269  // individual elements treating this as a 4-rotation:
270  double xt() const;
271  double yt() const;
272  double zt() const;
273  double tx() const;
274  double ty() const;
275  double tz() const;
276  double tt() const;
277 
278  // ---------- Operations in the Rotation group
279 
280  HepRotation operator * ( const Hep3RotationInterface & r ) const ;
281 
282  // ---------- Application
283 
284  HepLorentzVector operator* ( const HepLorentzVector & w ) const ;
285  HepLorentzVector operator()( const HepLorentzVector & w ) const ;
286  // apply to HepLorentzVector
287 
288  Hep3Vector operator* ( const Hep3Vector & v ) const ;
289  Hep3Vector operator()( const Hep3Vector & v ) const ;
290  // apply to Hep3Vector
291 
292  // ---------- I/O and a helper method
293 
294  std::ostream & print( std::ostream & os ) const;
295 
296 #endif /* ONLY_IN_CONCRETE_CLASSES */
297 
298 private:
299 
300  ~Hep3RotationInterface() {} // private destructor to forbid instatiation
301 
302 }; // Hep3RotationInterface
303 
304 
305 //-***************************
306 // 3x3 and 4x4 representations
307 //-***************************
308 
309 struct HepRep3x3 {
310 
311  // ----- Constructors:
312 
313  inline HepRep3x3();
314 
315  inline HepRep3x3( double xx, double xy, double xz
316  , double yx, double yy, double yz
317  , double zx, double zy, double zz
318  );
319 
320  inline HepRep3x3( const double * array );
321  // construct from an array of doubles, holding the rotation matrix
322  // in ROW order (xx, xy, ...)
323 
324  inline void setToIdentity();
325 
326  // ----- The data members are public:
327  double xx_, xy_, xz_,
330 
331  inline void getArray ( double * array ) const;
332  // fill array with the NINE doubles xx, xy, xz ... zz
333 
334 }; // HepRep3x3
335 
336 struct HepRep4x4 {
337 
338  // ----- Constructors:
339  inline HepRep4x4();
340 
341  inline HepRep4x4( double xx, double xy, double xz, double xt
342  , double yx, double yy, double yz, double yt
343  , double zx, double zy, double zz, double zt
344  , double tx, double ty, double tz, double tt
345  );
346 
347  inline HepRep4x4( const HepRep4x4Symmetric & rep );
348 
349  inline HepRep4x4( const double * array );
350  // construct from an array of doubles, holding the transformation matrix
351  // in ROW order xx, xy, ...
352 
353  inline void setToIdentity();
354 
355  // ----- The data members are public:
356  double xx_, xy_, xz_, xt_,
360 
361  inline void getArray ( double * array ) const;
362  // fill array with the SIXTEEN doubles xx, xy, xz ... tz, tt
363 
364  inline bool operator==(HepRep4x4 const & r) const;
365  inline bool operator!=(HepRep4x4 const & r) const;
366 
367 
368 }; // HepRep4x4
369 
371 
372  // ----- Constructors:
373 
374  inline HepRep4x4Symmetric();
375 
376  inline HepRep4x4Symmetric
377  ( double xx, double xy, double xz, double xt
378  , double yy, double yz, double yt
379  , double zz, double zt
380  , double tt );
381 
382  inline HepRep4x4Symmetric( const double * array );
383  // construct from an array of doubles, holding the transformation matrix
384  // elements in this order: xx, xy, xz, xt, yy, yz, yt, zz, zt, tt
385 
386  inline void setToIdentity();
387 
388  // ----- The data members are public:
389  double xx_, xy_, xz_, xt_,
393 
394  inline void getArray ( double * array ) const;
395  // fill array with the TEN doubles xx, xy, xz, xt, yy, yz, yt, zz, zt, tt
396 
397 };
398 
399 } // namespace CLHEP
400 
401 #include "CLHEP/Vector/RotationInterfaces.icc"
402 
403 #ifdef ENABLE_BACKWARDS_COMPATIBILITY
404 // backwards compatibility will be enabled ONLY in CLHEP 1.9
405 using namespace CLHEP;
406 #endif
407 
408 #endif // ROTATION_INTERFACES_H
colZ
HepRotation colZ()
delta
HepRotation delta() setPhi()
colY
HepRotation colY()
CLHEP::HepRotationX
Definition: Geometry/CLHEP/Vector/RotationX.h:44
CLHEP::HepRep4x4::xz_
double xz_
Definition: Geometry/CLHEP/Vector/RotationInterfaces.h:356
CLHEP::HepAxisAngle
Definition: Geometry/CLHEP/Vector/AxisAngle.h:37
CLHEP::Hep4RotationInterface::~Hep4RotationInterface
~Hep4RotationInterface()
Definition: Geometry/CLHEP/Vector/RotationInterfaces.h:201
CLHEP::HepRep4x4::operator!=
bool operator!=(HepRep4x4 const &r) const
CLHEP::HepRep4x4::tt_
double tt_
Definition: Geometry/CLHEP/Vector/RotationInterfaces.h:359
CLHEP::Hep4RotationInterface::setTolerance
static double setTolerance(double tol)
Definition: RotationInterfaces.cc:27
HepBoost
namespace and inside the zmpv namespace it typedef s UnitVector to be HepUnit3Vector The conversion which provide those methods available for GETTING INFORMATION if an object might be either a Rotation or a since RI has methods a routine can be passed a RI &and take because anything you wish to ask about a LT you could equally well ask about a Rotation From one derives Rotation and its special cases RotationX etc We can t derive RotationX from from one derives HepLorentzRotation along with HepBoost
Definition: keyMergeIssues.doc:304
CLHEP::HepRep4x4::xx_
double xx_
Definition: Geometry/CLHEP/Vector/RotationInterfaces.h:356
CLHEP::HepRep3x3::zx_
double zx_
Definition: Geometry/CLHEP/Vector/RotationInterfaces.h:329
CLHEP::HepRep4x4::zx_
double zx_
Definition: Geometry/CLHEP/Vector/RotationInterfaces.h:358
CLHEP::HepRep4x4Symmetric::getArray
void getArray(double *array) const
CLHEP::HepRep3x3::yy_
double yy_
Definition: Geometry/CLHEP/Vector/RotationInterfaces.h:328
CLHEP::HepRep4x4Symmetric::yy_
double yy_
Definition: Geometry/CLHEP/Vector/RotationInterfaces.h:390
CLHEP::HepRep4x4::HepRep4x4
HepRep4x4()
CLHEP::HepRep3x3::yz_
double yz_
Definition: Geometry/CLHEP/Vector/RotationInterfaces.h:328
CLHEP::HepRep4x4::yx_
double yx_
Definition: Geometry/CLHEP/Vector/RotationInterfaces.h:357
CLHEP::HepBoostX
Definition: Geometry/CLHEP/Vector/BoostX.h:42
CLHEP::Hep4RotationInterface::ToleranceTicks
@ ToleranceTicks
Definition: Geometry/CLHEP/Vector/RotationInterfaces.h:197
CLHEP::HepRep4x4Symmetric::HepRep4x4Symmetric
HepRep4x4Symmetric()
CLHEP::Hep4RotationInterface::getTolerance
static double getTolerance()
Definition: RotationInterfaces.cc:26
CLHEP::HepRep4x4::getArray
void getArray(double *array) const
CLHEP::HepRep3x3::HepRep3x3
HepRep3x3()
CLHEP::HepRep3x3
Definition: Geometry/CLHEP/Vector/RotationInterfaces.h:309
CLHEP::HepRep4x4::yy_
double yy_
Definition: Geometry/CLHEP/Vector/RotationInterfaces.h:357
CLHEP::HepRep4x4Symmetric::setToIdentity
void setToIdentity()
CLHEP::HepRep4x4Symmetric
Definition: Geometry/CLHEP/Vector/RotationInterfaces.h:370
axis
We have the boost methods returning HepLorentzVector &rather than so things can be chained we feel the boost methods along an axis
Definition: minorMergeIssues.doc:155
CLHEP::Hep4RotationInterface::tolerance
static double tolerance
Definition: Geometry/CLHEP/Vector/RotationInterfaces.h:118
CLHEP::HepRep4x4::yt_
double yt_
Definition: Geometry/CLHEP/Vector/RotationInterfaces.h:357
CLHEP::HepRep4x4Symmetric::xx_
double xx_
Definition: Geometry/CLHEP/Vector/RotationInterfaces.h:389
CLHEP::HepRep3x3::setToIdentity
void setToIdentity()
howNear
HepRotation and so forth howNear()
CLHEP::HepRep4x4::ty_
double ty_
Definition: Geometry/CLHEP/Vector/RotationInterfaces.h:359
CLHEP::HepRep4x4Symmetric::yt_
double yt_
Definition: Geometry/CLHEP/Vector/RotationInterfaces.h:390
CLHEP::HepRep3x3::zy_
double zy_
Definition: Geometry/CLHEP/Vector/RotationInterfaces.h:329
CLHEP::HepRotation
Definition: Geometry/CLHEP/Vector/Rotation.h:48
CLHEP::operator!=
bool operator!=(const HepRotation &r, const HepLorentzRotation &lt)
Definition: Geometry/CLHEP/Vector/LorentzRotation.h:354
CLHEP::HepRep4x4::xt_
double xt_
Definition: Geometry/CLHEP/Vector/RotationInterfaces.h:356
CLHEP::HepLorentzRotation
Definition: Geometry/CLHEP/Vector/LorentzRotation.h:54
CLHEP::HepRotationY
Definition: Geometry/CLHEP/Vector/RotationY.h:43
CLHEP::HepBoostY
Definition: Geometry/CLHEP/Vector/BoostY.h:42
CLHEP::Hep4RotationInterface
Definition: Geometry/CLHEP/Vector/RotationInterfaces.h:100
CLHEP::HepRep4x4::tx_
double tx_
Definition: Geometry/CLHEP/Vector/RotationInterfaces.h:359
CLHEP::HepRep4x4Symmetric::zt_
double zt_
Definition: Geometry/CLHEP/Vector/RotationInterfaces.h:391
CLHEP::HepRep3x3::zz_
double zz_
Definition: Geometry/CLHEP/Vector/RotationInterfaces.h:329
CLHEP::HepRep4x4
Definition: Geometry/CLHEP/Vector/RotationInterfaces.h:336
CLHEP::operator==
bool operator==(const HepRotation &r, const HepLorentzRotation &lt)
Definition: Geometry/CLHEP/Vector/LorentzRotation.h:352
psi
HepRotation psi() axis()
CLHEP::HepRep4x4Symmetric::tt_
double tt_
Definition: Geometry/CLHEP/Vector/RotationInterfaces.h:392
CLHEP::HepRep4x4::zz_
double zz_
Definition: Geometry/CLHEP/Vector/RotationInterfaces.h:358
CLHEP
Definition: ClhepVersion.h:13
CLHEP::HepRep4x4::zy_
double zy_
Definition: Geometry/CLHEP/Vector/RotationInterfaces.h:358
CLHEP::HepBoost
Definition: Geometry/CLHEP/Vector/Boost.h:43
v
they are gone ZOOM Features Discontinued The following features of the ZOOM package were felt to be extreme overkill These have been after checking that no existing user code was utilizing as in SpaceVector v
Definition: keyMergeIssues.doc:324
CLHEP::HepRep3x3::xy_
double xy_
Definition: Geometry/CLHEP/Vector/RotationInterfaces.h:327
CLHEP::HepRep4x4::operator==
bool operator==(HepRep4x4 const &r) const
rowY
HepRotation rowY()
CLHEP::HepRotationZ
Definition: Geometry/CLHEP/Vector/RotationZ.h:43
CLHEP::HepRep4x4Symmetric::yz_
double yz_
Definition: Geometry/CLHEP/Vector/RotationInterfaces.h:390
CLHEP::HepBoostZ
Definition: Geometry/CLHEP/Vector/BoostZ.h:42
CLHEP::Hep3Vector
Definition: Geometry/CLHEP/Vector/ThreeVector.h:41
CLHEP::HepRep3x3::xx_
double xx_
Definition: Geometry/CLHEP/Vector/RotationInterfaces.h:327
phi
we want to make it possible for the user to use the so we provide a few new for double double phi
Definition: minorMergeIssues.doc:20
HepBoostX
namespace and inside the zmpv namespace it typedef s UnitVector to be HepUnit3Vector The conversion which provide those methods available for GETTING INFORMATION if an object might be either a Rotation or a since RI has methods a routine can be passed a RI &and take because anything you wish to ask about a LT you could equally well ask about a Rotation From one derives Rotation and its special cases RotationX etc We can t derive RotationX from from one derives HepLorentzRotation along with HepBoostX
Definition: keyMergeIssues.doc:304
CLHEP::HepRep4x4::setToIdentity
void setToIdentity()
CLHEP::HepRep4x4::xy_
double xy_
Definition: Geometry/CLHEP/Vector/RotationInterfaces.h:356
CLHEP::HepRep4x4Symmetric::xy_
double xy_
Definition: Geometry/CLHEP/Vector/RotationInterfaces.h:389
CLHEP::HepRep4x4::tz_
double tz_
Definition: Geometry/CLHEP/Vector/RotationInterfaces.h:359
rowZ
HepRotation rowZ() phi()
CLHEP::HepLorentzVector
Definition: Geometry/CLHEP/Vector/LorentzVector.h:72
CLHEP::HepRep4x4::zt_
double zt_
Definition: Geometry/CLHEP/Vector/RotationInterfaces.h:358
CLHEP::Hep3RotationInterface
Definition: Geometry/CLHEP/Vector/RotationInterfaces.h:217
CLHEP::HepEulerAngles
Definition: Geometry/CLHEP/Vector/EulerAngles.h:32
CLHEP::HepRep3x3::yx_
double yx_
Definition: Geometry/CLHEP/Vector/RotationInterfaces.h:328
rowX
HepRotation rowX()
CLHEP::HepRep4x4::yz_
double yz_
Definition: Geometry/CLHEP/Vector/RotationInterfaces.h:357
CLHEP::HepRep4x4Symmetric::xz_
double xz_
Definition: Geometry/CLHEP/Vector/RotationInterfaces.h:389
CLHEP::operator*
HepLorentzRotation operator*(const HepRotation &r, const HepLorentzRotation &lt)
Definition: LorentzRotation.cc:262
CLHEP::HepRep4x4Symmetric::zz_
double zz_
Definition: Geometry/CLHEP/Vector/RotationInterfaces.h:391
CLHEP::HepRep3x3::getArray
void getArray(double *array) const
CLHEP::HepRep4x4Symmetric::xt_
double xt_
Definition: Geometry/CLHEP/Vector/RotationInterfaces.h:389
theta
we want to make it possible for the user to use the so we provide a few new for double theta
Definition: minorMergeIssues.doc:20
CLHEP::HepRep3x3::xz_
double xz_
Definition: Geometry/CLHEP/Vector/RotationInterfaces.h:327