[4] | 1 | // -*- C++ -*-
|
---|
| 2 | // $Id: Rotation.icc,v 1.1 2008-06-04 14:14:59 demin Exp $
|
---|
| 3 | // ---------------------------------------------------------------------------
|
---|
| 4 | //
|
---|
| 5 | // This file is a part of the CLHEP - a Class Library for High Energy Physics.
|
---|
| 6 | //
|
---|
| 7 | // This is the definitions of the inline member functions of the
|
---|
| 8 | // HepRotation class
|
---|
| 9 | //
|
---|
| 10 |
|
---|
| 11 | namespace CLHEP {
|
---|
| 12 |
|
---|
| 13 | // Put commonly used accessors as early as possible to avoid inlining misses:
|
---|
| 14 |
|
---|
| 15 | inline double HepRotation::xx() const { return rxx; }
|
---|
| 16 | inline double HepRotation::xy() const { return rxy; }
|
---|
| 17 | inline double HepRotation::xz() const { return rxz; }
|
---|
| 18 | inline double HepRotation::yx() const { return ryx; }
|
---|
| 19 | inline double HepRotation::yy() const { return ryy; }
|
---|
| 20 | inline double HepRotation::yz() const { return ryz; }
|
---|
| 21 | inline double HepRotation::zx() const { return rzx; }
|
---|
| 22 | inline double HepRotation::zy() const { return rzy; }
|
---|
| 23 | inline double HepRotation::zz() const { return rzz; }
|
---|
| 24 |
|
---|
| 25 | inline HepRep3x3 HepRotation::rep3x3() const {
|
---|
| 26 | return HepRep3x3 ( rxx, rxy, rxz,
|
---|
| 27 | ryx, ryy, ryz,
|
---|
| 28 | rzx, rzy, rzz );
|
---|
| 29 | }
|
---|
| 30 |
|
---|
| 31 | inline double HepRotation::xt() const { return 0.0; }
|
---|
| 32 | inline double HepRotation::yt() const { return 0.0; }
|
---|
| 33 | inline double HepRotation::zt() const { return 0.0; }
|
---|
| 34 | inline double HepRotation::tx() const { return 0.0; }
|
---|
| 35 | inline double HepRotation::ty() const { return 0.0; }
|
---|
| 36 | inline double HepRotation::tz() const { return 0.0; }
|
---|
| 37 | inline double HepRotation::tt() const { return 1.0; }
|
---|
| 38 |
|
---|
| 39 | inline HepRep4x4 HepRotation::rep4x4() const {
|
---|
| 40 | return HepRep4x4 ( rxx, rxy, rxz, 0.0,
|
---|
| 41 | ryx, ryy, ryz, 0.0,
|
---|
| 42 | rzx, rzy, rzz, 0.0,
|
---|
| 43 | 0.0, 0.0, 0.0, 1.0 );
|
---|
| 44 | }
|
---|
| 45 |
|
---|
| 46 | // Ctors etc:
|
---|
| 47 |
|
---|
| 48 | inline HepRotation::HepRotation() : rxx(1.0), rxy(0.0), rxz(0.0),
|
---|
| 49 | ryx(0.0), ryy(1.0), ryz(0.0),
|
---|
| 50 | rzx(0.0), rzy(0.0), rzz(1.0) {}
|
---|
| 51 |
|
---|
| 52 | inline HepRotation::HepRotation(const HepRotation & m) :
|
---|
| 53 | rxx(m.rxx), rxy(m.rxy), rxz(m.rxz),
|
---|
| 54 | ryx(m.ryx), ryy(m.ryy), ryz(m.ryz),
|
---|
| 55 | rzx(m.rzx), rzy(m.rzy), rzz(m.rzz) {}
|
---|
| 56 |
|
---|
| 57 | inline HepRotation::HepRotation
|
---|
| 58 | (double mxx, double mxy, double mxz,
|
---|
| 59 | double myx, double myy, double myz,
|
---|
| 60 | double mzx, double mzy, double mzz) :
|
---|
| 61 | rxx(mxx), rxy(mxy), rxz(mxz),
|
---|
| 62 | ryx(myx), ryy(myy), ryz(myz),
|
---|
| 63 | rzx(mzx), rzy(mzy), rzz(mzz) {}
|
---|
| 64 |
|
---|
| 65 | inline HepRotation::HepRotation ( const HepRep3x3 & m ) :
|
---|
| 66 | rxx(m.xx_), rxy(m.xy_), rxz(m.xz_),
|
---|
| 67 | ryx(m.yx_), ryy(m.yy_), ryz(m.yz_),
|
---|
| 68 | rzx(m.zx_), rzy(m.zy_), rzz(m.zz_) {}
|
---|
| 69 |
|
---|
| 70 | inline HepRotation::HepRotation(const HepRotationX & rx) :
|
---|
| 71 | rxx(1.0), rxy(0.0), rxz(0.0),
|
---|
| 72 | ryx(0.0), ryy(rx.yy()), ryz(rx.yz()),
|
---|
| 73 | rzx(0.0), rzy(rx.zy()), rzz(rx.zz()) {}
|
---|
| 74 |
|
---|
| 75 | inline HepRotation::HepRotation(const HepRotationY & ry) :
|
---|
| 76 | rxx(ry.xx()), rxy(0.0), rxz(ry.xz()),
|
---|
| 77 | ryx(0.0), ryy(1.0), ryz(0.0),
|
---|
| 78 | rzx(ry.zx()), rzy(0.0), rzz(ry.zz()) {}
|
---|
| 79 |
|
---|
| 80 | inline HepRotation::HepRotation(const HepRotationZ & rz) :
|
---|
| 81 | rxx(rz.xx()), rxy(rz.xy()), rxz(0.0),
|
---|
| 82 | ryx(rz.yx()), ryy(rz.yy()), ryz(0.0),
|
---|
| 83 | rzx(0.0), rzy(0.0), rzz(1.0) {}
|
---|
| 84 |
|
---|
| 85 | inline HepRotation::~HepRotation() {}
|
---|
| 86 |
|
---|
| 87 | // More accessors:
|
---|
| 88 |
|
---|
| 89 | inline HepRotation::HepRotation_row::HepRotation_row
|
---|
| 90 | (const HepRotation & r, int i) : rr(r), ii(i) {}
|
---|
| 91 |
|
---|
| 92 | inline double HepRotation::HepRotation_row::operator [] (int jj) const {
|
---|
| 93 | return rr(ii,jj);
|
---|
| 94 | }
|
---|
| 95 |
|
---|
| 96 | inline
|
---|
| 97 | const HepRotation::HepRotation_row HepRotation::operator [] (int i) const {
|
---|
| 98 | return HepRotation_row(*this, i);
|
---|
| 99 | }
|
---|
| 100 |
|
---|
| 101 | inline Hep3Vector HepRotation::colX() const
|
---|
| 102 | { return Hep3Vector ( rxx, ryx, rzx ); }
|
---|
| 103 | inline Hep3Vector HepRotation::colY() const
|
---|
| 104 | { return Hep3Vector ( rxy, ryy, rzy ); }
|
---|
| 105 | inline Hep3Vector HepRotation::colZ() const
|
---|
| 106 | { return Hep3Vector ( rxz, ryz, rzz ); }
|
---|
| 107 |
|
---|
| 108 | inline Hep3Vector HepRotation::rowX() const
|
---|
| 109 | { return Hep3Vector ( rxx, rxy, rxz ); }
|
---|
| 110 | inline Hep3Vector HepRotation::rowY() const
|
---|
| 111 | { return Hep3Vector ( ryx, ryy, ryz ); }
|
---|
| 112 | inline Hep3Vector HepRotation::rowZ() const
|
---|
| 113 | { return Hep3Vector ( rzx, rzy, rzz ); }
|
---|
| 114 |
|
---|
| 115 | inline HepLorentzVector HepRotation::col1() const
|
---|
| 116 | { return HepLorentzVector (colX(), 0); }
|
---|
| 117 | inline HepLorentzVector HepRotation::col2() const
|
---|
| 118 | { return HepLorentzVector (colY(), 0); }
|
---|
| 119 | inline HepLorentzVector HepRotation::col3() const
|
---|
| 120 | { return HepLorentzVector (colZ(), 0); }
|
---|
| 121 | inline HepLorentzVector HepRotation::col4() const
|
---|
| 122 | { return HepLorentzVector (0,0,0,1); }
|
---|
| 123 | inline HepLorentzVector HepRotation::row1() const
|
---|
| 124 | { return HepLorentzVector (rowX(), 0); }
|
---|
| 125 | inline HepLorentzVector HepRotation::row2() const
|
---|
| 126 | { return HepLorentzVector (rowY(), 0); }
|
---|
| 127 | inline HepLorentzVector HepRotation::row3() const
|
---|
| 128 | { return HepLorentzVector (rowZ(), 0); }
|
---|
| 129 | inline HepLorentzVector HepRotation::row4() const
|
---|
| 130 | { return HepLorentzVector (0,0,0,1); }
|
---|
| 131 |
|
---|
| 132 | inline double HepRotation::getPhi () const { return phi(); }
|
---|
| 133 | inline double HepRotation::getTheta() const { return theta(); }
|
---|
| 134 | inline double HepRotation::getPsi () const { return psi(); }
|
---|
| 135 | inline double HepRotation::getDelta() const { return delta(); }
|
---|
| 136 | inline Hep3Vector HepRotation::getAxis () const { return axis(); }
|
---|
| 137 |
|
---|
| 138 | inline HepRotation & HepRotation::operator = (const HepRotation & m) {
|
---|
| 139 | rxx = m.rxx;
|
---|
| 140 | rxy = m.rxy;
|
---|
| 141 | rxz = m.rxz;
|
---|
| 142 | ryx = m.ryx;
|
---|
| 143 | ryy = m.ryy;
|
---|
| 144 | ryz = m.ryz;
|
---|
| 145 | rzx = m.rzx;
|
---|
| 146 | rzy = m.rzy;
|
---|
| 147 | rzz = m.rzz;
|
---|
| 148 | return *this;
|
---|
| 149 | }
|
---|
| 150 |
|
---|
| 151 | inline HepRotation & HepRotation::set(const HepRep3x3 & m) {
|
---|
| 152 | rxx = m.xx_;
|
---|
| 153 | rxy = m.xy_;
|
---|
| 154 | rxz = m.xz_;
|
---|
| 155 | ryx = m.yx_;
|
---|
| 156 | ryy = m.yy_;
|
---|
| 157 | ryz = m.yz_;
|
---|
| 158 | rzx = m.zx_;
|
---|
| 159 | rzy = m.zy_;
|
---|
| 160 | rzz = m.zz_;
|
---|
| 161 | return *this;
|
---|
| 162 | }
|
---|
| 163 |
|
---|
| 164 | inline HepRotation & HepRotation::set(const HepRotationX & r) {
|
---|
| 165 | return (set (r.rep3x3()));
|
---|
| 166 | }
|
---|
| 167 | inline HepRotation & HepRotation::set(const HepRotationY & r) {
|
---|
| 168 | return (set (r.rep3x3()));
|
---|
| 169 | }
|
---|
| 170 | inline HepRotation & HepRotation::set(const HepRotationZ & r) {
|
---|
| 171 | return (set (r.rep3x3()));
|
---|
| 172 | }
|
---|
| 173 |
|
---|
| 174 | inline HepRotation & HepRotation::operator= (const HepRotationX & r) {
|
---|
| 175 | return (set (r.rep3x3()));
|
---|
| 176 | }
|
---|
| 177 | inline HepRotation & HepRotation::operator= (const HepRotationY & r) {
|
---|
| 178 | return (set (r.rep3x3()));
|
---|
| 179 | }
|
---|
| 180 | inline HepRotation & HepRotation::operator= (const HepRotationZ & r) {
|
---|
| 181 | return (set (r.rep3x3()));
|
---|
| 182 | }
|
---|
| 183 |
|
---|
| 184 | inline Hep3Vector HepRotation::operator * (const Hep3Vector & p) const {
|
---|
| 185 | return Hep3Vector(rxx*p.x() + rxy*p.y() + rxz*p.z(),
|
---|
| 186 | ryx*p.x() + ryy*p.y() + ryz*p.z(),
|
---|
| 187 | rzx*p.x() + rzy*p.y() + rzz*p.z());
|
---|
| 188 | // This is identical to the code in the CLHEP 1.6 version
|
---|
| 189 | }
|
---|
| 190 |
|
---|
| 191 | inline Hep3Vector HepRotation::operator () (const Hep3Vector & p) const {
|
---|
| 192 | register double x = p.x();
|
---|
| 193 | register double y = p.y();
|
---|
| 194 | register double z = p.z();
|
---|
| 195 | return Hep3Vector(rxx*x + rxy*y + rxz*z,
|
---|
| 196 | ryx*x + ryy*y + ryz*z,
|
---|
| 197 | rzx*x + rzy*y + rzz*z);
|
---|
| 198 | }
|
---|
| 199 |
|
---|
| 200 | inline HepLorentzVector
|
---|
| 201 | HepRotation::operator () (const HepLorentzVector & w) const {
|
---|
| 202 | return HepLorentzVector( operator() (w.vect()), w.t() );
|
---|
| 203 | }
|
---|
| 204 |
|
---|
| 205 | inline HepLorentzVector HepRotation::operator *
|
---|
| 206 | (const HepLorentzVector & p) const {
|
---|
| 207 | return operator()(p);
|
---|
| 208 | }
|
---|
| 209 |
|
---|
| 210 | inline HepRotation HepRotation::operator* (const HepRotation & r) const {
|
---|
| 211 | return HepRotation(rxx*r.rxx + rxy*r.ryx + rxz*r.rzx,
|
---|
| 212 | rxx*r.rxy + rxy*r.ryy + rxz*r.rzy,
|
---|
| 213 | rxx*r.rxz + rxy*r.ryz + rxz*r.rzz,
|
---|
| 214 | ryx*r.rxx + ryy*r.ryx + ryz*r.rzx,
|
---|
| 215 | ryx*r.rxy + ryy*r.ryy + ryz*r.rzy,
|
---|
| 216 | ryx*r.rxz + ryy*r.ryz + ryz*r.rzz,
|
---|
| 217 | rzx*r.rxx + rzy*r.ryx + rzz*r.rzx,
|
---|
| 218 | rzx*r.rxy + rzy*r.ryy + rzz*r.rzy,
|
---|
| 219 | rzx*r.rxz + rzy*r.ryz + rzz*r.rzz );
|
---|
| 220 | }
|
---|
| 221 |
|
---|
| 222 | inline HepRotation HepRotation::operator * (const HepRotationX & rx) const {
|
---|
| 223 | double yy = rx.yy();
|
---|
| 224 | double yz = rx.yz();
|
---|
| 225 | double zy = -yz;
|
---|
| 226 | double zz = yy;
|
---|
| 227 | return HepRotation(
|
---|
| 228 | rxx, rxy*yy + rxz*zy, rxy*yz + rxz*zz,
|
---|
| 229 | ryx, ryy*yy + ryz*zy, ryy*yz + ryz*zz,
|
---|
| 230 | rzx, rzy*yy + rzz*zy, rzy*yz + rzz*zz );
|
---|
| 231 | }
|
---|
| 232 |
|
---|
| 233 | inline HepRotation HepRotation::operator * (const HepRotationY & ry) const {
|
---|
| 234 | double xx = ry.xx();
|
---|
| 235 | double xz = ry.xz();
|
---|
| 236 | double zx = -xz;
|
---|
| 237 | double zz = xx;
|
---|
| 238 | return HepRotation(
|
---|
| 239 | rxx*xx + rxz*zx, rxy, rxx*xz + rxz*zz,
|
---|
| 240 | ryx*xx + ryz*zx, ryy, ryx*xz + ryz*zz,
|
---|
| 241 | rzx*xx + rzz*zx, rzy, rzx*xz + rzz*zz );
|
---|
| 242 | }
|
---|
| 243 |
|
---|
| 244 | inline HepRotation HepRotation::operator * (const HepRotationZ & rz) const {
|
---|
| 245 | double xx = rz.xx();
|
---|
| 246 | double xy = rz.xy();
|
---|
| 247 | double yx = -xy;
|
---|
| 248 | double yy = xx;
|
---|
| 249 | return HepRotation(
|
---|
| 250 | rxx*xx + rxy*yx, rxx*xy + rxy*yy, rxz,
|
---|
| 251 | ryx*xx + ryy*yx, ryx*xy + ryy*yy, ryz,
|
---|
| 252 | rzx*xx + rzy*yx, rzx*xy + rzy*yy, rzz );
|
---|
| 253 | }
|
---|
| 254 |
|
---|
| 255 |
|
---|
| 256 | inline HepRotation & HepRotation::operator *= (const HepRotation & r) {
|
---|
| 257 | return *this = (*this) * (r);
|
---|
| 258 | }
|
---|
| 259 |
|
---|
| 260 | inline HepRotation & HepRotation::operator *= (const HepRotationX & r) {
|
---|
| 261 | return *this = (*this) * (r); }
|
---|
| 262 | inline HepRotation & HepRotation::operator *= (const HepRotationY & r) {
|
---|
| 263 | return *this = (*this) * (r); }
|
---|
| 264 | inline HepRotation & HepRotation::operator *= (const HepRotationZ & r) {
|
---|
| 265 | return *this = (*this) * (r); }
|
---|
| 266 |
|
---|
| 267 | inline HepRotation & HepRotation::transform(const HepRotation & r) {
|
---|
| 268 | return *this = r * (*this);
|
---|
| 269 | }
|
---|
| 270 |
|
---|
| 271 | inline HepRotation & HepRotation::transform(const HepRotationX & r) {
|
---|
| 272 | return *this = r * (*this); }
|
---|
| 273 | inline HepRotation & HepRotation::transform(const HepRotationY & r) {
|
---|
| 274 | return *this = r * (*this); }
|
---|
| 275 | inline HepRotation & HepRotation::transform(const HepRotationZ & r) {
|
---|
| 276 | return *this = r * (*this); }
|
---|
| 277 |
|
---|
| 278 | inline HepRotation HepRotation::inverse() const {
|
---|
| 279 | return HepRotation( rxx, ryx, rzx,
|
---|
| 280 | rxy, ryy, rzy,
|
---|
| 281 | rxz, ryz, rzz );
|
---|
| 282 | }
|
---|
| 283 |
|
---|
| 284 | inline HepRotation inverseOf (const HepRotation & r) {
|
---|
| 285 | return r.inverse();
|
---|
| 286 | }
|
---|
| 287 |
|
---|
| 288 | inline HepRotation & HepRotation::invert() {
|
---|
| 289 | return *this=inverse();
|
---|
| 290 | }
|
---|
| 291 |
|
---|
| 292 | inline HepRotation & HepRotation::rotate
|
---|
| 293 | (double delta, const Hep3Vector * p) {
|
---|
| 294 | return rotate(delta, *p);
|
---|
| 295 | }
|
---|
| 296 |
|
---|
| 297 | inline bool HepRotation::operator== ( const HepRotation & r ) const {
|
---|
| 298 | return ( rxx==r.rxx && rxy==r.rxy && rxz==r.rxz &&
|
---|
| 299 | ryx==r.ryx && ryy==r.ryy && ryz==r.ryz &&
|
---|
| 300 | rzx==r.rzx && rzy==r.rzy && rzz==r.rzz );
|
---|
| 301 | }
|
---|
| 302 | inline bool HepRotation::operator!= ( const HepRotation & r ) const {
|
---|
| 303 | return ! operator==(r);
|
---|
| 304 | }
|
---|
| 305 | inline bool HepRotation::operator< ( const HepRotation & r ) const
|
---|
| 306 | { return compare(r)< 0; }
|
---|
| 307 | inline bool HepRotation::operator<=( const HepRotation & r ) const
|
---|
| 308 | { return compare(r)<=0; }
|
---|
| 309 | inline bool HepRotation::operator>=( const HepRotation & r ) const
|
---|
| 310 | { return compare(r)>=0; }
|
---|
| 311 | inline bool HepRotation::operator> ( const HepRotation & r ) const
|
---|
| 312 | { return compare(r)> 0; }
|
---|
| 313 |
|
---|
| 314 | inline double HepRotation::getTolerance() {
|
---|
| 315 | return Hep4RotationInterface::tolerance;
|
---|
| 316 | }
|
---|
| 317 | inline double HepRotation::setTolerance(double tol) {
|
---|
| 318 | return Hep4RotationInterface::setTolerance(tol);
|
---|
| 319 | }
|
---|
| 320 |
|
---|
| 321 | inline HepRotation operator * (const HepRotationX & rx, const HepRotation & r){
|
---|
| 322 | HepRep3x3 m = r.rep3x3();
|
---|
| 323 | double c = rx.yy();
|
---|
| 324 | double s = rx.zy();
|
---|
| 325 | return HepRotation ( m.xx_, m.xy_, m.xz_,
|
---|
| 326 | c*m.yx_-s*m.zx_, c*m.yy_-s*m.zy_, c*m.yz_-s*m.zz_,
|
---|
| 327 | s*m.yx_+c*m.zx_, s*m.yy_+c*m.zy_, s*m.yz_+c*m.zz_ );
|
---|
| 328 | }
|
---|
| 329 |
|
---|
| 330 | inline HepRotation operator * (const HepRotationY & ry, const HepRotation & r){
|
---|
| 331 | HepRep3x3 m = r.rep3x3();
|
---|
| 332 | double c = ry.xx();
|
---|
| 333 | double s = ry.xz();
|
---|
| 334 | return HepRotation ( c*m.xx_+s*m.zx_, c*m.xy_+s*m.zy_, c*m.xz_+s*m.zz_,
|
---|
| 335 | m.yx_, m.yy_, m.yz_,
|
---|
| 336 | -s*m.xx_+c*m.zx_,-s*m.xy_+c*m.zy_,-s*m.xz_+c*m.zz_ );
|
---|
| 337 | }
|
---|
| 338 |
|
---|
| 339 | inline HepRotation operator * (const HepRotationZ & rz, const HepRotation & r){
|
---|
| 340 | HepRep3x3 m = r.rep3x3();
|
---|
| 341 | double c = rz.xx();
|
---|
| 342 | double s = rz.yx();
|
---|
| 343 | return HepRotation ( c*m.xx_-s*m.yx_, c*m.xy_-s*m.yy_, c*m.xz_-s*m.yz_,
|
---|
| 344 | s*m.xx_+c*m.yx_, s*m.xy_+c*m.yy_, s*m.xz_+c*m.yz_,
|
---|
| 345 | m.zx_, m.zy_, m.zz_ );
|
---|
| 346 | }
|
---|
| 347 |
|
---|
| 348 | } // namespace CLHEP
|
---|