Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 10:03:33

0001 // -*- C++ -*-
0002 // CLASSDOC OFF
0003 // ---------------------------------------------------------------------------
0004 // CLASSDOC ON
0005 
0006 #ifndef HEP_ROTATION_INTERFACES_H
0007 #define HEP_ROTATION_INTERFACES_H
0008 
0009 // This file is a part of the CLHEP - a Class Library for High Energy Physics.
0010 //
0011 // This contains the definition of two abstract interface classes:
0012 // Hep4RotationInterface 
0013 // Hep3RotationInterface.  
0014 // However, these are mostly for defining methods which should be present in
0015 // any 4- or 3-rotation class, however specialized.  The actual classes do
0016 // not inherit from these.  The virtual function overhead turns out 
0017 // to be too steep for that to be practical.
0018 //
0019 // It may be desirable in the future to turn these classes into constraints
0020 // in the Stroustrup sense, so as to enforce this interface, still without 
0021 // inheritance.  However, they do contain an important static:
0022 // static double tolerance to set criteria for relative nearness.
0023 //
0024 // This file also defines structs 
0025 // HepRep3x3;
0026 // HepRep4x4;
0027 // HepRep4x4Symmetric;
0028 // which are used by various Rotation classes.
0029 // 
0030 // Hep4RotationInterface 
0031 //  contains all the methods to get attributes of either a
0032 //  HepLorentzRotation or a HepRotation -- any information 
0033 //  that pertains to a LorentzRotation can also be defined
0034 //  for a HepRotation.(For example, the 4x4 representation
0035 //  would just have 0's in the space-time entries and 1 in
0036 //  the time-time entry.) 
0037 //
0038 // Hep3RotationInterface 
0039 //  inherits from Hep4RotationInterface,  and adds methods
0040 //  which are well-defined only in the case of a Rotation.
0041 //  For example, a 3x3 representation is an attribute only
0042 //  if the generic LorentzRotation involves no boost.
0043 //
0044 // In terms of classes in the ZOOM PhysicsVectors package, 
0045 //  Hep4RotationInterface <--> LorentzTransformationInterface
0046 //  Hep3RotationInterface <--> RotationInterface
0047 //
0048 // Hep4RotationInterface defines the required methods for:
0049 //  HepLorentzRotation
0050 //  HepBoost
0051 //  HepBoostX
0052 //  HepBoostY
0053 //  HepBoostZ
0054 //
0055 // Hep3RotationInterface defines the required methods for:
0056 //  HepRotation
0057 //  HepRotationX
0058 //  HepRotationY
0059 //  HepRotationZ
0060 //
0061 // .SS See Also
0062 // Rotation.h, LorentzRotation.h
0063 //
0064 // .SS Author
0065 // Mark Fischler
0066 //
0067 
0068 #include "CLHEP/Vector/defs.h" 
0069 #include "CLHEP/Vector/ThreeVector.h"
0070 #include "CLHEP/Vector/LorentzVector.h"
0071 #include "CLHEP/Vector/AxisAngle.h"
0072 
0073 namespace CLHEP {
0074 
0075 struct HepRep3x3;
0076 struct HepRep4x4;
0077 struct HepRep4x4Symmetric;
0078 
0079 class HepRotation;
0080 class HepRotationX;
0081 class HepRotationY;
0082 class HepRotationZ;
0083 class HepLorentzRotation;
0084 class HepBoost;
0085 class HepBoostX;
0086 class HepBoostY;
0087 class HepBoostZ;
0088 
0089 //-******************************
0090 //
0091 // Hep4RotationInterface 
0092 //
0093 //-******************************
0094 
0095 /**
0096  * @author
0097  * @ingroup vector
0098  */
0099 class Hep4RotationInterface  {
0100 
0101   // All attributes of shared by HepLorentzRotation, HepBoost, 
0102   // HepBoostX, HepBoostY, HepBoostZ.  HepRotation, HepRotationX, 
0103   // HepRotationY, HepRotationZ also share this attribute interface.
0104 
0105   friend class  HepRotation;
0106   friend class  HepRotationX;
0107   friend class  HepRotationY;
0108   friend class  HepRotationZ;
0109   friend class  HepLorentzRotation;
0110   friend class  HepBoost;
0111   friend class  HepBoostX;
0112   friend class  HepBoostY;
0113   friend class  HepBoostZ;
0114 
0115 public:
0116 
0117   static double tolerance;        // to determine relative nearness
0118 
0119   // ----------  Accessors:
0120 
0121 #ifdef ONLY_IN_CONCRETE_CLASSES
0122   //  orthosymplectic 4-vectors:
0123   HepLorentzVector col1() const;
0124   HepLorentzVector col2() const;
0125   HepLorentzVector col3() const;
0126   HepLorentzVector col4() const;
0127   HepLorentzVector row1() const;
0128   HepLorentzVector row2() const;
0129   HepLorentzVector row3() const;
0130   HepLorentzVector row4() const;
0131 
0132   //  individual elements:
0133   double xx() const  ;
0134   double xy() const  ;
0135   double xz() const  ;
0136   double xt() const  ;
0137   double yx() const  ;
0138   double yy() const  ;
0139   double yz() const  ;
0140   double yt() const  ;
0141   double zx() const  ;
0142   double zy() const  ;
0143   double zz() const  ;
0144   double zt() const  ;
0145   double tx() const  ;
0146   double ty() const  ;
0147   double tz() const  ;
0148   double tt() const  ;
0149 
0150   //   4x4 representation:
0151 //HepRep4x4 rep4x4() const; JMM  Declared here but not defined anywhere!
0152 
0153   // ----------  Operations:
0154   //   comparisons:
0155 
0156   inline int compare( const Hep4RotationInterface & lt ) const;
0157   // Dictionary-order comparisons, utilizing the decompose(b,r) method
0158 
0159   //   decomposition:
0160 
0161   void decompose (HepAxisAngle & rotation, Hep3Vector & boost)const;
0162   // Decompose as T= R * B, where R is pure rotation, B is pure boost.
0163 
0164   void decompose (Hep3Vector & boost, HepAxisAngle & rotation)const;
0165   // Decompose as T= B * R, where R is pure rotation, B is pure boost.
0166 
0167   bool operator == (const Hep4RotationInterface & r) const;
0168   bool operator != (const Hep4RotationInterface & r) const;
0169 
0170   //   relative comparison:
0171 
0172   double norm2() const  ;
0173   double  distance2( const Hep4RotationInterface & lt ) const  ;
0174   double  howNear( const Hep4RotationInterface & lt ) const  ;
0175   bool isNear (const Hep4RotationInterface & lt, 
0176                    double epsilon=tolerance) const  ;
0177 
0178   void rectify()  ;
0179   // non-const but logically const correction for accumulated roundoff errors
0180 
0181   // ----------  Apply LorentzTransformations:
0182 
0183   HepLorentzVector operator* ( const HepLorentzVector & w ) const  ;
0184   HepLorentzVector operator()( const HepLorentzVector & w ) const  ;
0185   // Apply to a 4-vector
0186 
0187   // ----------  I/O:
0188 
0189   std::ostream & print( std::ostream & os ) const;
0190 
0191 #endif /* ONLY_IN_CONCRETE_CLASSES */
0192 
0193   static double getTolerance();
0194   static double setTolerance( double tol );
0195 
0196   static const int ToleranceTicks = 100;
0197 
0198 protected:
0199 
0200   ~Hep4RotationInterface() {}   // protect destructor to forbid instatiation
0201 
0202 };  // Hep4RotationInterface
0203 
0204 
0205 //-******************************
0206 //
0207 // Hep3RotationInterface 
0208 //
0209 //-******************************
0210 
0211 /**
0212  * @author
0213  * @ingroup vector
0214  */
0215 class Hep3RotationInterface : public Hep4RotationInterface {
0216 
0217   // All attributes of HepRotation, HepRotationX, HepRotationY, HepRotationZ
0218   // beyond those available by virtue of being a Hep3RotationInterface.
0219 
0220   friend class  HepRotation;
0221   friend class  HepRotationX;
0222   friend class  HepRotationY;
0223   friend class  HepRotationZ;
0224 
0225 public:
0226 
0227 #ifdef ONLY_IN_CONCRETE_CLASSES
0228 
0229   //   Euler angles:
0230   double getPhi  () const  ;
0231   double getTheta() const  ;
0232   double getPsi  () const  ;
0233   double    phi  () const  ;
0234   double    theta() const  ;
0235   double    psi  () const  ;
0236   HepEulerAngles eulerAngles() const  ;
0237 
0238   //   axis & angle of rotation:
0239   double  getDelta() const  ;
0240   Hep3Vector getAxis () const  ;
0241   double     delta() const  ;
0242   Hep3Vector    axis () const  ;
0243   HepAxisAngle axisAngle() const  ;
0244 
0245   //   orthogonal unit-length vectors:
0246   Hep3Vector rowX() const;
0247   Hep3Vector rowY() const;
0248   Hep3Vector rowZ() const;
0249 
0250   Hep3Vector colX() const;
0251   Hep3Vector colY() const;
0252   Hep3Vector colZ() const;
0253 
0254 //HepRep3x3 rep3x3() const; JMM  Declared here but not defined anywhere!
0255   //   3x3 representation
0256 
0257   //  orthosymplectic 4-vectors treating this as a 4-rotation:
0258   HepLorentzVector col1() const;
0259   HepLorentzVector col2() const;
0260   HepLorentzVector col3() const;
0261   HepLorentzVector col4() const;
0262   HepLorentzVector row1() const;
0263   HepLorentzVector row2() const;
0264   HepLorentzVector row3() const;
0265   HepLorentzVector row4() const;
0266 
0267   //  individual elements treating this as a 4-rotation:
0268   double xt() const; 
0269   double yt() const; 
0270   double zt() const; 
0271   double tx() const; 
0272   double ty() const;
0273   double tz() const;
0274   double tt() const;
0275 
0276   // ---------- Operations in the Rotation group
0277 
0278   HepRotation operator * ( const Hep3RotationInterface & r ) const  ;
0279 
0280   // ---------- Application
0281 
0282   HepLorentzVector operator* ( const HepLorentzVector & w ) const  ;
0283   HepLorentzVector operator()( const HepLorentzVector & w ) const  ;
0284   //   apply to HepLorentzVector
0285 
0286   Hep3Vector operator* ( const Hep3Vector & v ) const  ;
0287   Hep3Vector operator()( const Hep3Vector & v ) const  ;
0288   //   apply to Hep3Vector
0289 
0290   // ---------- I/O and a helper method
0291 
0292   std::ostream & print( std::ostream & os ) const;
0293 
0294 #endif /* ONLY_IN_CONCRETE_CLASSES */
0295 
0296 private:
0297 
0298   ~Hep3RotationInterface() {}   // private destructor to forbid instatiation
0299 
0300 };  // Hep3RotationInterface
0301 
0302 //-***************************
0303 // 3x3 and 4x4 representations
0304 //-***************************
0305 
0306 struct HepRep3x3 {
0307 
0308   // -----  Constructors:
0309 
0310   inline HepRep3x3();
0311 
0312   inline HepRep3x3(  double xx, double xy, double xz
0313                    , double yx, double yy, double yz
0314                    , double zx, double zy, double zz
0315                    );
0316 
0317   inline HepRep3x3( const double * array );
0318   // construct from an array of doubles, holding the rotation matrix
0319   // in ROW order (xx, xy, ...)
0320 
0321   inline void setToIdentity();
0322 
0323   // -----  The data members are public:
0324   double xx_, xy_, xz_,
0325             yx_, yy_, yz_,
0326             zx_, zy_, zz_;
0327 
0328   inline void getArray ( double * array ) const;
0329   // fill array with the NINE doubles xx, xy, xz ... zz
0330 
0331 };  // HepRep3x3
0332 
0333 struct HepRep4x4 {
0334 
0335   // -----  Constructors:
0336   inline HepRep4x4();
0337 
0338   inline HepRep4x4(  double xx, double xy, double xz, double xt
0339                    , double yx, double yy, double yz, double yt
0340                    , double zx, double zy, double zz, double zt
0341                    , double tx, double ty, double tz, double tt
0342                    );
0343 
0344   inline HepRep4x4( const HepRep4x4Symmetric & rep );
0345 
0346   inline HepRep4x4( const double * array );
0347   // construct from an array of doubles, holding the transformation matrix
0348   // in ROW order xx, xy, ...
0349 
0350   inline void setToIdentity();
0351 
0352   // -----  The data members are public:
0353   double xx_, xy_, xz_, xt_,
0354             yx_, yy_, yz_, yt_,
0355             zx_, zy_, zz_, zt_,
0356             tx_, ty_, tz_, tt_;
0357                          
0358   inline void getArray ( double * array ) const;
0359   // fill array with the SIXTEEN doubles xx, xy, xz ... tz, tt
0360 
0361   inline bool operator==(HepRep4x4 const & r) const;
0362   inline bool operator!=(HepRep4x4 const & r) const;
0363 
0364 
0365 };  // HepRep4x4
0366 
0367 struct HepRep4x4Symmetric {
0368 
0369   // -----  Constructors:
0370 
0371   inline HepRep4x4Symmetric();
0372 
0373   inline HepRep4x4Symmetric
0374     ( double xx, double xy, double xz, double xt
0375                       , double yy, double yz, double yt
0376                                     , double zz, double zt
0377                                                   , double tt );
0378 
0379   inline HepRep4x4Symmetric( const double * array );
0380   // construct from an array of doubles, holding the transformation matrix
0381   // elements in this order:  xx, xy, xz, xt, yy, yz, yt, zz, zt, tt
0382 
0383   inline void setToIdentity();
0384 
0385   // -----  The data members are public:
0386   double xx_, xy_, xz_, xt_,
0387                  yy_, yz_, yt_,
0388                       zz_, zt_,
0389                            tt_;
0390 
0391   inline void getArray ( double * array ) const;
0392   // fill array with the TEN doubles xx, xy, xz, xt, yy, yz, yt, zz, zt, tt
0393 
0394 };
0395 
0396 }  // namespace CLHEP
0397 
0398 #include "CLHEP/Vector/RotationInterfaces.icc"
0399 
0400 #ifdef ENABLE_BACKWARDS_COMPATIBILITY
0401 //  backwards compatibility will be enabled ONLY in CLHEP 1.9
0402 using namespace CLHEP;
0403 #endif
0404 
0405 #endif // ROTATION_INTERFACES_H