Geant4 Cross Reference |
1 // -*- C++ -*- 1 // -*- C++ -*- 2 // CLASSDOC OFF 2 // CLASSDOC OFF 3 // ------------------------------------------- 3 // --------------------------------------------------------------------------- 4 // CLASSDOC ON 4 // CLASSDOC ON 5 // 5 // 6 // This file is a part of the CLHEP - a Class 6 // This file is a part of the CLHEP - a Class Library for High Energy Physics. 7 // 7 // 8 // This is the definition of the HepRotationZ 8 // This is the definition of the HepRotationZ class for performing rotations 9 // around the X axis on objects of the Hep3Vec 9 // around the X axis on objects of the Hep3Vector (and HepLorentzVector) class. 10 // 10 // 11 // HepRotationZ is a concrete implementation o 11 // HepRotationZ is a concrete implementation of Hep3RotationInterface. 12 // 12 // 13 // .SS See Also 13 // .SS See Also 14 // RotationInterfaces.h 14 // RotationInterfaces.h 15 // ThreeVector.h, LorentzVector.h, LorentzRota 15 // ThreeVector.h, LorentzVector.h, LorentzRotation.h 16 // 16 // 17 // .SS Author 17 // .SS Author 18 // Mark Fischler 18 // Mark Fischler 19 19 20 #ifndef HEP_ROTATIONZ_H 20 #ifndef HEP_ROTATIONZ_H 21 #define HEP_ROTATIONZ_H 21 #define HEP_ROTATIONZ_H 22 22 23 #include "CLHEP/Vector/RotationInterfaces.h" 23 #include "CLHEP/Vector/RotationInterfaces.h" 24 24 25 namespace CLHEP { 25 namespace CLHEP { 26 26 27 class HepRotationZ; 27 class HepRotationZ; 28 class HepRotation; 28 class HepRotation; 29 class HepBoost; 29 class HepBoost; 30 30 31 inline HepRotationZ inverseOf(const HepRotatio 31 inline HepRotationZ inverseOf(const HepRotationZ & r); 32 // Returns the inverse of a RotationZ. 32 // Returns the inverse of a RotationZ. 33 33 34 /** 34 /** 35 * @author 35 * @author 36 * @ingroup vector 36 * @ingroup vector 37 */ 37 */ 38 class HepRotationZ { 38 class HepRotationZ { 39 39 40 public: 40 public: 41 41 42 // ---------- Constructors and Assignment: 42 // ---------- Constructors and Assignment: 43 43 44 inline HepRotationZ(); 44 inline HepRotationZ(); 45 // Default constructor. Gives an identity ro 45 // Default constructor. Gives an identity rotation. 46 46 47 HepRotationZ(double delta); 47 HepRotationZ(double delta); 48 // supply angle of rotation 48 // supply angle of rotation 49 49 50 inline HepRotationZ(const HepRotationZ & ori 50 inline HepRotationZ(const HepRotationZ & orig); 51 inline HepRotationZ(HepRotationZ && orig) = 51 inline HepRotationZ(HepRotationZ && orig) = default; 52 // Copy and move constructors. 52 // Copy and move constructors. 53 53 54 inline HepRotationZ & operator = (const HepR 54 inline HepRotationZ & operator = (const HepRotationZ & r); 55 inline HepRotationZ & operator = (HepRotatio 55 inline HepRotationZ & operator = (HepRotationZ && r) = default; 56 // Copy and move assignments from a Rotation 56 // Copy and move assignments from a Rotation, which must be RotationZ 57 57 58 HepRotationZ & set ( double delta ); 58 HepRotationZ & set ( double delta ); 59 // set angle of rotation 59 // set angle of rotation 60 60 61 inline ~HepRotationZ(); 61 inline ~HepRotationZ(); 62 // Trivial destructor. 62 // Trivial destructor. 63 63 64 // ---------- Accessors: 64 // ---------- Accessors: 65 65 66 inline Hep3Vector colX() const; 66 inline Hep3Vector colX() const; 67 inline Hep3Vector colY() const; 67 inline Hep3Vector colY() const; 68 inline Hep3Vector colZ() const; 68 inline Hep3Vector colZ() const; 69 // orthogonal unit-length column vectors 69 // orthogonal unit-length column vectors 70 70 71 inline Hep3Vector rowX() const; 71 inline Hep3Vector rowX() const; 72 inline Hep3Vector rowY() const; 72 inline Hep3Vector rowY() const; 73 inline Hep3Vector rowZ() const; 73 inline Hep3Vector rowZ() const; 74 // orthogonal unit-length row vectors 74 // orthogonal unit-length row vectors 75 75 76 inline double xx() const; 76 inline double xx() const; 77 inline double xy() const; 77 inline double xy() const; 78 inline double xz() const; 78 inline double xz() const; 79 inline double yx() const; 79 inline double yx() const; 80 inline double yy() const; 80 inline double yy() const; 81 inline double yz() const; 81 inline double yz() const; 82 inline double zx() const; 82 inline double zx() const; 83 inline double zy() const; 83 inline double zy() const; 84 inline double zz() const; 84 inline double zz() const; 85 // Elements of the rotation matrix (Geant4). 85 // Elements of the rotation matrix (Geant4). 86 86 87 inline HepRep3x3 rep3x3() const; 87 inline HepRep3x3 rep3x3() const; 88 // 3x3 representation: 88 // 3x3 representation: 89 89 90 // ------------ Euler angles: 90 // ------------ Euler angles: 91 inline double getPhi () const; 91 inline double getPhi () const; 92 inline double getTheta() const; 92 inline double getTheta() const; 93 inline double getPsi () const; 93 inline double getPsi () const; 94 double phi () const; 94 double phi () const; 95 double theta() const; 95 double theta() const; 96 double psi () const; 96 double psi () const; 97 HepEulerAngles eulerAngles() const; 97 HepEulerAngles eulerAngles() const; 98 98 99 // ------------ axis & angle of rotation: 99 // ------------ axis & angle of rotation: 100 inline double getDelta() const; 100 inline double getDelta() const; 101 inline Hep3Vector getAxis () const; 101 inline Hep3Vector getAxis () const; 102 inline double delta() const; 102 inline double delta() const; 103 inline Hep3Vector axis () const; 103 inline Hep3Vector axis () const; 104 inline HepAxisAngle axisAngle() const; 104 inline HepAxisAngle axisAngle() const; 105 inline void getAngleAxis(double & delta, He 105 inline void getAngleAxis(double & delta, Hep3Vector & axis) const; 106 // Returns the rotation angle and rotation a 106 // Returns the rotation angle and rotation axis (Geant4). 107 107 108 // ------------- Angles of rotated axes 108 // ------------- Angles of rotated axes 109 double phiX() const; 109 double phiX() const; 110 double phiY() const; 110 double phiY() const; 111 double phiZ() const; 111 double phiZ() const; 112 double thetaX() const; 112 double thetaX() const; 113 double thetaY() const; 113 double thetaY() const; 114 double thetaZ() const; 114 double thetaZ() const; 115 // Return angles (RADS) made by rotated axes 115 // Return angles (RADS) made by rotated axes against original axes (Geant4). 116 116 117 // ---------- Other accessors treating pure 117 // ---------- Other accessors treating pure rotation as a 4-rotation 118 118 119 inline HepLorentzVector col1() const; 119 inline HepLorentzVector col1() const; 120 inline HepLorentzVector col2() const; 120 inline HepLorentzVector col2() const; 121 inline HepLorentzVector col3() const; 121 inline HepLorentzVector col3() const; 122 // orthosymplectic 4-vector columns - T com 122 // orthosymplectic 4-vector columns - T component will be zero 123 123 124 inline HepLorentzVector col4() const; 124 inline HepLorentzVector col4() const; 125 // Will be (0,0,0,1) for this pure Rotation. 125 // Will be (0,0,0,1) for this pure Rotation. 126 126 127 inline HepLorentzVector row1() const; 127 inline HepLorentzVector row1() const; 128 inline HepLorentzVector row2() const; 128 inline HepLorentzVector row2() const; 129 inline HepLorentzVector row3() const; 129 inline HepLorentzVector row3() const; 130 // orthosymplectic 4-vector rows - T compon 130 // orthosymplectic 4-vector rows - T component will be zero 131 131 132 inline HepLorentzVector row4() const; 132 inline HepLorentzVector row4() const; 133 // Will be (0,0,0,1) for this pure Rotation. 133 // Will be (0,0,0,1) for this pure Rotation. 134 134 135 inline double xt() const; 135 inline double xt() const; 136 inline double yt() const; 136 inline double yt() const; 137 inline double zt() const; 137 inline double zt() const; 138 inline double tx() const; 138 inline double tx() const; 139 inline double ty() const; 139 inline double ty() const; 140 inline double tz() const; 140 inline double tz() const; 141 // Will be zero for this pure Rotation 141 // Will be zero for this pure Rotation 142 142 143 inline double tt() const; 143 inline double tt() const; 144 // Will be one for this pure Rotation 144 // Will be one for this pure Rotation 145 145 146 inline HepRep4x4 rep4x4() const; 146 inline HepRep4x4 rep4x4() const; 147 // 4x4 representation. 147 // 4x4 representation. 148 148 149 // --------- Mutators 149 // --------- Mutators 150 150 151 void setDelta (double delta); 151 void setDelta (double delta); 152 // change angle of rotation, leaving rotatio 152 // change angle of rotation, leaving rotation axis unchanged. 153 153 154 // ---------- Decomposition: 154 // ---------- Decomposition: 155 155 156 void decompose (HepAxisAngle & rotation, Hep 156 void decompose (HepAxisAngle & rotation, Hep3Vector & boost) const; 157 void decompose (Hep3Vector & boost, HepAxisA 157 void decompose (Hep3Vector & boost, HepAxisAngle & rotation) const; 158 void decompose (HepRotation & rotation, HepB 158 void decompose (HepRotation & rotation, HepBoost & boost) const; 159 void decompose (HepBoost & boost, HepRotatio 159 void decompose (HepBoost & boost, HepRotation & rotation) const; 160 // These are trivial, as the boost vector i 160 // These are trivial, as the boost vector is 0. 161 161 162 // ---------- Comparisons: 162 // ---------- Comparisons: 163 163 164 inline bool isIdentity() const; 164 inline bool isIdentity() const; 165 // Returns true if the identity matrix (Gean 165 // Returns true if the identity matrix (Geant4). 166 166 167 inline int compare( const HepRotationZ & r 167 inline int compare( const HepRotationZ & r ) const; 168 // Dictionary-order comparison, in order of 168 // Dictionary-order comparison, in order of delta 169 // Used in operator<, >, <=, >= 169 // Used in operator<, >, <=, >= 170 170 171 inline bool operator== ( const HepRotationZ 171 inline bool operator== ( const HepRotationZ & r ) const; 172 inline bool operator!= ( const HepRotationZ 172 inline bool operator!= ( const HepRotationZ & r ) const; 173 inline bool operator< ( const HepRotationZ 173 inline bool operator< ( const HepRotationZ & r ) const; 174 inline bool operator> ( const HepRotationZ 174 inline bool operator> ( const HepRotationZ & r ) const; 175 inline bool operator<= ( const HepRotationZ 175 inline bool operator<= ( const HepRotationZ & r ) const; 176 inline bool operator>= ( const HepRotationZ 176 inline bool operator>= ( const HepRotationZ & r ) const; 177 177 178 double distance2( const HepRotationZ & r ) 178 double distance2( const HepRotationZ & r ) const; 179 // 3 - Tr ( this/r ) 179 // 3 - Tr ( this/r ) 180 180 181 double distance2( const HepRotation & r ) 181 double distance2( const HepRotation & r ) const; 182 // 3 - Tr ( this/r ) -- This works with Rota 182 // 3 - Tr ( this/r ) -- This works with RotationY or Z also 183 183 184 double howNear( const HepRotationZ & r ) con 184 double howNear( const HepRotationZ & r ) const; 185 double howNear( const HepRotation & r ) con 185 double howNear( const HepRotation & r ) const; 186 bool isNear( const HepRotationZ & r, 186 bool isNear( const HepRotationZ & r, 187 double epsilon=Hep4RotationInterf 187 double epsilon=Hep4RotationInterface::tolerance) const; 188 bool isNear( const HepRotation & r, 188 bool isNear( const HepRotation & r, 189 double epsilon=Hep4RotationInterf 189 double epsilon=Hep4RotationInterface::tolerance) const; 190 190 191 double distance2( const HepBoost & 191 double distance2( const HepBoost & lt ) const; 192 // 3 - Tr ( this ) + |b|^2 / (1-|b|^2) 192 // 3 - Tr ( this ) + |b|^2 / (1-|b|^2) 193 double distance2( const HepLorentzRotation & 193 double distance2( const HepLorentzRotation & lt ) const; 194 // 3 - Tr ( this/r ) + |b|^2 / (1-|b|^2) whe 194 // 3 - Tr ( this/r ) + |b|^2 / (1-|b|^2) where b is the boost vector of lt 195 195 196 double howNear( const HepBoost & l 196 double howNear( const HepBoost & lt ) const; 197 double howNear( const HepLorentzRotation & l 197 double howNear( const HepLorentzRotation & lt ) const; 198 bool isNear( const HepBoost & lt, 198 bool isNear( const HepBoost & lt, 199 double epsilon=Hep4RotationInterf 199 double epsilon=Hep4RotationInterface::tolerance) const; 200 bool isNear( const HepLorentzRotation & lt, 200 bool isNear( const HepLorentzRotation & lt, 201 double epsilon=Hep4RotationInterf 201 double epsilon=Hep4RotationInterface::tolerance) const; 202 202 203 // ---------- Properties: 203 // ---------- Properties: 204 204 205 double norm2() const; 205 double norm2() const; 206 // distance2 (IDENTITY), which is 3 - Tr ( * 206 // distance2 (IDENTITY), which is 3 - Tr ( *this ) 207 207 208 inline void rectify(); 208 inline void rectify(); 209 // non-const but logically moot correction f 209 // non-const but logically moot correction for accumulated roundoff errors 210 210 211 // ---------- Application: 211 // ---------- Application: 212 212 213 inline Hep3Vector operator() (const Hep3Vect 213 inline Hep3Vector operator() (const Hep3Vector & p) const; 214 // Rotate a Hep3Vector. 214 // Rotate a Hep3Vector. 215 215 216 inline Hep3Vector operator * (const Hep3Vec 216 inline Hep3Vector operator * (const Hep3Vector & p) const; 217 // Multiplication with a Hep3Vector. 217 // Multiplication with a Hep3Vector. 218 218 219 inline HepLorentzVector operator()( const He 219 inline HepLorentzVector operator()( const HepLorentzVector & w ) const; 220 // Rotate (the space part of) a HepLorentzVe 220 // Rotate (the space part of) a HepLorentzVector. 221 221 222 inline HepLorentzVector operator* ( const H 222 inline HepLorentzVector operator* ( const HepLorentzVector & w ) const; 223 // Multiplication with a HepLorentzVector. 223 // Multiplication with a HepLorentzVector. 224 224 225 // ---------- Operations in the group of Rota 225 // ---------- Operations in the group of Rotations 226 226 227 inline HepRotationZ operator * (const HepRot 227 inline HepRotationZ operator * (const HepRotationZ & rz) const; 228 // Product of two Z rotations: (this) * rz 228 // Product of two Z rotations: (this) * rz is known to be RotationZ. 229 229 230 // Product of two rotations (this) * b - mat 230 // Product of two rotations (this) * b - matrix multiplication 231 231 232 inline HepRotationZ & operator *= (const He 232 inline HepRotationZ & operator *= (const HepRotationZ & r); 233 inline HepRotationZ & transform (const He 233 inline HepRotationZ & transform (const HepRotationZ & r); 234 // Matrix multiplication. 234 // Matrix multiplication. 235 // Note a *= b; <=> a = a * b; while a.trans 235 // Note a *= b; <=> a = a * b; while a.transform(b); <=> a = b * a; 236 // However, in this special case, they commu 236 // However, in this special case, they commute: Both just add deltas. 237 237 238 inline HepRotationZ inverse() const; 238 inline HepRotationZ inverse() const; 239 // Returns the inverse. 239 // Returns the inverse. 240 240 241 friend HepRotationZ inverseOf(const HepRotat 241 friend HepRotationZ inverseOf(const HepRotationZ & r); 242 // Returns the inverse of a RotationZ. 242 // Returns the inverse of a RotationZ. 243 243 244 inline HepRotationZ & invert(); 244 inline HepRotationZ & invert(); 245 // Inverts the Rotation matrix (be negating 245 // Inverts the Rotation matrix (be negating delta). 246 246 247 // ---------- I/O: 247 // ---------- I/O: 248 248 249 std::ostream & print( std::ostream & os ) co 249 std::ostream & print( std::ostream & os ) const; 250 // Output, identifying type of rotation and 250 // Output, identifying type of rotation and delta. 251 251 252 // ---------- Tolerance 252 // ---------- Tolerance 253 253 254 static inline double getTolerance(); 254 static inline double getTolerance(); 255 static inline double setTolerance(double tol 255 static inline double setTolerance(double tol); 256 256 257 protected: 257 protected: 258 258 259 double its_d; 259 double its_d; 260 // The angle of rotation. 260 // The angle of rotation. 261 261 262 double its_s; 262 double its_s; 263 double its_c; 263 double its_c; 264 // Cache the trig functions, for rapid opera 264 // Cache the trig functions, for rapid operations. 265 265 266 inline HepRotationZ ( double dd, double ss, 266 inline HepRotationZ ( double dd, double ss, double cc ); 267 // Unchecked load-the-data-members 267 // Unchecked load-the-data-members 268 268 269 static inline double proper (double delta); 269 static inline double proper (double delta); 270 // Put an angle into the range of (-PI, PI]. 270 // Put an angle into the range of (-PI, PI]. Useful helper method. 271 271 272 }; // HepRotationZ 272 }; // HepRotationZ 273 273 274 inline 274 inline 275 std::ostream & operator << 275 std::ostream & operator << 276 ( std::ostream & os, const HepRotationZ & r 276 ( std::ostream & os, const HepRotationZ & r ) {return r.print(os);} 277 277 278 // ---------- Free-function operations in the 278 // ---------- Free-function operations in the group of Rotations 279 279 280 } // namespace CLHEP 280 } // namespace CLHEP 281 281 282 #include "CLHEP/Vector/RotationZ.icc" 282 #include "CLHEP/Vector/RotationZ.icc" 283 283 284 #endif /* HEP_ROTATIONZ_H */ 284 #endif /* HEP_ROTATIONZ_H */ 285 285 286 286