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 10.6)


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