CLHEP 2.0.4.7 Reference Documentation
CLHEP Home Page CLHEP Documentation CLHEP Bug Reports |
00001 // -*- C++ -*- 00002 // CLASSDOC OFF 00003 // --------------------------------------------------------------------------- 00004 // CLASSDOC ON 00005 // 00006 // This file is a part of the CLHEP - a Class Library for High Energy Physics. 00007 // 00008 // This is the definition of the HepRotationZ class for performing rotations 00009 // around the X axis on objects of the Hep3Vector (and HepLorentzVector) class. 00010 // 00011 // HepRotationZ is a concrete implementation of Hep3RotationInterface. 00012 // 00013 // .SS See Also 00014 // RotationInterfaces.h 00015 // ThreeVector.h, LorentzVector.h, LorentzRotation.h 00016 // 00017 // .SS Author 00018 // Mark Fischler 00019 00020 #ifndef HEP_ROTATIONZ_H 00021 #define HEP_ROTATIONZ_H 00022 00023 #ifdef GNUPRAGMA 00024 #pragma interface 00025 #endif 00026 00027 #include "CLHEP/Vector/defs.h" 00028 #include "CLHEP/Vector/RotationInterfaces.h" 00029 00030 namespace CLHEP { 00031 00032 class HepRotationZ; 00033 class HepRotation; 00034 class HepBoost; 00035 00036 inline HepRotationZ inverseOf(const HepRotationZ & r); 00037 // Returns the inverse of a RotationZ. 00038 00043 class HepRotationZ { 00044 00045 public: 00046 00047 // ---------- Constructors and Assignment: 00048 00049 inline HepRotationZ(); 00050 // Default constructor. Gives an identity rotation. 00051 00052 HepRotationZ(double delta); 00053 // supply angle of rotation 00054 00055 inline HepRotationZ(const HepRotationZ & orig); 00056 // Copy constructor. 00057 00058 inline HepRotationZ & operator = (const HepRotationZ & r); 00059 // Assignment from a Rotation, which must be RotationZ 00060 00061 HepRotationZ & set ( double delta ); 00062 // set angle of rotation 00063 00064 inline ~HepRotationZ(); 00065 // Trivial destructor. 00066 00067 // ---------- Accessors: 00068 00069 inline Hep3Vector colX() const; 00070 inline Hep3Vector colY() const; 00071 inline Hep3Vector colZ() const; 00072 // orthogonal unit-length column vectors 00073 00074 inline Hep3Vector rowX() const; 00075 inline Hep3Vector rowY() const; 00076 inline Hep3Vector rowZ() const; 00077 // orthogonal unit-length row vectors 00078 00079 inline double xx() const; 00080 inline double xy() const; 00081 inline double xz() const; 00082 inline double yx() const; 00083 inline double yy() const; 00084 inline double yz() const; 00085 inline double zx() const; 00086 inline double zy() const; 00087 inline double zz() const; 00088 // Elements of the rotation matrix (Geant4). 00089 00090 inline HepRep3x3 rep3x3() const; 00091 // 3x3 representation: 00092 00093 // ------------ Euler angles: 00094 inline double getPhi () const; 00095 inline double getTheta() const; 00096 inline double getPsi () const; 00097 double phi () const; 00098 double theta() const; 00099 double psi () const; 00100 HepEulerAngles eulerAngles() const; 00101 00102 // ------------ axis & angle of rotation: 00103 inline double getDelta() const; 00104 inline Hep3Vector getAxis () const; 00105 inline double delta() const; 00106 inline Hep3Vector axis () const; 00107 inline HepAxisAngle axisAngle() const; 00108 inline void getAngleAxis(double & delta, Hep3Vector & axis) const; 00109 // Returns the rotation angle and rotation axis (Geant4). 00110 00111 // ------------- Angles of rotated axes 00112 double phiX() const; 00113 double phiY() const; 00114 double phiZ() const; 00115 double thetaX() const; 00116 double thetaY() const; 00117 double thetaZ() const; 00118 // Return angles (RADS) made by rotated axes against original axes (Geant4). 00119 00120 // ---------- Other accessors treating pure rotation as a 4-rotation 00121 00122 inline HepLorentzVector col1() const; 00123 inline HepLorentzVector col2() const; 00124 inline HepLorentzVector col3() const; 00125 // orthosymplectic 4-vector columns - T component will be zero 00126 00127 inline HepLorentzVector col4() const; 00128 // Will be (0,0,0,1) for this pure Rotation. 00129 00130 inline HepLorentzVector row1() const; 00131 inline HepLorentzVector row2() const; 00132 inline HepLorentzVector row3() const; 00133 // orthosymplectic 4-vector rows - T component will be zero 00134 00135 inline HepLorentzVector row4() const; 00136 // Will be (0,0,0,1) for this pure Rotation. 00137 00138 inline double xt() const; 00139 inline double yt() const; 00140 inline double zt() const; 00141 inline double tx() const; 00142 inline double ty() const; 00143 inline double tz() const; 00144 // Will be zero for this pure Rotation 00145 00146 inline double tt() const; 00147 // Will be one for this pure Rotation 00148 00149 inline HepRep4x4 rep4x4() const; 00150 // 4x4 representation. 00151 00152 // --------- Mutators 00153 00154 void setDelta (double delta); 00155 // change angle of rotation, leaving rotation axis unchanged. 00156 00157 // ---------- Decomposition: 00158 00159 void decompose (HepAxisAngle & rotation, Hep3Vector & boost) const; 00160 void decompose (Hep3Vector & boost, HepAxisAngle & rotation) const; 00161 void decompose (HepRotation & rotation, HepBoost & boost) const; 00162 void decompose (HepBoost & boost, HepRotation & rotation) const; 00163 // These are trivial, as the boost vector is 0. 00164 00165 // ---------- Comparisons: 00166 00167 inline bool isIdentity() const; 00168 // Returns true if the identity matrix (Geant4). 00169 00170 inline int compare( const HepRotationZ & r ) const; 00171 // Dictionary-order comparison, in order of delta 00172 // Used in operator<, >, <=, >= 00173 00174 inline bool operator== ( const HepRotationZ & r ) const; 00175 inline bool operator!= ( const HepRotationZ & r ) const; 00176 inline bool operator< ( const HepRotationZ & r ) const; 00177 inline bool operator> ( const HepRotationZ & r ) const; 00178 inline bool operator<= ( const HepRotationZ & r ) const; 00179 inline bool operator>= ( const HepRotationZ & r ) const; 00180 00181 double distance2( const HepRotationZ & r ) const; 00182 // 3 - Tr ( this/r ) 00183 00184 double distance2( const HepRotation & r ) const; 00185 // 3 - Tr ( this/r ) -- This works with RotationY or Z also 00186 00187 double howNear( const HepRotationZ & r ) const; 00188 double howNear( const HepRotation & r ) const; 00189 bool isNear( const HepRotationZ & r, 00190 double epsilon=Hep4RotationInterface::tolerance) const; 00191 bool isNear( const HepRotation & r, 00192 double epsilon=Hep4RotationInterface::tolerance) const; 00193 00194 double distance2( const HepBoost & lt ) const; 00195 // 3 - Tr ( this ) + |b|^2 / (1-|b|^2) 00196 double distance2( const HepLorentzRotation & lt ) const; 00197 // 3 - Tr ( this/r ) + |b|^2 / (1-|b|^2) where b is the boost vector of lt 00198 00199 double howNear( const HepBoost & lt ) const; 00200 double howNear( const HepLorentzRotation & lt ) const; 00201 bool isNear( const HepBoost & lt, 00202 double epsilon=Hep4RotationInterface::tolerance) const; 00203 bool isNear( const HepLorentzRotation & lt, 00204 double epsilon=Hep4RotationInterface::tolerance) const; 00205 00206 // ---------- Properties: 00207 00208 double norm2() const; 00209 // distance2 (IDENTITY), which is 3 - Tr ( *this ) 00210 00211 inline void rectify(); 00212 // non-const but logically moot correction for accumulated roundoff errors 00213 00214 // ---------- Application: 00215 00216 inline Hep3Vector operator() (const Hep3Vector & p) const; 00217 // Rotate a Hep3Vector. 00218 00219 inline Hep3Vector operator * (const Hep3Vector & p) const; 00220 // Multiplication with a Hep3Vector. 00221 00222 inline HepLorentzVector operator()( const HepLorentzVector & w ) const; 00223 // Rotate (the space part of) a HepLorentzVector. 00224 00225 inline HepLorentzVector operator* ( const HepLorentzVector & w ) const; 00226 // Multiplication with a HepLorentzVector. 00227 00228 // ---------- Operations in the group of Rotations 00229 00230 inline HepRotationZ operator * (const HepRotationZ & rz) const; 00231 // Product of two Z rotations: (this) * rz is known to be RotationZ. 00232 00233 // Product of two rotations (this) * b - matrix multiplication 00234 00235 inline HepRotationZ & operator *= (const HepRotationZ & r); 00236 inline HepRotationZ & transform (const HepRotationZ & r); 00237 // Matrix multiplication. 00238 // Note a *= b; <=> a = a * b; while a.transform(b); <=> a = b * a; 00239 // However, in this special case, they commute: Both just add deltas. 00240 00241 inline HepRotationZ inverse() const; 00242 // Returns the inverse. 00243 00244 friend HepRotationZ inverseOf(const HepRotationZ & r); 00245 // Returns the inverse of a RotationZ. 00246 00247 inline HepRotationZ & invert(); 00248 // Inverts the Rotation matrix (be negating delta). 00249 00250 // ---------- I/O: 00251 00252 std::ostream & print( std::ostream & os ) const; 00253 // Output, identifying type of rotation and delta. 00254 00255 // ---------- Tolerance 00256 00257 static inline double getTolerance(); 00258 static inline double setTolerance(double tol); 00259 00260 protected: 00261 00262 double d; 00263 // The angle of rotation. 00264 00265 double s; 00266 double c; 00267 // Cache the trig functions, for rapid operations. 00268 00269 inline HepRotationZ ( double dd, double ss, double cc ); 00270 // Unchecked load-the-data-members 00271 00272 static inline double proper (double delta); 00273 // Put an angle into the range of (-PI, PI]. Useful helper method. 00274 00275 }; // HepRotationZ 00276 00277 inline 00278 std::ostream & operator << 00279 ( std::ostream & os, const HepRotationZ & r ) {return r.print(os);} 00280 00281 // ---------- Free-function operations in the group of Rotations 00282 00283 } // namespace CLHEP 00284 00285 #include "CLHEP/Vector/RotationZ.icc" 00286 00287 #ifdef ENABLE_BACKWARDS_COMPATIBILITY 00288 // backwards compatibility will be enabled ONLY in CLHEP 1.9 00289 using namespace CLHEP; 00290 #endif 00291 00292 #endif /* HEP_ROTATIONZ_H */ 00293