Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/geometry/management/include/G4AffineTransform.icc

Version: [ ReleaseNotes ] [ 1.0 ] [ 1.1 ] [ 2.0 ] [ 3.0 ] [ 3.1 ] [ 3.2 ] [ 4.0 ] [ 4.0.p1 ] [ 4.0.p2 ] [ 4.1 ] [ 4.1.p1 ] [ 5.0 ] [ 5.0.p1 ] [ 5.1 ] [ 5.1.p1 ] [ 5.2 ] [ 5.2.p1 ] [ 5.2.p2 ] [ 6.0 ] [ 6.0.p1 ] [ 6.1 ] [ 6.2 ] [ 6.2.p1 ] [ 6.2.p2 ] [ 7.0 ] [ 7.0.p1 ] [ 7.1 ] [ 7.1.p1 ] [ 8.0 ] [ 8.0.p1 ] [ 8.1 ] [ 8.1.p1 ] [ 8.1.p2 ] [ 8.2 ] [ 8.2.p1 ] [ 8.3 ] [ 8.3.p1 ] [ 8.3.p2 ] [ 9.0 ] [ 9.0.p1 ] [ 9.0.p2 ] [ 9.1 ] [ 9.1.p1 ] [ 9.1.p2 ] [ 9.1.p3 ] [ 9.2 ] [ 9.2.p1 ] [ 9.2.p2 ] [ 9.2.p3 ] [ 9.2.p4 ] [ 9.3 ] [ 9.3.p1 ] [ 9.3.p2 ] [ 9.4 ] [ 9.4.p1 ] [ 9.4.p2 ] [ 9.4.p3 ] [ 9.4.p4 ] [ 9.5 ] [ 9.5.p1 ] [ 9.5.p2 ] [ 9.6 ] [ 9.6.p1 ] [ 9.6.p2 ] [ 9.6.p3 ] [ 9.6.p4 ] [ 10.0 ] [ 10.0.p1 ] [ 10.0.p2 ] [ 10.0.p3 ] [ 10.0.p4 ] [ 10.1 ] [ 10.1.p1 ] [ 10.1.p2 ] [ 10.1.p3 ] [ 10.2 ] [ 10.2.p1 ] [ 10.2.p2 ] [ 10.2.p3 ] [ 10.3 ] [ 10.3.p1 ] [ 10.3.p2 ] [ 10.3.p3 ] [ 10.4 ] [ 10.4.p1 ] [ 10.4.p2 ] [ 10.4.p3 ] [ 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /geometry/management/include/G4AffineTransform.icc (Version 11.3.0) and /geometry/management/include/G4AffineTransform.icc (Version 1.0)


                                                   >>   1 // This code implementation is the intellectual property of
                                                   >>   2 // the GEANT4 collaboration.
                                                   >>   3 //
                                                   >>   4 // By copying, distributing or modifying the Program (or any work
                                                   >>   5 // based on the Program) you indicate your acceptance of this statement,
                                                   >>   6 // and all its terms.
                                                   >>   7 //
                                                   >>   8 // $Id: G4AffineTransform.icc,v 1.2.10.1 1999/12/07 20:48:08 gunter Exp $
                                                   >>   9 // GEANT4 tag $Name: geant4-01-00 $
  1 //                                                 10 //
  2 // ******************************************* << 
  3 // * License and Disclaimer                    << 
  4 // *                                           << 
  5 // * The  Geant4 software  is  copyright of th << 
  6 // * the Geant4 Collaboration.  It is provided << 
  7 // * conditions of the Geant4 Software License << 
  8 // * LICENSE and available at  http://cern.ch/ << 
  9 // * include a list of copyright holders.      << 
 10 // *                                           << 
 11 // * Neither the authors of this software syst << 
 12 // * institutes,nor the agencies providing fin << 
 13 // * work  make  any representation or  warran << 
 14 // * regarding  this  software system or assum << 
 15 // * use.  Please see the license in the file  << 
 16 // * for the full disclaimer and the limitatio << 
 17 // *                                           << 
 18 // * This  code  implementation is the result  << 
 19 // * technical work of the GEANT4 collaboratio << 
 20 // * By using,  copying,  modifying or  distri << 
 21 // * any work based  on the software)  you  ag << 
 22 // * use  in  resulting  scientific  publicati << 
 23 // * acceptance of all terms of the Geant4 Sof << 
 24 // ******************************************* << 
 25 //                                                 11 //
 26 // G4AffineTransformation Inline implementatio     12 // G4AffineTransformation Inline implementation
 27 //                                                 13 //
 28 // ------------------------------------------- << 
 29                                                    14 
 30 inline G4AffineTransform::G4AffineTransform()  <<  15 inline G4AffineTransform::G4AffineTransform() :
 31  : rxx(1),rxy(0),rxz(0),                       <<  16  rxx(1),rxy(0),rxz(0),
 32    ryx(0),ryy(1),ryz(0),                       <<  17  ryx(0),ryy(1),ryz(0),
 33    rzx(0),rzy(0),rzz(1),                       <<  18  rzx(0),rzy(0),rzz(1),
 34    tx(0),ty(0),tz(0)                           <<  19  tx(0),ty(0),tz(0)
 35 {}                                                 20 {}
 36                                                    21 
 37 inline G4AffineTransform::G4AffineTransform(co <<  22 inline G4AffineTransform::G4AffineTransform(const G4ThreeVector& tlate) :
 38  : rxx(1),rxy(0),rxz(0),                       <<  23  rxx(1),rxy(0),rxz(0),
 39    ryx(0),ryy(1),ryz(0),                       <<  24  ryx(0),ryy(1),ryz(0),
 40    rzx(0),rzy(0),rzz(1),                       <<  25  rzx(0),rzy(0),rzz(1),
 41    tx(tlate.x()),ty(tlate.y()),tz(tlate.z())   <<  26  tx(tlate.x()),ty(tlate.y()),tz(tlate.z())
 42 {}                                                 27 {}
 43                                                    28 
 44 inline G4AffineTransform::G4AffineTransform(co <<  29 inline G4AffineTransform::G4AffineTransform(const G4RotationMatrix& rot) :
 45  : rxx(rot.xx()),rxy(rot.xy()),rxz(rot.xz()),  <<  30  rxx(rot.xx()),rxy(rot.xy()),rxz(rot.xz()),
 46    ryx(rot.yx()),ryy(rot.yy()),ryz(rot.yz()),  <<  31  ryx(rot.yx()),ryy(rot.yy()),ryz(rot.yz()),
 47    rzx(rot.zx()),rzy(rot.zy()),rzz(rot.zz()),  <<  32  rzx(rot.zx()),rzy(rot.zy()),rzz(rot.zz()),
 48    tx(0),ty(0),tz(0)                           <<  33  tx(0),ty(0),tz(0)
 49 {}                                                 34 {}
 50                                                    35 
 51 inline G4AffineTransform::G4AffineTransform( c     36 inline G4AffineTransform::G4AffineTransform( const G4RotationMatrix& rot,
 52                                              c <<  37                            const G4ThreeVector& tlate   ) :
 53  : rxx(rot.xx()),rxy(rot.xy()),rxz(rot.xz()),  <<  38  rxx(rot.xx()),rxy(rot.xy()),rxz(rot.xz()),
 54    ryx(rot.yx()),ryy(rot.yy()),ryz(rot.yz()),  <<  39  ryx(rot.yx()),ryy(rot.yy()),ryz(rot.yz()),
 55    rzx(rot.zx()),rzy(rot.zy()),rzz(rot.zz()),  <<  40  rzx(rot.zx()),rzy(rot.zy()),rzz(rot.zz()),
 56    tx(tlate.x()),ty(tlate.y()),tz(tlate.z())   <<  41  tx(tlate.x()),ty(tlate.y()),tz(tlate.z())
 57 {}                                                 42 {}
 58                                                    43 
 59 inline G4AffineTransform::G4AffineTransform( c <<  44 inline G4AffineTransform::G4AffineTransform( const G4RotationMatrix *rot,
 60                                              c <<  45                            const G4ThreeVector& tlate) :
 61  : tx(tlate.x()),ty(tlate.y()),tz(tlate.z())   <<  46  tx(tlate.x()),ty(tlate.y()),tz(tlate.z())
 62 {                                              <<  47 {
 63   if (rot != nullptr)                          <<  48   if (rot)
 64   {                                            <<  49     {
 65     rxx=rot->xx();rxy=rot->xy();rxz=rot->xz(); <<  50       rxx=rot->xx();rxy=rot->xy();rxz=rot->xz();
 66     ryx=rot->yx();ryy=rot->yy();ryz=rot->yz(); <<  51       ryx=rot->yx();ryy=rot->yy();ryz=rot->yz();
 67     rzx=rot->zx();rzy=rot->zy();rzz=rot->zz(); <<  52       rzx=rot->zx();rzy=rot->zy();rzz=rot->zz();
 68   }                                            <<  53     }
 69   else                                             54   else
 70   {                                            <<  55     {
 71     rxx=1; rxy=0; rxz=0;                       <<  56       rxx=1; rxy=0; rxz=0;
 72     ryx=0; ryy=1; ryz=0;                       <<  57       ryx=0; ryy=1; ryz=0;
 73     rzx=0; rzy=0; rzz=1;                       <<  58       rzx=0; rzy=0; rzz=1;
 74   }                                            <<  59     }
 75 }                                                  60 }
 76                                                    61 
 77 inline                                         <<  62 inline 
 78 G4AffineTransform::                                63 G4AffineTransform::
 79 G4AffineTransform( const G4double prxx,const G     64 G4AffineTransform( const G4double prxx,const G4double prxy,const G4double prxz,
 80                    const G4double pryx,const G <<  65              const G4double pryx,const G4double pryy,const G4double pryz,
 81                    const G4double przx,const G <<  66              const G4double przx,const G4double przy,const G4double przz,
 82                    const G4double ptx,const G4 <<  67              const G4double ptx,const G4double pty,const G4double ptz) :
 83  : rxx(prxx),rxy(prxy),rxz(prxz),              <<  68  rxx(prxx),rxy(prxy),rxz(prxz),
 84    ryx(pryx),ryy(pryy),ryz(pryz),              <<  69  ryx(pryx),ryy(pryy),ryz(pryz),
 85    rzx(przx),rzy(przy),rzz(przz),              <<  70  rzx(przx),rzy(przy),rzz(przz),
 86    tx(ptx),ty(pty),tz(ptz)                     <<  71  tx(ptx),ty(pty),tz(ptz)
 87 {}                                                 72 {}
 88                                                    73 
 89 inline G4AffineTransform&                      <<  74 inline G4AffineTransform G4AffineTransform::operator * (const G4AffineTransform& tf) const
 90 G4AffineTransform::operator = (const G4AffineT << 
 91 {                                                  75 {
 92   if (this == &rhs)  { return *this; }         <<  76   return G4AffineTransform(
 93   rxx = rhs.rxx; rxy = rhs.rxy; rxz = rhs.rxz; <<  77   rxx*tf.rxx+rxy*tf.ryx+rxz*tf.rzx,
 94   ryx = rhs.ryx; ryy = rhs.ryy; ryz = rhs.ryz; <<  78   rxx*tf.rxy+rxy*tf.ryy+rxz*tf.rzy,
 95   rzx = rhs.rzx; rzy = rhs.rzy; rzz = rhs.rzz; <<  79   rxx*tf.rxz+rxy*tf.ryz+rxz*tf.rzz,
 96   tx = rhs.tx; ty = rhs.ty; tz = rhs.tz;       <<  80 
 97   return *this;                                <<  81   ryx*tf.rxx+ryy*tf.ryx+ryz*tf.rzx,
 98 }                                              <<  82   ryx*tf.rxy+ryy*tf.ryy+ryz*tf.rzy,
 99                                                <<  83   ryx*tf.rxz+ryy*tf.ryz+ryz*tf.rzz,
100 inline G4AffineTransform                       <<  84 
101 G4AffineTransform::operator * (const G4AffineT <<  85   rzx*tf.rxx+rzy*tf.ryx+rzz*tf.rzx,
102 {                                              <<  86   rzx*tf.rxy+rzy*tf.ryy+rzz*tf.rzy,
103   return G4AffineTransform(rxx*tf.rxx+rxy*tf.r <<  87   rzx*tf.rxz+rzy*tf.ryz+rzz*tf.rzz,
104                            rxx*tf.rxy+rxy*tf.r <<  88   
105                            rxx*tf.rxz+rxy*tf.r <<  89   tx*tf.rxx+ty*tf.ryx+tz*tf.rzx+tf.tx,
106                                                <<  90   tx*tf.rxy+ty*tf.ryy+tz*tf.rzy+tf.ty,
107                            ryx*tf.rxx+ryy*tf.r <<  91   tx*tf.rxz+ty*tf.ryz+tz*tf.rzz+tf.tz);
108                            ryx*tf.rxy+ryy*tf.r <<  92 }
109                            ryx*tf.rxz+ryy*tf.r <<  93 
110                                                <<  94 inline G4AffineTransform& G4AffineTransform::operator *= (const G4AffineTransform& tf)
111                            rzx*tf.rxx+rzy*tf.r <<  95 {
112                            rzx*tf.rxy+rzy*tf.r <<  96          // Use temporaries for `in place' compound transform computation
113                            rzx*tf.rxz+rzy*tf.r <<  97 
114                                                <<  98   G4double nrxx=rxx*tf.rxx+rxy*tf.ryx+rxz*tf.rzx;
115                            tx*tf.rxx+ty*tf.ryx <<  99   G4double nrxy=rxx*tf.rxy+rxy*tf.ryy+rxz*tf.rzy;
116                            tx*tf.rxy+ty*tf.ryy << 100   G4double nrxz=rxx*tf.rxz+rxy*tf.ryz+rxz*tf.rzz;
117                            tx*tf.rxz+ty*tf.ryz << 101 
                                                   >> 102   G4double nryx=ryx*tf.rxx+ryy*tf.ryx+ryz*tf.rzx;
                                                   >> 103   G4double nryy=ryx*tf.rxy+ryy*tf.ryy+ryz*tf.rzy;
                                                   >> 104   G4double nryz=ryx*tf.rxz+ryy*tf.ryz+ryz*tf.rzz;
                                                   >> 105 
                                                   >> 106   G4double nrzx=rzx*tf.rxx+rzy*tf.ryx+rzz*tf.rzx;
                                                   >> 107   G4double nrzy=rzx*tf.rxy+rzy*tf.ryy+rzz*tf.rzy;
                                                   >> 108   G4double nrzz=rzx*tf.rxz+rzy*tf.ryz+rzz*tf.rzz;
                                                   >> 109   
                                                   >> 110   G4double ntx=tx*tf.rxx+ty*tf.ryx+tz*tf.rzx+tf.tx;
                                                   >> 111   G4double nty=tx*tf.rxy+ty*tf.ryy+tz*tf.rzy+tf.ty;
                                                   >> 112   G4double ntz=tx*tf.rxz+ty*tf.ryz+tz*tf.rzz+tf.tz;
                                                   >> 113 
                                                   >> 114   tx=ntx; ty=nty; tz=ntz;
                                                   >> 115   rxx=nrxx; rxy=nrxy; rxz=nrxz;
                                                   >> 116   ryx=nryx; ryy=nryy; ryz=nryz;
                                                   >> 117   rzx=nrzx; rzy=nrzy; rzz=nrzz;
                                                   >> 118 
                                                   >> 119   return *this;
                                                   >> 120 }
                                                   >> 121 
                                                   >> 122 inline G4AffineTransform& G4AffineTransform::Product(const G4AffineTransform& tf1,
                                                   >> 123                 const G4AffineTransform& tf2)
                                                   >> 124 {
                                                   >> 125   rxx=tf1.rxx*tf2.rxx + tf1.rxy*tf2.ryx + tf1.rxz*tf2.rzx;
                                                   >> 126   rxy=tf1.rxx*tf2.rxy + tf1.rxy*tf2.ryy + tf1.rxz*tf2.rzy;
                                                   >> 127   rxz=tf1.rxx*tf2.rxz + tf1.rxy*tf2.ryz + tf1.rxz*tf2.rzz;
                                                   >> 128 
                                                   >> 129   ryx=tf1.ryx*tf2.rxx + tf1.ryy*tf2.ryx + tf1.ryz*tf2.rzx;
                                                   >> 130   ryy=tf1.ryx*tf2.rxy + tf1.ryy*tf2.ryy + tf1.ryz*tf2.rzy;
                                                   >> 131   ryz=tf1.ryx*tf2.rxz + tf1.ryy*tf2.ryz + tf1.ryz*tf2.rzz;
                                                   >> 132 
                                                   >> 133   rzx=tf1.rzx*tf2.rxx + tf1.rzy*tf2.ryx + tf1.rzz*tf2.rzx;
                                                   >> 134   rzy=tf1.rzx*tf2.rxy + tf1.rzy*tf2.ryy + tf1.rzz*tf2.rzy;
                                                   >> 135   rzz=tf1.rzx*tf2.rxz + tf1.rzy*tf2.ryz + tf1.rzz*tf2.rzz;
                                                   >> 136   
                                                   >> 137   tx=tf1.tx*tf2.rxx + tf1.ty*tf2.ryx + tf1.tz*tf2.rzx   + tf2.tx;
                                                   >> 138   ty=tf1.tx*tf2.rxy + tf1.ty*tf2.ryy + tf1.tz*tf2.rzy   + tf2.ty;
                                                   >> 139   tz=tf1.tx*tf2.rxz + tf1.ty*tf2.ryz + tf1.tz*tf2.rzz   + tf2.tz; 
                                                   >> 140   
                                                   >> 141   return *this;
118 }                                                 142 }
119                                                   143 
120 inline G4AffineTransform&                         144 inline G4AffineTransform&
121 G4AffineTransform::operator *= (const G4Affine << 145 G4AffineTransform::InverseProduct( const G4AffineTransform& tf1,
                                                   >> 146            const G4AffineTransform& tf2)
122 {                                                 147 {
123   // Use temporaries for `in place' compound t << 148   G4double itf2tx = - tf2.tx*tf2.rxx - tf2.ty*tf2.rxy - tf2.tz*tf2.rxz;
124   //                                           << 149   G4double itf2ty = - tf2.tx*tf2.ryx - tf2.ty*tf2.ryy - tf2.tz*tf2.ryz;
125   G4double nrxx=rxx*tf.rxx+rxy*tf.ryx+rxz*tf.r << 150   G4double itf2tz = - tf2.tx*tf2.rzx - tf2.ty*tf2.rzy - tf2.tz*tf2.rzz;
126   G4double nrxy=rxx*tf.rxy+rxy*tf.ryy+rxz*tf.r << 
127   G4double nrxz=rxx*tf.rxz+rxy*tf.ryz+rxz*tf.r << 
128                                                << 
129   G4double nryx=ryx*tf.rxx+ryy*tf.ryx+ryz*tf.r << 
130   G4double nryy=ryx*tf.rxy+ryy*tf.ryy+ryz*tf.r << 
131   G4double nryz=ryx*tf.rxz+ryy*tf.ryz+ryz*tf.r << 
132                                                << 
133   G4double nrzx=rzx*tf.rxx+rzy*tf.ryx+rzz*tf.r << 
134   G4double nrzy=rzx*tf.rxy+rzy*tf.ryy+rzz*tf.r << 
135   G4double nrzz=rzx*tf.rxz+rzy*tf.ryz+rzz*tf.r << 
136                                                << 
137   G4double ntx=tx*tf.rxx+ty*tf.ryx+tz*tf.rzx+t << 
138   G4double nty=tx*tf.rxy+ty*tf.ryy+tz*tf.rzy+t << 
139   G4double ntz=tx*tf.rxz+ty*tf.ryz+tz*tf.rzz+t << 
140                                                << 
141   tx=ntx; ty=nty; tz=ntz;                      << 
142   rxx=nrxx; rxy=nrxy; rxz=nrxz;                << 
143   ryx=nryx; ryy=nryy; ryz=nryz;                << 
144   rzx=nrzx; rzy=nrzy; rzz=nrzz;                << 
145                                                   151 
146   return *this;                                << 152   rxx=tf1.rxx*tf2.rxx+tf1.rxy*tf2.rxy+tf1.rxz*tf2.rxz;
                                                   >> 153   rxy=tf1.rxx*tf2.ryx+tf1.rxy*tf2.ryy+tf1.rxz*tf2.ryz;
                                                   >> 154   rxz=tf1.rxx*tf2.rzx+tf1.rxy*tf2.rzy+tf1.rxz*tf2.rzz;
                                                   >> 155 
                                                   >> 156   ryx=tf1.ryx*tf2.rxx+tf1.ryy*tf2.rxy+tf1.ryz*tf2.rxz;
                                                   >> 157   ryy=tf1.ryx*tf2.ryx+tf1.ryy*tf2.ryy+tf1.ryz*tf2.ryz;
                                                   >> 158   ryz=tf1.ryx*tf2.rzx+tf1.ryy*tf2.rzy+tf1.ryz*tf2.rzz;
                                                   >> 159 
                                                   >> 160   rzx=tf1.rzx*tf2.rxx+tf1.rzy*tf2.rxy+tf1.rzz*tf2.rxz;
                                                   >> 161   rzy=tf1.rzx*tf2.ryx+tf1.rzy*tf2.ryy+tf1.rzz*tf2.ryz;
                                                   >> 162   rzz=tf1.rzx*tf2.rzx+tf1.rzy*tf2.rzy+tf1.rzz*tf2.rzz;
                                                   >> 163   
                                                   >> 164   tx=tf1.tx*tf2.rxx+tf1.ty*tf2.rxy+tf1.tz*tf2.rxz+itf2tx;
                                                   >> 165   ty=tf1.tx*tf2.ryx+tf1.ty*tf2.ryy+tf1.tz*tf2.ryz+itf2ty;
                                                   >> 166   tz=tf1.tx*tf2.rzx+tf1.ty*tf2.rzy+tf1.tz*tf2.rzz+itf2tz;
                                                   >> 167 
                                                   >> 168   return *this;
147 }                                                 169 }
148                                                   170 
149 inline G4AffineTransform&                      << 171 inline
150 G4AffineTransform::Product( const G4AffineTran << 172 G4ThreeVector G4AffineTransform::TransformPoint(const G4ThreeVector& vec) const
151                             const G4AffineTran << 
152 {                                                 173 {
153   rxx = tf1.rxx*tf2.rxx + tf1.rxy*tf2.ryx + tf << 174   return G4ThreeVector( vec.x()*rxx + vec.y()*ryx + vec.z()*rzx   + tx,
154   rxy = tf1.rxx*tf2.rxy + tf1.rxy*tf2.ryy + tf << 175                   vec.x()*rxy + vec.y()*ryy + vec.z()*rzy   + ty,
155   rxz = tf1.rxx*tf2.rxz + tf1.rxy*tf2.ryz + tf << 176                   vec.x()*rxz + vec.y()*ryz + vec.z()*rzz   + tz  );
156                                                << 
157   ryx = tf1.ryx*tf2.rxx + tf1.ryy*tf2.ryx + tf << 
158   ryy = tf1.ryx*tf2.rxy + tf1.ryy*tf2.ryy + tf << 
159   ryz = tf1.ryx*tf2.rxz + tf1.ryy*tf2.ryz + tf << 
160                                                << 
161   rzx = tf1.rzx*tf2.rxx + tf1.rzy*tf2.ryx + tf << 
162   rzy = tf1.rzx*tf2.rxy + tf1.rzy*tf2.ryy + tf << 
163   rzz = tf1.rzx*tf2.rxz + tf1.rzy*tf2.ryz + tf << 
164                                                << 
165   tx = tf1.tx*tf2.rxx + tf1.ty*tf2.ryx + tf1.t << 
166   ty = tf1.tx*tf2.rxy + tf1.ty*tf2.ryy + tf1.t << 
167   tz = tf1.tx*tf2.rxz + tf1.ty*tf2.ryz + tf1.t << 
168                                                << 
169   return *this;                                << 
170 }                                                 177 }
171                                                   178 
172 inline G4AffineTransform&                      << 179 inline
173 G4AffineTransform::InverseProduct( const G4Aff << 180 G4ThreeVector G4AffineTransform::TransformAxis(const G4ThreeVector& axis) const
174                                    const G4Aff << 
175 {                                                 181 {
176   if ((tf2.rxx + tf2.ryy + tf2.rzz) == 3.)     << 182   return G4ThreeVector( axis.x()*rxx + axis.y()*ryx + axis.z()*rzx,
177   {                                            << 183                   axis.x()*rxy + axis.y()*ryy + axis.z()*rzy,
178     rxx = tf1.rxx;                             << 184                   axis.x()*rxz + axis.y()*ryz + axis.z()*rzz  );
179     rxy = tf1.rxy;                             << 185 
180     rxz = tf1.rxz;                             << 
181                                                << 
182     ryx = tf1.ryx;                             << 
183     ryy = tf1.ryy;                             << 
184     ryz = tf1.ryz;                             << 
185                                                << 
186     rzx = tf1.rzx;                             << 
187     rzy = tf1.rzy;                             << 
188     rzz = tf1.rzz;                             << 
189                                                << 
190     tx = tf1.tx - tf2.tx;                      << 
191     ty = tf1.ty - tf2.ty;                      << 
192     tz = tf1.tz - tf2.tz;                      << 
193   }                                            << 
194   else                                         << 
195   {                                            << 
196     G4double tf1rxx = tf1.rxx, tf1rxy = tf1.rx << 
197     rxx = tf1rxx*tf2.rxx + tf1rxy*tf2.rxy + tf << 
198     rxy = tf1rxx*tf2.ryx + tf1rxy*tf2.ryy + tf << 
199     rxz = tf1rxx*tf2.rzx + tf1rxy*tf2.rzy + tf << 
200                                                << 
201     G4double tf1ryx = tf1.ryx, tf1ryy = tf1.ry << 
202     ryx = tf1ryx*tf2.rxx + tf1ryy*tf2.rxy + tf << 
203     ryy = tf1ryx*tf2.ryx + tf1ryy*tf2.ryy + tf << 
204     ryz = tf1ryx*tf2.rzx + tf1ryy*tf2.rzy + tf << 
205                                                << 
206     G4double tf1rzx = tf1.rzx, tf1rzy = tf1.rz << 
207     rzx = tf1rzx*tf2.rxx + tf1rzy*tf2.rxy + tf << 
208     rzy = tf1rzx*tf2.ryx + tf1rzy*tf2.ryy + tf << 
209     rzz = tf1rzx*tf2.rzx + tf1rzy*tf2.rzy + tf << 
210                                                << 
211     G4double tf1_2tx = tf1.tx - tf2.tx;        << 
212     G4double tf1_2ty = tf1.ty - tf2.ty;        << 
213     G4double tf1_2tz = tf1.tz - tf2.tz;        << 
214     tx = tf1_2tx*tf2.rxx + tf1_2ty*tf2.rxy + t << 
215     ty = tf1_2tx*tf2.ryx + tf1_2ty*tf2.ryy + t << 
216     tz = tf1_2tx*tf2.rzx + tf1_2ty*tf2.rzy + t << 
217   }                                            << 
218   return *this;                                << 
219 }                                              << 
220                                                << 
221 inline G4ThreeVector                           << 
222 G4AffineTransform::TransformPoint(const G4Thre << 
223 {                                              << 
224   G4double vecx = vec.x(), vecy = vec.y(), vec << 
225   return { vecx*rxx + vecy*ryx + vecz*rzx + tx << 
226            vecx*rxy + vecy*ryy + vecz*rzy + ty << 
227            vecx*rxz + vecy*ryz + vecz*rzz + tz << 
228 }                                              << 
229                                                << 
230 inline G4ThreeVector                           << 
231 G4AffineTransform::InverseTransformPoint(const << 
232 {                                              << 
233   G4double vecx = vec.x()-tx, vecy = vec.y()-t << 
234   return { vecx*rxx + vecy*rxy + vecz*rxz,     << 
235            vecx*ryx + vecy*ryy + vecz*ryz,     << 
236            vecx*rzx + vecy*rzy + vecz*rzz };   << 
237 }                                              << 
238                                                << 
239 inline G4ThreeVector                           << 
240 G4AffineTransform::TransformAxis(const G4Three << 
241 {                                              << 
242   G4double axisx = axis.x(), axisy = axis.y(), << 
243   return { axisx*rxx + axisy*ryx + axisz*rzx,  << 
244            axisx*rxy + axisy*ryy + axisz*rzy,  << 
245            axisx*rxz + axisy*ryz + axisz*rzz } << 
246 }                                              << 
247                                                << 
248 inline G4ThreeVector                           << 
249 G4AffineTransform::InverseTransformAxis(const  << 
250 {                                              << 
251   G4double axisx = axis.x(), axisy = axis.y(), << 
252   return { axisx*rxx + axisy*rxy + axisz*rxz,  << 
253            axisx*ryx + axisy*ryy + axisz*ryz,  << 
254            axisx*rzx + axisy*rzy + axisz*rzz } << 
255 }                                                 186 }
256                                                   187 
257 inline                                            188 inline
258 void G4AffineTransform::ApplyPointTransform(G4    189 void G4AffineTransform::ApplyPointTransform(G4ThreeVector& vec) const
259 {                                                 190 {
260   G4double vecx = vec.x(), vecy = vec.y(), vec << 191   G4double x = vec.x()*rxx + vec.y()*ryx + vec.z()*rzx    + tx;
261   vec.setX( vecx*rxx + vecy*ryx + vecz*rzx + t << 192   G4double y = vec.x()*rxy + vec.y()*ryy + vec.z()*rzy    + ty;
262   vec.setY( vecx*rxy + vecy*ryy + vecz*rzy + t << 193   G4double z = vec.x()*rxz + vec.y()*ryz + vec.z()*rzz    + tz;
263   vec.setZ( vecx*rxz + vecy*ryz + vecz*rzz + t << 194   
                                                   >> 195   vec.setX(x);
                                                   >> 196   vec.setY(y);
                                                   >> 197   vec.setZ(z);
264 }                                                 198 }
265                                                   199 
266 inline                                            200 inline
267 void G4AffineTransform::ApplyAxisTransform(G4T    201 void G4AffineTransform::ApplyAxisTransform(G4ThreeVector& axis) const
268 {                                                 202 {
269   G4double axisx = axis.x(), axisy = axis.y(), << 203   G4double x = axis.x()*rxx + axis.y()*ryx + axis.z()*rzx;
270   axis.setX( axisx*rxx + axisy*ryx + axisz*rzx << 204   G4double y = axis.x()*rxy + axis.y()*ryy + axis.z()*rzy;
271   axis.setY( axisx*rxy + axisy*ryy + axisz*rzy << 205   G4double z = axis.x()*rxz + axis.y()*ryz + axis.z()*rzz;
272   axis.setZ( axisx*rxz + axisy*ryz + axisz*rzz << 206   
                                                   >> 207   axis.setX(x);
                                                   >> 208   axis.setY(y);
                                                   >> 209   axis.setZ(z);
273 }                                                 210 }
274                                                   211 
275 inline                                            212 inline
276 G4AffineTransform G4AffineTransform::Inverse()    213 G4AffineTransform G4AffineTransform::Inverse() const
277 {                                                 214 {
278   G4double ttx = -tx, tty = -ty, ttz = -tz;    << 215   return G4AffineTransform( rxx, ryx, rzx,
279   return G4AffineTransform( rxx, ryx, rzx,     << 216           rxy, ryy, rzy,
280                             rxy, ryy, rzy,     << 217           rxz, ryz, rzz,
281                             rxz, ryz, rzz,     << 218          
282                             ttx*rxx + tty*rxy  << 219          -tx*rxx - ty*rxy - tz*rxz,
283                             ttx*ryx + tty*ryy  << 220          -tx*ryx - ty*ryy - tz*ryz,
284                             ttx*rzx + tty*rzy  << 221                                  -tx*rzx - ty*rzy - tz*rzz  );
285 }                                                 222 }
286                                                   223 
287 inline                                            224 inline
288 G4AffineTransform& G4AffineTransform::Invert()    225 G4AffineTransform& G4AffineTransform::Invert()
289 {                                                 226 {
290   G4double ttx = -tx, tty = -ty, ttz = -tz;    << 227   G4double v1 = -tx*rxx - ty*rxy - tz*rxz;
291            tx = ttx*rxx + tty*rxy + ttz*rxz;   << 228   G4double v2 = -tx*ryx - ty*ryy - tz*ryz;
292            ty = ttx*ryx + tty*ryy + ttz*ryz;   << 229   G4double v3 = -tx*rzx - ty*rzy - tz*rzz;
293            tz = ttx*rzx + tty*rzy + ttz*rzz;   << 230   
294                                                << 231   tx=v1; ty=v2; tz=v3;
295   G4double tmp1=ryx; ryx=rxy; rxy=tmp1;        << 232   
296   G4double tmp2=rzx; rzx=rxz; rxz=tmp2;        << 233   G4double tmp1=ryx; ryx=rxy; rxy=tmp1;
297   G4double tmp3=rzy; rzy=ryz; ryz=tmp3;        << 234   G4double tmp2=rzx; rzx=rxz; rxz=tmp2;
                                                   >> 235   G4double tmp3=rzy; rzy=ryz; ryz=tmp3;
                                                   >> 236   
                                                   >> 237   return *this;
298                                                   238 
299   return *this;                                << 
300 }                                                 239 }
301                                                   240 
302 inline                                            241 inline
303 G4AffineTransform& G4AffineTransform::operator    242 G4AffineTransform& G4AffineTransform::operator +=(const G4ThreeVector& tlate)
304 {                                                 243 {
305   tx += tlate.x();                             << 244   tx += tlate.x();
306   ty += tlate.y();                             << 245   ty += tlate.y();
307   tz += tlate.z();                             << 246   tz += tlate.z();
308                                                << 247   
309   return *this;                                << 248   return *this;
310 }                                                 249 }
311                                                   250 
312 inline                                            251 inline
313 G4AffineTransform& G4AffineTransform::operator    252 G4AffineTransform& G4AffineTransform::operator -=(const G4ThreeVector& tlate)
314 {                                                 253 {
315   tx -= tlate.x();                             << 254   tx -= tlate.x();
316   ty -= tlate.y();                             << 255   ty -= tlate.y();
317   tz -= tlate.z();                             << 256   tz -= tlate.z();
318                                                << 257   
319   return *this;                                << 258   return *this;
320 }                                                 259 }
321                                                   260 
322 inline                                            261 inline
323 G4bool G4AffineTransform::operator == (const G    262 G4bool G4AffineTransform::operator == (const G4AffineTransform& tf) const
324 {                                                 263 {
325   return tx==tf.tx&&ty==tf.ty&&tz==tf.tz&&     << 264   return (tx==tf.tx&&ty==tf.ty&&tz==tf.tz&&
326          rxx==tf.rxx&&rxy==tf.rxy&&rxz==tf.rxz << 265     rxx==tf.rxx&&rxy==tf.rxy&&rxz==tf.rxz&&
327          ryx==tf.ryx&&ryy==tf.ryy&&ryz==tf.ryz << 266     ryx==tf.ryx&&ryy==tf.ryy&&ryz==tf.ryz&&
328          rzx==tf.rzx&&rzy==tf.rzy&&rzz==tf.rzz << 267     rzx==tf.rzx&&rzy==tf.rzy&&rzz==tf.rzz) ? true : false;
329 }                                                 268 }
330                                                << 
331 inline                                            269 inline
332 G4bool G4AffineTransform::operator != (const G    270 G4bool G4AffineTransform::operator != (const G4AffineTransform& tf) const
333 {                                                 271 {
334   return tx!=tf.tx||ty!=tf.ty||tz!=tf.tz||     << 272   return (tx!=tf.tx||ty!=tf.ty||tz!=tf.tz||
335          rxx!=tf.rxx||rxy!=tf.rxy||rxz!=tf.rxz << 273     rxx!=tf.rxx||rxy!=tf.rxy||rxz!=tf.rxz||
336          ryx!=tf.ryx||ryy!=tf.ryy||ryz!=tf.ryz << 274     ryx!=tf.ryx||ryy!=tf.ryy||ryz!=tf.ryz||
337          rzx!=tf.rzx||rzy!=tf.rzy||rzz!=tf.rzz << 275     rzx!=tf.rzx||rzy!=tf.rzy||rzz!=tf.rzz) ? true : false;
338 }                                                 276 }
339                                                   277 
340 inline                                            278 inline
341 G4double G4AffineTransform::operator [] (const    279 G4double G4AffineTransform::operator [] (const G4int n) const
342 {                                                 280 {
343   G4double v = 0.0;                            << 281   G4double v;
344   switch(n)                                    << 282   switch(n)
345   {                                            << 283     {
346     case 0:                                    << 284     case 0:
347             v=rxx;                             << 285       v=rxx;
348             break;                             << 286       break;
349     case 1:                                    << 287     case 1:
350             v=rxy;                             << 288       v=rxy;
351             break;                             << 289       break;
352     case 2:                                    << 290     case 2:
353             v=rxz;                             << 291       v=rxz;
354             break;                             << 292       break;
355     case 4:                                    << 293     case 4:
356             v=ryx;                             << 294       v=ryx;
357             break;                             << 295       break;
358     case 5:                                    << 296     case 5:
359             v=ryy;                             << 297       v=ryy;
360             break;                             << 298       break;
361     case 6:                                    << 299     case 6:
362             v=ryz;                             << 300       v=ryz;
363             break;                             << 301       break;
364     case 8:                                    << 302     case 8:
365             v=rzx;                             << 303       v=rzx;
366             break;                             << 304       break;
367     case 9:                                    << 305     case 9:
368             v=rzy;                             << 306       v=rzy;
369             break;                             << 307       break;
370     case 10:                                   << 308     case 10:
371             v=rzz;                             << 309       v=rzz;
372             break;                             << 310       break;
373     case 12:                                   << 311     case 12:
374             v=tx;                              << 312       v=tx;
375             break;                             << 313       break;
376     case 13:                                   << 314     case 13:
377             v=ty;                              << 315       v=ty;
378             break;                             << 316       break;
379     case 14:                                   << 317     case 14:
380             v=tz;                              << 318       v=tz;
381             break;                             << 319       break;
382     case 3:                                    << 320     case 3:
383     case 7:                                    << 321     case 7:
384     case 11:                                   << 322     case 11:
385             break;                             << 323       v=0;
386     case 15:                                   << 324       break;
387             v=1.0;                             << 325     case 15:
388             break;                             << 326       v=1;
389   }                                            << 327       break;
390   return v;                                    << 328     }
                                                   >> 329   return v;
391 }                                                 330 }
392                                                   331 
393 inline                                            332 inline
394 G4bool G4AffineTransform::IsRotated() const       333 G4bool G4AffineTransform::IsRotated() const
395 {                                                 334 {
396   return !(rxx==1.0 && ryy==1.0 && rzz==1.0);  << 335   return (rxx==1.0 && ryy==1.0 && rzz==1.0) ? false : true;
397 }                                                 336 }
398                                                   337 
399 inline                                            338 inline 
400 G4bool G4AffineTransform::IsTranslated() const    339 G4bool G4AffineTransform::IsTranslated() const
401 {                                                 340 {
402   return (tx != 0.0) || (ty != 0.0) || (tz !=  << 341   return (tx || ty || tz) ? true:false;
403 }                                                 342 }
404                                                   343 
405 inline G4RotationMatrix G4AffineTransform::Net << 344 inline G4RotationMatrix G4AffineTransform::NetRotation() const {
406 {                                              << 345   G4RotationMatrix m;
407   return G4Rep3x3(rxx,rxy,rxz,                 << 346   return m.rotateAxes(G4ThreeVector(rxx,ryx,rzx),
408                   ryx,ryy,ryz,                 << 347           G4ThreeVector(rxy,ryy,rzy),
409                   rzx,rzy,rzz);                << 348                       G4ThreeVector(rxz,ryz,rzz));
410 }                                              << 
411                                                << 
412 inline G4RotationMatrix G4AffineTransform::Inv << 
413 {                                              << 
414   return G4Rep3x3(rxx,ryx,rzx,                 << 
415                   rxy,ryy,rzy,                 << 
416                   rxz,ryz,rzz);                << 
417 }                                                 349 }
418                                                   350 
419 inline                                            351 inline
420 G4ThreeVector G4AffineTransform::NetTranslatio    352 G4ThreeVector G4AffineTransform::NetTranslation() const
421 {                                                 353 {
422   return {tx,ty,tz};                           << 354   return G4ThreeVector(tx,ty,tz);
423 }                                              << 
424                                                << 
425 inline                                         << 
426 G4ThreeVector G4AffineTransform::InverseNetTra << 
427 {                                              << 
428   G4double ttx = -tx, tty = -ty, ttz = -tz;    << 
429   G4double invtx = ttx*rxx + tty*rxy + ttz*rxz << 
430   G4double invty = ttx*ryx + tty*ryy + ttz*ryz << 
431   G4double invtz = ttx*rzx + tty*rzy + ttz*rzz << 
432   return {invtx,invty,invtz};                  << 
433 }                                                 355 }
434                                                   356 
435 inline                                            357 inline 
436 void G4AffineTransform::SetNetRotation(const G    358 void G4AffineTransform::SetNetRotation(const G4RotationMatrix& rot)
437 {                                                 359 {
438   rxx=rot.xx();                                << 360   rxx=rot.xx();
439   rxy=rot.xy();                                << 361   rxy=rot.xy();
440   rxz=rot.xz();                                << 362   rxz=rot.xz();
441   ryx=rot.yx();                                << 363   ryx=rot.yx();
442   ryy=rot.yy();                                << 364   ryy=rot.yy();
443   ryz=rot.yz();                                << 365   ryz=rot.yz();
444   rzx=rot.zx();                                << 366   rzx=rot.zx();
445   rzy=rot.zy();                                << 367   rzy=rot.zy();
446   rzz=rot.zz();                                << 368   rzz=rot.zz();
447 }                                                 369 }
448                                                   370 
449 inline                                            371 inline
450 void G4AffineTransform::SetNetTranslation(cons    372 void G4AffineTransform::SetNetTranslation(const G4ThreeVector& tlate)
451 {                                                 373 {
452   tx=tlate.x();                                << 374   tx=tlate.x();
453   ty=tlate.y();                                << 375   ty=tlate.y();
454   tz=tlate.z();                                << 376   tz=tlate.z();
455 }                                              << 
456                                                << 
457 inline                                         << 
458 G4AffineTransform::operator G4Transform3D () c << 
459 {                                              << 
460   return G4Transform3D(NetRotation().inverse() << 
461 }                                              << 
462                                                << 
463 inline                                         << 
464 std::ostream& operator << (std::ostream& os, c << 
465 {                                              << 
466   std::streamsize oldPrec = os.precision(6);   << 
467   G4double DeviationTolerance = 1.0e-05;       << 
468                                                << 
469   G4double diagDeviation = 0.0;                << 
470   G4double offdDeviationUL = 0.0;              << 
471   G4double offdDeviationDR = 0.0;              << 
472   G4double offdDeviation = 0.0;                << 
473                                                << 
474   os << "  Transformation: " << G4endl;        << 
475                                                << 
476   // double  a = std::max ( 1, 2, 3 ) ;        << 
477                                                << 
478   G4bool UnitTr = ! transf.IsRotated();        << 
479   diagDeviation = std::max( std::fabs( transf[ << 
480                             std::fabs( transf[ << 
481   diagDeviation = std::max( diagDeviation,     << 
482                             std::fabs( transf[ << 
483                                                << 
484   offdDeviationUL = std::max( std::fabs( trans << 
485                               std::fabs( trans << 
486   offdDeviationUL = std::max( offdDeviationUL, << 
487                               std::fabs( trans << 
488                                                << 
489   offdDeviationDR = std::max( std::fabs( trans << 
490                               std::fabs( trans << 
491   offdDeviationDR = std::max( offdDeviationDR, << 
492                               std::fabs( trans << 
493   offdDeviation = std::max( offdDeviationUL, o << 
494                                                << 
495   if( UnitTr || std::max(diagDeviation, offdDe << 
496   {                                            << 
497      os << "    UNIT  Rotation " << G4endl;    << 
498   }                                            << 
499   else                                         << 
500   {                                            << 
501      os << "rx/x,y,z: "                        << 
502         << transf[0]  << " " << transf[1] << " << 
503         << "ry/x,y,z: "                        << 
504         << transf[4]  << " " << transf[5] << " << 
505         << "rz/x,y,z: "                        << 
506         << transf[8]  << " " << transf[9] << " << 
507   }                                            << 
508                                                << 
509   os << "tr/x,y,z: " << transf[12]  << " " <<  << 
510      << G4endl;                                << 
511                                                << 
512   os.precision(oldPrec);                       << 
513                                                << 
514   return os;                                   << 
515 }                                                 377 }
516                                                   378