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