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