Skip to content
Snippets Groups Projects
Commit 25ce267e authored by Evgueni Tcherniaev's avatar Evgueni Tcherniaev
Browse files

Use of temporary variables

parent 78702576
No related branches found
No related tags found
No related merge requests found
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
// ******************************************************************** // ********************************************************************
// //
// //
// $Id: G4AffineTransform.icc 98309 2016-07-06 10:30:15Z gcosmo $ // $Id: G4AffineTransform.icc 98307 2016-07-06 10:28:35Z gcosmo $
// //
// //
// G4AffineTransformation Inline implementation // G4AffineTransformation Inline implementation
...@@ -50,9 +50,7 @@ inline G4AffineTransform::G4AffineTransform(const G4RotationMatrix& rot) ...@@ -50,9 +50,7 @@ inline G4AffineTransform::G4AffineTransform(const G4RotationMatrix& rot)
ryx(rot.yx()),ryy(rot.yy()),ryz(rot.yz()), ryx(rot.yx()),ryy(rot.yy()),ryz(rot.yz()),
rzx(rot.zx()),rzy(rot.zy()),rzz(rot.zz()), rzx(rot.zx()),rzy(rot.zy()),rzz(rot.zz()),
tx(0),ty(0),tz(0) tx(0),ty(0),tz(0)
{ {}
if (rxx==1. && ryy==1. && rzz==1.) { rxy = rxz = ryx = ryz = rzx = rzy = 0; }
}
inline G4AffineTransform::G4AffineTransform( const G4RotationMatrix& rot, inline G4AffineTransform::G4AffineTransform( const G4RotationMatrix& rot,
const G4ThreeVector& tlate ) const G4ThreeVector& tlate )
...@@ -60,9 +58,7 @@ inline G4AffineTransform::G4AffineTransform( const G4RotationMatrix& rot, ...@@ -60,9 +58,7 @@ inline G4AffineTransform::G4AffineTransform( const G4RotationMatrix& rot,
ryx(rot.yx()),ryy(rot.yy()),ryz(rot.yz()), ryx(rot.yx()),ryy(rot.yy()),ryz(rot.yz()),
rzx(rot.zx()),rzy(rot.zy()),rzz(rot.zz()), rzx(rot.zx()),rzy(rot.zy()),rzz(rot.zz()),
tx(tlate.x()),ty(tlate.y()),tz(tlate.z()) tx(tlate.x()),ty(tlate.y()),tz(tlate.z())
{ {}
if (rxx==1. && ryy==1. && rzz==1.) { rxy = rxz = ryx = ryz = rzx = rzy = 0; }
}
inline G4AffineTransform::G4AffineTransform( const G4RotationMatrix* rot, inline G4AffineTransform::G4AffineTransform( const G4RotationMatrix* rot,
const G4ThreeVector& tlate) const G4ThreeVector& tlate)
...@@ -73,7 +69,6 @@ inline G4AffineTransform::G4AffineTransform( const G4RotationMatrix* rot, ...@@ -73,7 +69,6 @@ inline G4AffineTransform::G4AffineTransform( const G4RotationMatrix* rot,
rxx=rot->xx();rxy=rot->xy();rxz=rot->xz(); rxx=rot->xx();rxy=rot->xy();rxz=rot->xz();
ryx=rot->yx();ryy=rot->yy();ryz=rot->yz(); ryx=rot->yx();ryy=rot->yy();ryz=rot->yz();
rzx=rot->zx();rzy=rot->zy();rzz=rot->zz(); rzx=rot->zx();rzy=rot->zy();rzz=rot->zz();
if (rxx==1. && ryy==1. && rzz==1.) { rxy = rxz = ryx = ryz = rzx = rzy = 0; }
} }
else else
{ {
...@@ -93,9 +88,7 @@ G4AffineTransform( const G4double prxx,const G4double prxy,const G4double prxz, ...@@ -93,9 +88,7 @@ G4AffineTransform( const G4double prxx,const G4double prxy,const G4double prxz,
ryx(pryx),ryy(pryy),ryz(pryz), ryx(pryx),ryy(pryy),ryz(pryz),
rzx(przx),rzy(przy),rzz(przz), rzx(przx),rzy(przy),rzz(przz),
tx(ptx),ty(pty),tz(ptz) tx(ptx),ty(pty),tz(ptz)
{ {}
if (rxx==1. && ryy==1. && rzz==1.) { rxy = rxz = ryx = ryz = rzx = rzy = 0; }
}
inline G4AffineTransform inline G4AffineTransform
G4AffineTransform::operator * (const G4AffineTransform& tf) const G4AffineTransform::operator * (const G4AffineTransform& tf) const
...@@ -144,7 +137,6 @@ G4AffineTransform::operator *= (const G4AffineTransform& tf) ...@@ -144,7 +137,6 @@ G4AffineTransform::operator *= (const G4AffineTransform& tf)
ryx=nryx; ryy=nryy; ryz=nryz; ryx=nryx; ryy=nryy; ryz=nryz;
rzx=nrzx; rzy=nrzy; rzz=nrzz; rzx=nrzx; rzy=nrzy; rzz=nrzz;
if (rxx==1. && ryy==1. && rzz==1.) { rxy = rxz = ryx = ryz = rzx = rzy = 0; }
return *this; return *this;
} }
...@@ -168,7 +160,6 @@ G4AffineTransform::Product(const G4AffineTransform& tf1, ...@@ -168,7 +160,6 @@ G4AffineTransform::Product(const G4AffineTransform& tf1,
ty=tf1.tx*tf2.rxy + tf1.ty*tf2.ryy + tf1.tz*tf2.rzy + tf2.ty; ty=tf1.tx*tf2.rxy + tf1.ty*tf2.ryy + tf1.tz*tf2.rzy + tf2.ty;
tz=tf1.tx*tf2.rxz + tf1.ty*tf2.ryz + tf1.tz*tf2.rzz + tf2.tz; tz=tf1.tx*tf2.rxz + tf1.ty*tf2.ryz + tf1.tz*tf2.rzz + tf2.tz;
if (rxx==1. && ryy==1. && rzz==1.) { rxy = rxz = ryx = ryz = rzx = rzy = 0; }
return *this; return *this;
} }
...@@ -196,32 +187,34 @@ G4AffineTransform::InverseProduct( const G4AffineTransform& tf1, ...@@ -196,32 +187,34 @@ G4AffineTransform::InverseProduct( const G4AffineTransform& tf1,
ty=tf1.tx*tf2.ryx+tf1.ty*tf2.ryy+tf1.tz*tf2.ryz+itf2ty; ty=tf1.tx*tf2.ryx+tf1.ty*tf2.ryy+tf1.tz*tf2.ryz+itf2ty;
tz=tf1.tx*tf2.rzx+tf1.ty*tf2.rzy+tf1.tz*tf2.rzz+itf2tz; tz=tf1.tx*tf2.rzx+tf1.ty*tf2.rzy+tf1.tz*tf2.rzz+itf2tz;
if (rxx==1. && ryy==1. && rzz==1.) { rxy = rxz = ryx = ryz = rzx = rzy = 0; }
return *this; return *this;
} }
inline inline
G4ThreeVector G4AffineTransform::TransformPoint(const G4ThreeVector& vec) const G4ThreeVector G4AffineTransform::TransformPoint(const G4ThreeVector& vec) const
{ {
return G4ThreeVector( vec.x()*rxx + vec.y()*ryx + vec.z()*rzx + tx, G4double vecx = vec.x(), vecy = vec.y(), vecz = vec.z();
vec.x()*rxy + vec.y()*ryy + vec.z()*rzy + ty, return G4ThreeVector( vecx*rxx + vecy*ryx + vecz*rzx + tx,
vec.x()*rxz + vec.y()*ryz + vec.z()*rzz + tz ); vecx*rxy + vecy*ryy + vecz*rzy + ty,
vecx*rxz + vecy*ryz + vecz*rzz + tz );
} }
inline inline
G4ThreeVector G4AffineTransform::TransformAxis(const G4ThreeVector& axis) const G4ThreeVector G4AffineTransform::TransformAxis(const G4ThreeVector& axis) const
{ {
return G4ThreeVector( axis.x()*rxx + axis.y()*ryx + axis.z()*rzx, G4double axisx = axis.x(), axisy = axis.y(), axisz = axis.z();
axis.x()*rxy + axis.y()*ryy + axis.z()*rzy, return G4ThreeVector( axisx*rxx + axisy*ryx + axisz*rzx,
axis.x()*rxz + axis.y()*ryz + axis.z()*rzz ); axisx*rxy + axisy*ryy + axisz*rzy,
axisx*rxz + axisy*ryz + axisz*rzz );
} }
inline inline
void G4AffineTransform::ApplyPointTransform(G4ThreeVector& vec) const void G4AffineTransform::ApplyPointTransform(G4ThreeVector& vec) const
{ {
G4double x = vec.x()*rxx + vec.y()*ryx + vec.z()*rzx + tx; G4double vecx = vec.x(), vecy = vec.y(), vecz = vec.z();
G4double y = vec.x()*rxy + vec.y()*ryy + vec.z()*rzy + ty; G4double x = vecx*rxx + vecy*ryx + vecz*rzx + tx;
G4double z = vec.x()*rxz + vec.y()*ryz + vec.z()*rzz + tz; G4double y = vecx*rxy + vecy*ryy + vecz*rzy + ty;
G4double z = vecx*rxz + vecy*ryz + vecz*rzz + tz;
vec.setX(x); vec.setX(x);
vec.setY(y); vec.setY(y);
...@@ -231,9 +224,10 @@ void G4AffineTransform::ApplyPointTransform(G4ThreeVector& vec) const ...@@ -231,9 +224,10 @@ void G4AffineTransform::ApplyPointTransform(G4ThreeVector& vec) const
inline inline
void G4AffineTransform::ApplyAxisTransform(G4ThreeVector& axis) const void G4AffineTransform::ApplyAxisTransform(G4ThreeVector& axis) const
{ {
G4double x = axis.x()*rxx + axis.y()*ryx + axis.z()*rzx; G4double axisx = axis.x(), axisy = axis.y(), axisz = axis.z();
G4double y = axis.x()*rxy + axis.y()*ryy + axis.z()*rzy; G4double x = axisx*rxx + axisy*ryx + axisz*rzx;
G4double z = axis.x()*rxz + axis.y()*ryz + axis.z()*rzz; G4double y = axisx*rxy + axisy*ryy + axisz*rzy;
G4double z = axisx*rxz + axisy*ryz + axisz*rzz;
axis.setX(x); axis.setX(x);
axis.setY(y); axis.setY(y);
...@@ -396,7 +390,6 @@ void G4AffineTransform::SetNetRotation(const G4RotationMatrix& rot) ...@@ -396,7 +390,6 @@ void G4AffineTransform::SetNetRotation(const G4RotationMatrix& rot)
rzx=rot.zx(); rzx=rot.zx();
rzy=rot.zy(); rzy=rot.zy();
rzz=rot.zz(); rzz=rot.zz();
if (rxx==1. && ryy==1. && rzz==1.) { rxy = rxz = ryx = ryz = rzx = rzy = 0; }
} }
inline inline
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment