CLHEP 2.0.4.7 Reference Documentation
   
CLHEP Home Page     CLHEP Documentation     CLHEP Bug Reports

RotationInterfaces.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 // CLASSDOC OFF
00003 // ---------------------------------------------------------------------------
00004 // CLASSDOC ON
00005 
00006 #ifndef HEP_ROTATION_INTERFACES_H
00007 #define HEP_ROTATION_INTERFACES_H
00008 
00009 // This file is a part of the CLHEP - a Class Library for High Energy Physics.
00010 //
00011 // This contains the definition of two abstract interface classes:
00012 // Hep4RotationInterface 
00013 // Hep3RotationInterface.  
00014 // However, these are mostly for defining methods which should be present in
00015 // any 4- or 3-rotation class, however specialized.  The actual classes do
00016 // not inherit from these.  The virtual function overhead turns out 
00017 // to be too steep for that to be practical.
00018 //
00019 // It may be desirable in the future to turn these classes into constraints
00020 // in the Stroustrup sense, so as to enforce this interface, still without 
00021 // inheritance.  However, they do contain an important static:
00022 // static double tolerance to set criteria for relative nearness.
00023 //
00024 // This file also defines structs 
00025 // HepRep3x3;
00026 // HepRep4x4;
00027 // HepRep4x4Symmetric;
00028 // which are used by various Rotation classes.
00029 // 
00030 // Hep4RotationInterface 
00031 //      contains all the methods to get attributes of either a
00032 //      HepLorentzRotation or a HepRotation -- any information 
00033 //      that pertains to a LorentzRotation can also be defined
00034 //      for a HepRotation.(For example, the 4x4 representation
00035 //      would just have 0's in the space-time entries and 1 in
00036 //      the time-time entry.) 
00037 //
00038 // Hep3RotationInterface 
00039 //      inherits from Hep4RotationInterface,  and adds methods
00040 //      which are well-defined only in the case of a Rotation.
00041 //      For example, a 3x3 representation is an attribute only
00042 //      if the generic LorentzRotation involves no boost.
00043 //
00044 // In terms of classes in the ZOOM PhysicsVectors package, 
00045 //      Hep4RotationInterface <--> LorentzTransformationInterface
00046 //      Hep3RotationInterface <--> RotationInterface
00047 //
00048 // Hep4RotationInterface defines the required methods for:
00049 //      HepLorentzRotation
00050 //      HepBoost
00051 //      HepBoostX
00052 //      HepBoostY
00053 //      HepBoostZ
00054 //
00055 // Hep3RotationInterface defines the required methods for:
00056 //      HepRotation
00057 //      HepRotationX
00058 //      HepRotationY
00059 //      HepRotationZ
00060 //
00061 // .SS See Also
00062 // Rotation.h, LorentzRotation.h
00063 //
00064 // .SS Author
00065 // Mark Fischler
00066 //
00067 
00068 #include "CLHEP/Vector/defs.h" 
00069 #include "CLHEP/Vector/ThreeVector.h"
00070 #include "CLHEP/Vector/LorentzVector.h"
00071 #include "CLHEP/Vector/AxisAngle.h"
00072 
00073 namespace CLHEP {
00074 
00075 struct HepRep3x3;
00076 struct HepRep4x4;
00077 struct HepRep4x4Symmetric;
00078 
00079 class HepRotation;
00080 class HepRotationX;
00081 class HepRotationY;
00082 class HepRotationZ;
00083 class HepLorentzRotation;
00084 class HepBoost;
00085 class HepBoostX;
00086 class HepBoostY;
00087 class HepBoostZ;
00088 
00089 
00090 //-******************************
00091 //
00092 // Hep4RotationInterface 
00093 //
00094 //-******************************
00095 
00100 class Hep4RotationInterface  {
00101 
00102   // All attributes of shared by HepLorentzRotation, HepBoost, 
00103   // HepBoostX, HepBoostY, HepBoostZ.  HepRotation, HepRotationX, 
00104   // HepRotationY, HepRotationZ also share this attribute interface.
00105 
00106   friend class  HepRotation;
00107   friend class  HepRotationX;
00108   friend class  HepRotationY;
00109   friend class  HepRotationZ;
00110   friend class  HepLorentzRotation;
00111   friend class  HepBoost;
00112   friend class  HepBoostX;
00113   friend class  HepBoostY;
00114   friend class  HepBoostZ;
00115 
00116 public:
00117 
00118   static double tolerance;        // to determine relative nearness
00119 
00120   // ----------  Accessors:
00121 
00122 #ifdef ONLY_IN_CONCRETE_CLASSES
00123   //  orthosymplectic 4-vectors:
00124   HepLorentzVector col1() const;
00125   HepLorentzVector col2() const;
00126   HepLorentzVector col3() const;
00127   HepLorentzVector col4() const;
00128   HepLorentzVector row1() const;
00129   HepLorentzVector row2() const;
00130   HepLorentzVector row3() const;
00131   HepLorentzVector row4() const;
00132 
00133   //  individual elements:
00134   double xx() const  ;
00135   double xy() const  ;
00136   double xz() const  ;
00137   double xt() const  ;
00138   double yx() const  ;
00139   double yy() const  ;
00140   double yz() const  ;
00141   double yt() const  ;
00142   double zx() const  ;
00143   double zy() const  ;
00144   double zz() const  ;
00145   double zt() const  ;
00146   double tx() const  ;
00147   double ty() const  ;
00148   double tz() const  ;
00149   double tt() const  ;
00150 
00151   //   4x4 representation:
00152 //HepRep4x4 rep4x4() const;     JMM  Declared here but not defined anywhere!
00153 
00154   // ----------  Operations:
00155   //   comparisons:
00156 
00157   inline int compare( const Hep4RotationInterface & lt ) const;
00158   // Dictionary-order comparisons, utilizing the decompose(b,r) method
00159 
00160   //   decomposition:
00161 
00162   void decompose (HepAxisAngle & rotation, Hep3Vector & boost)const;
00163   // Decompose as T= R * B, where R is pure rotation, B is pure boost.
00164 
00165   void decompose (Hep3Vector & boost, HepAxisAngle & rotation)const;
00166   // Decompose as T= B * R, where R is pure rotation, B is pure boost.
00167 
00168   bool operator == (const Hep4RotationInterface & r) const;
00169   bool operator != (const Hep4RotationInterface & r) const;
00170 
00171   //   relative comparison:
00172 
00173   double norm2() const  ;
00174   double  distance2( const Hep4RotationInterface & lt ) const  ;
00175   double  howNear( const Hep4RotationInterface & lt ) const  ;
00176   bool isNear (const Hep4RotationInterface & lt, 
00177                                    double epsilon=tolerance) const  ;
00178 
00179   void rectify()  ;
00180   // non-const but logically const correction for accumulated roundoff errors
00181 
00182   // ----------  Apply LorentzTransformations:
00183 
00184   HepLorentzVector operator* ( const HepLorentzVector & w ) const  ;
00185   HepLorentzVector operator()( const HepLorentzVector & w ) const  ;
00186   // Apply to a 4-vector
00187 
00188   // ----------  I/O:
00189 
00190   std::ostream & print( std::ostream & os ) const;
00191 
00192 #endif /* ONLY_IN_CONCRETE_CLASSES */
00193 
00194   static double getTolerance();
00195   static double setTolerance( double tol );
00196 
00197   enum { ToleranceTicks = 100 };
00198 
00199 protected:
00200 
00201   ~Hep4RotationInterface() {}   // protect destructor to forbid instatiation
00202 
00203 };  // Hep4RotationInterface
00204 
00205 
00206 
00207 //-******************************
00208 //
00209 // Hep3RotationInterface 
00210 //
00211 //-******************************
00212 
00217 class Hep3RotationInterface : public Hep4RotationInterface {
00218 
00219   // All attributes of HepRotation, HepRotationX, HepRotationY, HepRotationZ
00220   // beyond those available by virtue of being a Hep3RotationInterface.
00221 
00222   friend class  HepRotation;
00223   friend class  HepRotationX;
00224   friend class  HepRotationY;
00225   friend class  HepRotationZ;
00226 
00227 public:
00228 
00229 #ifdef ONLY_IN_CONCRETE_CLASSES
00230 
00231   //   Euler angles:
00232   double getPhi  () const  ;
00233   double getTheta() const  ;
00234   double getPsi  () const  ;
00235   double    phi  () const  ;
00236   double    theta() const  ;
00237   double    psi  () const  ;
00238   HepEulerAngles eulerAngles() const  ;
00239 
00240   //   axis & angle of rotation:
00241   double  getDelta() const  ;
00242   Hep3Vector getAxis () const  ;
00243   double     delta() const  ;
00244   Hep3Vector    axis () const  ;
00245   HepAxisAngle axisAngle() const  ;
00246 
00247   //   orthogonal unit-length vectors:
00248   Hep3Vector rowX() const;
00249   Hep3Vector rowY() const;
00250   Hep3Vector rowZ() const;
00251 
00252   Hep3Vector colX() const;
00253   Hep3Vector colY() const;
00254   Hep3Vector colZ() const;
00255 
00256 //HepRep3x3 rep3x3() const;     JMM  Declared here but not defined anywhere!
00257   //   3x3 representation
00258 
00259   //  orthosymplectic 4-vectors treating this as a 4-rotation:
00260   HepLorentzVector col1() const;
00261   HepLorentzVector col2() const;
00262   HepLorentzVector col3() const;
00263   HepLorentzVector col4() const;
00264   HepLorentzVector row1() const;
00265   HepLorentzVector row2() const;
00266   HepLorentzVector row3() const;
00267   HepLorentzVector row4() const;
00268 
00269   //  individual elements treating this as a 4-rotation:
00270   double xt() const; 
00271   double yt() const; 
00272   double zt() const; 
00273   double tx() const; 
00274   double ty() const;
00275   double tz() const;
00276   double tt() const;
00277 
00278   // ---------- Operations in the Rotation group
00279 
00280   HepRotation operator * ( const Hep3RotationInterface & r ) const  ;
00281 
00282   // ---------- Application
00283 
00284   HepLorentzVector operator* ( const HepLorentzVector & w ) const  ;
00285   HepLorentzVector operator()( const HepLorentzVector & w ) const  ;
00286   //   apply to HepLorentzVector
00287 
00288   Hep3Vector operator* ( const Hep3Vector & v ) const  ;
00289   Hep3Vector operator()( const Hep3Vector & v ) const  ;
00290   //   apply to Hep3Vector
00291 
00292   // ---------- I/O and a helper method
00293 
00294   std::ostream & print( std::ostream & os ) const;
00295 
00296 #endif /* ONLY_IN_CONCRETE_CLASSES */
00297 
00298 private:
00299 
00300   ~Hep3RotationInterface() {}   // private destructor to forbid instatiation
00301 
00302 };  // Hep3RotationInterface
00303 
00304 
00305 //-***************************
00306 // 3x3 and 4x4 representations
00307 //-***************************
00308 
00309 struct HepRep3x3 {
00310 
00311   // -----  Constructors:
00312 
00313   inline HepRep3x3();
00314 
00315   inline HepRep3x3(  double xx, double xy, double xz
00316                    , double yx, double yy, double yz
00317                    , double zx, double zy, double zz
00318                    );
00319 
00320   inline HepRep3x3( const double * array );
00321   // construct from an array of doubles, holding the rotation matrix
00322   // in ROW order (xx, xy, ...)
00323 
00324   inline void setToIdentity();
00325 
00326   // -----  The data members are public:
00327   double xx_, xy_, xz_,
00328             yx_, yy_, yz_,
00329             zx_, zy_, zz_;
00330 
00331   inline void getArray ( double * array ) const;
00332   // fill array with the NINE doubles xx, xy, xz ... zz
00333 
00334 };  // HepRep3x3
00335 
00336 struct HepRep4x4 {
00337 
00338   // -----  Constructors:
00339   inline HepRep4x4();
00340 
00341   inline HepRep4x4(  double xx, double xy, double xz, double xt
00342                    , double yx, double yy, double yz, double yt
00343                    , double zx, double zy, double zz, double zt
00344                    , double tx, double ty, double tz, double tt
00345                    );
00346 
00347   inline HepRep4x4( const HepRep4x4Symmetric & rep );
00348 
00349   inline HepRep4x4( const double * array );
00350   // construct from an array of doubles, holding the transformation matrix
00351   // in ROW order xx, xy, ...
00352 
00353   inline void setToIdentity();
00354 
00355   // -----  The data members are public:
00356   double xx_, xy_, xz_, xt_,
00357             yx_, yy_, yz_, yt_,
00358             zx_, zy_, zz_, zt_,
00359             tx_, ty_, tz_, tt_;
00360                          
00361   inline void getArray ( double * array ) const;
00362   // fill array with the SIXTEEN doubles xx, xy, xz ... tz, tt
00363 
00364   inline bool operator==(HepRep4x4 const & r) const;
00365   inline bool operator!=(HepRep4x4 const & r) const;
00366 
00367 
00368 };  // HepRep4x4
00369 
00370 struct HepRep4x4Symmetric {
00371 
00372   // -----  Constructors:
00373 
00374   inline HepRep4x4Symmetric();
00375 
00376   inline HepRep4x4Symmetric
00377         ( double xx, double xy, double xz, double xt
00378                       , double yy, double yz, double yt
00379                                     , double zz, double zt
00380                                                   , double tt );
00381 
00382   inline HepRep4x4Symmetric( const double * array );
00383   // construct from an array of doubles, holding the transformation matrix
00384   // elements in this order:  xx, xy, xz, xt, yy, yz, yt, zz, zt, tt
00385 
00386   inline void setToIdentity();
00387 
00388   // -----  The data members are public:
00389   double xx_, xy_, xz_, xt_,
00390                  yy_, yz_, yt_,
00391                       zz_, zt_,
00392                            tt_;
00393 
00394   inline void getArray ( double * array ) const;
00395   // fill array with the TEN doubles xx, xy, xz, xt, yy, yz, yt, zz, zt, tt
00396 
00397 };
00398 
00399 }  // namespace CLHEP
00400 
00401 #include "CLHEP/Vector/RotationInterfaces.icc"
00402 
00403 #ifdef ENABLE_BACKWARDS_COMPATIBILITY
00404 //  backwards compatibility will be enabled ONLY in CLHEP 1.9
00405 using namespace CLHEP;
00406 #endif
00407 
00408 #endif // ROTATION_INTERFACES_H

Generated on Thu Jul 1 22:02:31 2010 for CLHEP by  doxygen 1.4.7