Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:54:41

0001 // -*- C++ -*-
0002 // CLASSDOC OFF
0003 // ---------------------------------------------------------------------------
0004 // CLASSDOC ON
0005 //
0006 // This file is a part of the CLHEP - a Class Library for High Energy Physics.
0007 //
0008 // This is the definition of the HepRotationX class for performing rotations
0009 // around the X axis on objects of the Hep3Vector (and HepLorentzVector) class.
0010 //
0011 // HepRotationX is a concrete implementation of Hep3RotationInterface.
0012 //
0013 // .SS See Also
0014 // RotationInterfaces.h
0015 // ThreeVector.h, LorentzVector.h, LorentzRotation.h
0016 //
0017 // .SS Author
0018 // Mark Fischler
0019 
0020 #ifndef HEP_ROTATIONX_H
0021 #define HEP_ROTATIONX_H
0022 
0023 #include "CLHEP/Vector/defs.h" 
0024 #include "CLHEP/Vector/RotationInterfaces.h"
0025 
0026 namespace CLHEP  {
0027 
0028 class HepRotationX;
0029 
0030 class HepRotation;
0031 class HepBoost;
0032 
0033 inline HepRotationX inverseOf(const HepRotationX & r);
0034 // Returns the inverse of a RotationX.
0035 
0036 /**
0037  * @author
0038  * @ingroup vector
0039  */
0040 class HepRotationX {
0041 
0042 public:
0043 
0044   // ----------  Constructors and Assignment:
0045 
0046   inline HepRotationX();
0047   // Default constructor. Gives an identity rotation. 
0048 
0049   HepRotationX(double delta);
0050   // supply angle of rotation 
0051 
0052   inline HepRotationX(const HepRotationX & orig);
0053   inline HepRotationX(HepRotationX && orig) = default;
0054   // Copy and move constructors.
0055 
0056   inline HepRotationX & operator = (const HepRotationX & r);
0057   inline HepRotationX & operator = (HepRotationX && r) = default;
0058   // Copy and move assignments from a Rotation, which must be RotationX
0059 
0060   HepRotationX & set ( double delta );
0061   // set angle of rotation 
0062 
0063   inline ~HepRotationX();
0064   // Trivial destructor.
0065 
0066   // ----------  Accessors:
0067 
0068   inline Hep3Vector colX() const;
0069   inline Hep3Vector colY() const;
0070   inline Hep3Vector colZ() const;
0071   // orthogonal unit-length column vectors
0072 
0073   inline Hep3Vector rowX() const;
0074   inline Hep3Vector rowY() const;
0075   inline Hep3Vector rowZ() const;
0076   // orthogonal unit-length row vectors
0077                                 
0078   inline double xx() const;
0079   inline double xy() const;
0080   inline double xz() const;
0081   inline double yx() const;
0082   inline double yy() const;
0083   inline double yz() const;
0084   inline double zx() const;
0085   inline double zy() const;
0086   inline double zz() const;
0087   // Elements of the rotation matrix (Geant4).
0088 
0089   inline HepRep3x3 rep3x3() const;
0090   //   3x3 representation:
0091 
0092   // ------------  Euler angles:
0093   inline  double getPhi  () const;
0094   inline  double getTheta() const;
0095   inline  double getPsi  () const;
0096   double    phi  () const;
0097   double    theta() const;
0098   double    psi  () const;
0099   HepEulerAngles eulerAngles() const;
0100 
0101   // ------------  axis & angle of rotation:
0102   inline  double  getDelta() const;
0103   inline  Hep3Vector getAxis () const;
0104   inline  double     delta() const;
0105   inline  Hep3Vector    axis () const;
0106   inline  HepAxisAngle  axisAngle() const;
0107   inline  void getAngleAxis(double & delta, Hep3Vector & axis) const;
0108   // Returns the rotation angle and rotation axis (Geant4).     
0109 
0110   // ------------- Angles of rotated axes
0111   double phiX() const;
0112   double phiY() const;
0113   double phiZ() const;
0114   double thetaX() const;
0115   double thetaY() const;
0116   double thetaZ() const;
0117   // Return angles (RADS) made by rotated axes against original axes (Geant4).
0118 
0119   // ----------  Other accessors treating pure rotation as a 4-rotation
0120 
0121   inline HepLorentzVector col1() const;
0122   inline HepLorentzVector col2() const;
0123   inline HepLorentzVector col3() const;
0124   //  orthosymplectic 4-vector columns - T component will be zero
0125 
0126   inline HepLorentzVector col4() const;
0127   // Will be (0,0,0,1) for this pure Rotation.
0128 
0129   inline HepLorentzVector row1() const;
0130   inline HepLorentzVector row2() const;
0131   inline HepLorentzVector row3() const;
0132   //  orthosymplectic 4-vector rows - T component will be zero
0133 
0134   inline HepLorentzVector row4() const;
0135   // Will be (0,0,0,1) for this pure Rotation.
0136 
0137   inline double xt() const;
0138   inline double yt() const;
0139   inline double zt() const;
0140   inline double tx() const;
0141   inline double ty() const;
0142   inline double tz() const;
0143   // Will be zero for this pure Rotation
0144 
0145   inline double tt() const;
0146   // Will be one for this pure Rotation
0147 
0148   inline HepRep4x4 rep4x4() const;
0149   //   4x4 representation.
0150 
0151   // ---------   Mutators 
0152 
0153   void setDelta (double delta);
0154   // change angle of rotation, leaving rotation axis unchanged.
0155 
0156   // ----------  Decomposition:
0157 
0158   void decompose (HepAxisAngle & rotation, Hep3Vector & boost) const;
0159   void decompose (Hep3Vector & boost, HepAxisAngle & rotation) const;
0160   void decompose (HepRotation & rotation, HepBoost & boost) const;
0161   void decompose (HepBoost & boost, HepRotation & rotation) const;
0162   // These are trivial, as the boost vector is 0.       
0163 
0164   // ----------  Comparisons: 
0165   
0166   inline bool isIdentity() const;               
0167   // Returns true if the identity matrix (Geant4).  
0168 
0169   inline int compare( const HepRotationX & r  ) const;
0170   // Dictionary-order comparison, in order of delta
0171   // Used in operator<, >, <=, >= 
0172 
0173   inline bool operator== ( const HepRotationX & r ) const;
0174   inline bool operator!= ( const HepRotationX & r ) const;
0175   inline bool operator<  ( const HepRotationX & r ) const;
0176   inline bool operator>  ( const HepRotationX & r ) const;
0177   inline bool operator<= ( const HepRotationX & r ) const;
0178   inline bool operator>= ( const HepRotationX & r ) const;
0179   
0180   double distance2( const HepRotationX & r  ) const; 
0181   // 3 - Tr ( this/r )
0182 
0183   double distance2( const HepRotation &  r  ) const; 
0184   // 3 - Tr ( this/r ) -- This works with RotationY or Z also
0185 
0186   double howNear( const HepRotationX & r ) const;
0187   double howNear( const HepRotation  & r ) const;
0188   bool isNear( const HepRotationX & r,
0189                double epsilon=Hep4RotationInterface::tolerance) const;
0190   bool isNear( const HepRotation  & r,
0191                double epsilon=Hep4RotationInterface::tolerance) const;
0192 
0193   double distance2( const HepBoost           & lt  ) const; 
0194   // 3 - Tr ( this ) + |b|^2 / (1-|b|^2) 
0195   double distance2( const HepLorentzRotation & lt  ) const; 
0196   // 3 - Tr ( this/r ) + |b|^2 / (1-|b|^2) where b is the boost vector of lt
0197 
0198   double howNear( const HepBoost           & lt ) const;
0199   double howNear( const HepLorentzRotation & lt ) const;
0200   bool isNear( const HepBoost           & lt, 
0201                double epsilon=Hep4RotationInterface::tolerance) const;
0202   bool isNear( const HepLorentzRotation & lt,
0203                double epsilon=Hep4RotationInterface::tolerance) const;
0204 
0205   // ----------  Properties:
0206 
0207   double norm2() const; 
0208   // distance2 (IDENTITY), which is 3 - Tr ( *this )
0209 
0210   inline void rectify();
0211   // non-const but logically moot correction for accumulated roundoff errors
0212 
0213   // ---------- Application:
0214 
0215   inline Hep3Vector operator() (const Hep3Vector & p) const;
0216   // Rotate a Hep3Vector.                   
0217 
0218   inline  Hep3Vector operator * (const Hep3Vector & p) const;
0219   // Multiplication with a Hep3Vector.
0220 
0221   inline HepLorentzVector operator()( const HepLorentzVector & w ) const;
0222   // Rotate (the space part of) a HepLorentzVector.     
0223 
0224   inline  HepLorentzVector operator* ( const HepLorentzVector & w ) const;
0225   // Multiplication with a HepLorentzVector.
0226 
0227   // ---------- Operations in the group of Rotations 
0228 
0229   inline HepRotationX operator * (const HepRotationX & rx) const;
0230   // Product of two X rotations: (this) * rx is known to be RotationX.
0231 
0232   inline  HepRotationX & operator *= (const HepRotationX & r);
0233   inline  HepRotationX & transform   (const HepRotationX & r);
0234   // Matrix multiplication.
0235   // Note a *= b; <=> a = a * b; while a.transform(b); <=> a = b * a;
0236   // However, in this special case, they commute:  Both just add deltas.
0237 
0238   inline HepRotationX inverse() const;
0239   // Returns the inverse.
0240 
0241   friend HepRotationX inverseOf(const HepRotationX & r);
0242   // Returns the inverse of a RotationX.
0243 
0244   inline HepRotationX & invert();
0245   // Inverts the Rotation matrix (be negating delta).
0246 
0247   // ---------- I/O: 
0248 
0249   std::ostream & print( std::ostream & os ) const;
0250   // Output, identifying type of rotation and delta.
0251 
0252   // ---------- Tolerance
0253 
0254   static inline double getTolerance();
0255   static inline double setTolerance(double tol);
0256 
0257 protected:
0258 
0259   double its_d;
0260   // The angle of rotation.
0261 
0262   double its_s;
0263   double its_c;
0264   // Cache the trig functions, for rapid operations.
0265 
0266   inline HepRotationX ( double dd, double ss, double cc );
0267   // Unchecked load-the-data-members
0268 
0269   static inline double proper (double delta);
0270   // Put an angle into the range of (-PI, PI].  Useful helper method.
0271 
0272 };  // HepRotationX
0273 // ---------- Free-function operations in the group of Rotations
0274 
0275 inline   
0276 std::ostream & operator << 
0277     ( std::ostream & os, const HepRotationX & r ) {return r.print(os);}
0278 
0279 }  // namespace CLHEP
0280 
0281 #include "CLHEP/Vector/RotationX.icc"
0282 
0283 #ifdef ENABLE_BACKWARDS_COMPATIBILITY
0284 //  backwards compatibility will be enabled ONLY in CLHEP 1.9
0285 using namespace CLHEP;
0286 #endif
0287 
0288 #endif /* HEP_ROTATIONX_H */