Geant4 Cross Reference |
1 // -*- C++ -*- 1 // -*- C++ -*- 2 // ------------------------------------------- 2 // --------------------------------------------------------------------------- 3 // 3 // 4 // This file is a part of the CLHEP - a Class 4 // This file is a part of the CLHEP - a Class Library for High Energy Physics. 5 // 5 // 6 // This is the definitions of the inline membe 6 // This is the definitions of the inline member functions of the 7 // HepRotationX class 7 // HepRotationX class 8 // 8 // 9 9 10 #include <cmath> 10 #include <cmath> 11 #include "CLHEP/Units/PhysicalConstants.h" 11 #include "CLHEP/Units/PhysicalConstants.h" 12 12 13 namespace CLHEP { 13 namespace CLHEP { 14 14 15 inline double HepRotationX::yy() const { retur 15 inline double HepRotationX::yy() const { return its_c; } 16 inline double HepRotationX::yz() const { retur 16 inline double HepRotationX::yz() const { return -its_s; } 17 inline double HepRotationX::zy() const { retur 17 inline double HepRotationX::zy() const { return its_s; } 18 inline double HepRotationX::zz() const { retur 18 inline double HepRotationX::zz() const { return its_c; } 19 19 20 inline double HepRotationX::xx() const { retur 20 inline double HepRotationX::xx() const { return 1.0; } 21 inline double HepRotationX::xy() const { retur 21 inline double HepRotationX::xy() const { return 0.0; } 22 inline double HepRotationX::xz() const { retur 22 inline double HepRotationX::xz() const { return 0.0; } 23 inline double HepRotationX::yx() const { retur 23 inline double HepRotationX::yx() const { return 0.0; } 24 inline double HepRotationX::zx() const { retur 24 inline double HepRotationX::zx() const { return 0.0; } 25 25 26 inline HepRep3x3 HepRotationX::rep3x3() const 26 inline HepRep3x3 HepRotationX::rep3x3() const { 27 return HepRep3x3 ( 1.0, 0.0, 0.0, 27 return HepRep3x3 ( 1.0, 0.0, 0.0, 28 0.0, its_c, -its_s, 28 0.0, its_c, -its_s, 29 0.0, its_s, its_c ); 29 0.0, its_s, its_c ); 30 } 30 } 31 31 32 inline HepRotationX::HepRotationX() : its_d(0. 32 inline HepRotationX::HepRotationX() : its_d(0.0), its_s(0.0), its_c(1.0) {} 33 33 34 inline HepRotationX::HepRotationX(const HepRot 34 inline HepRotationX::HepRotationX(const HepRotationX & orig) : 35 its_d(orig.its_d), its_s(orig.its_s), its_c( 35 its_d(orig.its_d), its_s(orig.its_s), its_c(orig.its_c) 36 {} 36 {} 37 37 38 inline HepRotationX::HepRotationX(double dd, d 38 inline HepRotationX::HepRotationX(double dd, double ss, double cc) : 39 its_d(dd), its_s(ss), its_c(cc) 39 its_d(dd), its_s(ss), its_c(cc) 40 {} 40 {} 41 41 42 inline HepRotationX & HepRotationX::operator= 42 inline HepRotationX & HepRotationX::operator= (const HepRotationX & orig) { 43 its_d = orig.its_d; 43 its_d = orig.its_d; 44 its_s = orig.its_s; 44 its_s = orig.its_s; 45 its_c = orig.its_c; 45 its_c = orig.its_c; 46 return *this; 46 return *this; 47 } 47 } 48 48 49 inline HepRotationX::~HepRotationX() {} 49 inline HepRotationX::~HepRotationX() {} 50 50 51 inline Hep3Vector HepRotationX::colX() const 51 inline Hep3Vector HepRotationX::colX() const 52 { return Hep3Vector ( 1.0, 0.0, 0.0 ); 52 { return Hep3Vector ( 1.0, 0.0, 0.0 ); } 53 inline Hep3Vector HepRotationX::colY() const 53 inline Hep3Vector HepRotationX::colY() const 54 { return Hep3Vector ( 0.0, its_c, it 54 { return Hep3Vector ( 0.0, its_c, its_s ); } 55 inline Hep3Vector HepRotationX::colZ() const 55 inline Hep3Vector HepRotationX::colZ() const 56 { return Hep3Vector ( 0.0, -its_s, it 56 { return Hep3Vector ( 0.0, -its_s, its_c ); } 57 57 58 inline Hep3Vector HepRotationX::rowX() const 58 inline Hep3Vector HepRotationX::rowX() const 59 { return Hep3Vector ( 1.0, 0.0, 0.0 ); 59 { return Hep3Vector ( 1.0, 0.0, 0.0 ); } 60 inline Hep3Vector HepRotationX::rowY() const 60 inline Hep3Vector HepRotationX::rowY() const 61 { return Hep3Vector ( 0.0, its_c, -it 61 { return Hep3Vector ( 0.0, its_c, -its_s ); } 62 inline Hep3Vector HepRotationX::rowZ() const 62 inline Hep3Vector HepRotationX::rowZ() const 63 { return Hep3Vector ( 0.0, its_s, it 63 { return Hep3Vector ( 0.0, its_s, its_c ); } 64 64 65 inline double HepRotationX::getPhi () const 65 inline double HepRotationX::getPhi () const { return phi(); } 66 inline double HepRotationX::getTheta() const 66 inline double HepRotationX::getTheta() const { return theta(); } 67 inline double HepRotationX::getPsi () const 67 inline double HepRotationX::getPsi () const { return psi(); } 68 inline double HepRotationX::getDelta() const 68 inline double HepRotationX::getDelta() const { return its_d; } 69 inline Hep3Vector HepRotationX::getAxis () con 69 inline Hep3Vector HepRotationX::getAxis () const { return axis(); } 70 70 71 inline double HepRotationX::delta() const { r 71 inline double HepRotationX::delta() const { return its_d; } 72 inline Hep3Vector HepRotationX::axis() const { 72 inline Hep3Vector HepRotationX::axis() const { return Hep3Vector(1,0,0); } 73 73 74 inline HepAxisAngle HepRotationX::axisAngle() 74 inline HepAxisAngle HepRotationX::axisAngle() const { 75 return HepAxisAngle ( axis(), delta() ); 75 return HepAxisAngle ( axis(), delta() ); 76 } 76 } 77 77 78 inline void HepRotationX::getAngleAxis 78 inline void HepRotationX::getAngleAxis 79 (double & ddelta, Hep3Vector & aaxis) co 79 (double & ddelta, Hep3Vector & aaxis) const { 80 ddelta = its_d; 80 ddelta = its_d; 81 aaxis = getAxis(); 81 aaxis = getAxis(); 82 } 82 } 83 83 84 inline HepLorentzVector HepRotationX::col1() c 84 inline HepLorentzVector HepRotationX::col1() const 85 { return HepLorentzVector (colX(), 0); 85 { return HepLorentzVector (colX(), 0); } 86 inline HepLorentzVector HepRotationX::col2() c 86 inline HepLorentzVector HepRotationX::col2() const 87 { return HepLorentzVector (colY(), 0); 87 { return HepLorentzVector (colY(), 0); } 88 inline HepLorentzVector HepRotationX::col3() c 88 inline HepLorentzVector HepRotationX::col3() const 89 { return HepLorentzVector (colZ(), 0); 89 { return HepLorentzVector (colZ(), 0); } 90 inline HepLorentzVector HepRotationX::col4() c 90 inline HepLorentzVector HepRotationX::col4() const 91 { return HepLorentzVector (0,0,0,1); } 91 { return HepLorentzVector (0,0,0,1); } 92 inline HepLorentzVector HepRotationX::row1() c 92 inline HepLorentzVector HepRotationX::row1() const 93 { return HepLorentzVector (rowX(), 0); 93 { return HepLorentzVector (rowX(), 0); } 94 inline HepLorentzVector HepRotationX::row2() c 94 inline HepLorentzVector HepRotationX::row2() const 95 { return HepLorentzVector (rowY(), 0); 95 { return HepLorentzVector (rowY(), 0); } 96 inline HepLorentzVector HepRotationX::row3() c 96 inline HepLorentzVector HepRotationX::row3() const 97 { return HepLorentzVector (rowZ(), 0); 97 { return HepLorentzVector (rowZ(), 0); } 98 inline HepLorentzVector HepRotationX::row4() c 98 inline HepLorentzVector HepRotationX::row4() const 99 { return HepLorentzVector (0,0,0,1); } 99 { return HepLorentzVector (0,0,0,1); } 100 inline double HepRotationX::xt() const { retur 100 inline double HepRotationX::xt() const { return 0.0; } 101 inline double HepRotationX::yt() const { retur 101 inline double HepRotationX::yt() const { return 0.0; } 102 inline double HepRotationX::zt() const { retur 102 inline double HepRotationX::zt() const { return 0.0; } 103 inline double HepRotationX::tx() const { retur 103 inline double HepRotationX::tx() const { return 0.0; } 104 inline double HepRotationX::ty() const { retur 104 inline double HepRotationX::ty() const { return 0.0; } 105 inline double HepRotationX::tz() const { retur 105 inline double HepRotationX::tz() const { return 0.0; } 106 inline double HepRotationX::tt() const { retur 106 inline double HepRotationX::tt() const { return 1.0; } 107 107 108 inline HepRep4x4 HepRotationX::rep4x4() const 108 inline HepRep4x4 HepRotationX::rep4x4() const { 109 return HepRep4x4 ( 1.0, 0.0, 0.0, 0.0, 109 return HepRep4x4 ( 1.0, 0.0, 0.0, 0.0, 110 0.0, its_c, -its_s, 0.0, 110 0.0, its_c, -its_s, 0.0, 111 0.0, its_s, its_c, 0.0, 111 0.0, its_s, its_c, 0.0, 112 0.0, 0.0, 0.0, 1.0 ) 112 0.0, 0.0, 0.0, 1.0 ); 113 } 113 } 114 114 115 inline bool HepRotationX::isIdentity() const { 115 inline bool HepRotationX::isIdentity() const { 116 return ( its_d==0 ); 116 return ( its_d==0 ); 117 } 117 } 118 118 119 inline int HepRotationX::compare ( const HepRo 119 inline int HepRotationX::compare ( const HepRotationX & r ) const { 120 if (its_d > r.its_d) return 1; else if (its_ 120 if (its_d > r.its_d) return 1; else if (its_d < r.its_d) return -1; else return 0; 121 } 121 } 122 122 123 inline bool HepRotationX::operator==(const Hep 123 inline bool HepRotationX::operator==(const HepRotationX & r) const 124 { return (its_d==r.its_d); } 124 { return (its_d==r.its_d); } 125 inline bool HepRotationX::operator!=(const Hep 125 inline bool HepRotationX::operator!=(const HepRotationX & r) const 126 { return (its_d!=r.its_d); } 126 { return (its_d!=r.its_d); } 127 inline bool HepRotationX::operator>=(const Hep 127 inline bool HepRotationX::operator>=(const HepRotationX & r) const 128 { return (its_d>=r.its_d); } 128 { return (its_d>=r.its_d); } 129 inline bool HepRotationX::operator<=(const Hep 129 inline bool HepRotationX::operator<=(const HepRotationX & r) const 130 { return (its_d<=r.its_d); } 130 { return (its_d<=r.its_d); } 131 inline bool HepRotationX::operator> (const Hep 131 inline bool HepRotationX::operator> (const HepRotationX & r) const 132 { return (its_d> r.its_d); } 132 { return (its_d> r.its_d); } 133 inline bool HepRotationX::operator< (const Hep 133 inline bool HepRotationX::operator< (const HepRotationX & r) const 134 { return (its_d< r.its_d); } 134 { return (its_d< r.its_d); } 135 135 136 inline void HepRotationX::rectify() { 136 inline void HepRotationX::rectify() { 137 its_d = proper(its_d); // Just in case! 137 its_d = proper(its_d); // Just in case! 138 its_s = std::sin(its_d); 138 its_s = std::sin(its_d); 139 its_c = std::cos(its_d); 139 its_c = std::cos(its_d); 140 } 140 } 141 141 142 inline Hep3Vector HepRotationX::operator() (co 142 inline Hep3Vector HepRotationX::operator() (const Hep3Vector & p) const { 143 double x = p.x(); 143 double x = p.x(); 144 double y = p.y(); 144 double y = p.y(); 145 double z = p.z(); 145 double z = p.z(); 146 return Hep3Vector( x, 146 return Hep3Vector( x, 147 y * its_c - z * its_s, 147 y * its_c - z * its_s, 148 z * its_c + y * its_s 148 z * its_c + y * its_s ); 149 } 149 } 150 150 151 inline Hep3Vector HepRotationX::operator * (co 151 inline Hep3Vector HepRotationX::operator * (const Hep3Vector & p) const { 152 return operator()(p); 152 return operator()(p); 153 } 153 } 154 154 155 inline HepLorentzVector HepRotationX::operator 155 inline HepLorentzVector HepRotationX::operator() 156 ( const HepLorentzVector & w ) const { 156 ( const HepLorentzVector & w ) const { 157 return HepLorentzVector( operator() (w.vect 157 return HepLorentzVector( operator() (w.vect()) , w.t() ); 158 } 158 } 159 159 160 inline HepLorentzVector HepRotationX::operator 160 inline HepLorentzVector HepRotationX::operator * 161 (const HepLorentzVector & p) const { 161 (const HepLorentzVector & p) const { 162 return operator()(p); 162 return operator()(p); 163 } 163 } 164 164 165 inline HepRotationX & HepRotationX::operator * 165 inline HepRotationX & HepRotationX::operator *= (const HepRotationX & m1) { 166 return *this = (*this) * (m1); 166 return *this = (*this) * (m1); 167 } 167 } 168 168 169 inline HepRotationX & HepRotationX::transform( 169 inline HepRotationX & HepRotationX::transform(const HepRotationX & m1) { 170 return *this = m1 * (*this); 170 return *this = m1 * (*this); 171 } 171 } 172 172 173 inline double HepRotationX::proper( double dde 173 inline double HepRotationX::proper( double ddelta ) { 174 // -PI < d <= PI 174 // -PI < d <= PI 175 if ( std::fabs(ddelta) < CLHEP::pi ) { 175 if ( std::fabs(ddelta) < CLHEP::pi ) { 176 return ddelta; 176 return ddelta; 177 } else { 177 } else { 178 double x = ddelta / (CLHEP::twopi); << 178 register double x = ddelta / (CLHEP::twopi); 179 return (CLHEP::twopi) * ( x + std::floor( 179 return (CLHEP::twopi) * ( x + std::floor(.5-x) ); 180 } 180 } 181 } // proper() 181 } // proper() 182 182 183 inline HepRotationX HepRotationX::operator * ( 183 inline HepRotationX HepRotationX::operator * ( const HepRotationX & rx ) const { 184 return HepRotationX ( HepRotationX::proper(i 184 return HepRotationX ( HepRotationX::proper(its_d+rx.its_d), 185 its_s*rx.its_c + its_c 185 its_s*rx.its_c + its_c*rx.its_s, 186 its_c*rx.its_c - its_s 186 its_c*rx.its_c - its_s*rx.its_s ); 187 } 187 } 188 188 189 inline HepRotationX HepRotationX::inverse() co 189 inline HepRotationX HepRotationX::inverse() const { 190 return HepRotationX( proper(-its_d), -its_s, 190 return HepRotationX( proper(-its_d), -its_s, its_c ); 191 } 191 } 192 192 193 inline HepRotationX inverseOf(const HepRotatio 193 inline HepRotationX inverseOf(const HepRotationX & r) { 194 return r.inverse(); 194 return r.inverse(); 195 } 195 } 196 196 197 inline HepRotationX & HepRotationX::invert() { 197 inline HepRotationX & HepRotationX::invert() { 198 return *this=inverse(); 198 return *this=inverse(); 199 } 199 } 200 200 201 inline double HepRotationX::getTolerance() { 201 inline double HepRotationX::getTolerance() { 202 return Hep4RotationInterface::tolerance; 202 return Hep4RotationInterface::tolerance; 203 } 203 } 204 inline double HepRotationX::setTolerance(doubl 204 inline double HepRotationX::setTolerance(double tol) { 205 return Hep4RotationInterface::setTolerance(t 205 return Hep4RotationInterface::setTolerance(tol); 206 } 206 } 207 207 208 } // namespace CLHEP 208 } // namespace CLHEP 209 209