G4gsrotm.cc File Reference

#include "G3toG4.hh"
#include "G3RotTable.hh"
#include "G3toG4RotationMatrix.hh"
#include "G4PhysicalConstants.hh"
#include "G4ThreeVector.hh"

Go to the source code of this file.

Functions

void PG4gsrotm (G4String *tokens)
void G4gsrotm (G4int irot, G4double theta1, G4double phi1, G4double theta2, G4double phi2, G4double theta3, G4double phi3)


Function Documentation

void G4gsrotm ( G4int  irot,
G4double  theta1,
G4double  phi1,
G4double  theta2,
G4double  phi2,
G4double  theta3,
G4double  phi3 
)

Definition at line 54 of file G4gsrotm.cc.

References FatalException, G3Rot, G4cerr, G4endl, G4Exception(), G4INCL::Math::pi, G3RotTable::Put(), and G3toG4RotationMatrix::SetRotationMatrixByRow().

Referenced by G4BuildGeom(), and PG4gsrotm().

00056 {
00057     G4double degrad = pi/180;
00058     
00059     G4double th1r = theta1*degrad;
00060     G4double th2r = theta2*degrad;
00061     G4double th3r = theta3*degrad;
00062     
00063     G4double phi1r = phi1*degrad;
00064     G4double phi2r = phi2*degrad;
00065     G4double phi3r = phi3*degrad;
00066     
00067         // Construct unit vectors 
00068     
00069     G4ThreeVector x(std::sin(th1r)*std::cos(phi1r), std::sin(th1r)*std::sin(phi1r), std::cos(th1r));
00070     G4ThreeVector y(std::sin(th2r)*std::cos(phi2r), std::sin(th2r)*std::sin(phi2r), std::cos(th2r));
00071     G4ThreeVector z(std::sin(th3r)*std::cos(phi3r), std::sin(th3r)*std::sin(phi3r), std::cos(th3r));
00072 
00073         // check for orthonormality and left-handedness
00074 
00075     G4double check = (x.cross(y))*z;
00076     G4double tol = 1.0e-3;
00077         
00078     if (1-std::abs(check)>tol) {
00079         G4cerr << "Coordinate axes forming rotation matrix "
00080                << irot << " are not orthonormal.(" << 1-std::abs(check) << ")" 
00081          << G4endl;
00082         G4cerr << " theta1=" << theta1;
00083         G4cerr << " phi1=" << phi1;
00084         G4cerr << " theta2=" << theta2;
00085         G4cerr << " phi2=" << phi2;
00086         G4cerr << " theta3=" << theta3;
00087         G4cerr << " phi3=" << phi3;
00088         G4cerr << G4endl;
00089         G4Exception("G4gsrotm()", "G3toG40023", FatalException,
00090                     "Non orthogonal axes!");
00091         return;
00092     }
00093     //else if (1+check<=tol) {
00094     //    G4cerr << "G4gsrotm warning: coordinate axes forming rotation "
00095     //           << "matrix " << irot << " are left-handed" << G4endl;
00096     //}
00097     
00098     G3toG4RotationMatrix* rotp = new G3toG4RotationMatrix;
00099 
00100     rotp->SetRotationMatrixByRow(x, y, z);
00101     
00102         // add it to the List
00103 
00104     G3Rot.Put(irot, rotp);
00105 }

void PG4gsrotm ( G4String tokens  ) 

Definition at line 35 of file G4gsrotm.cc.

References G3fillParams(), G4gsrotm(), Ipar, PTgsrotm, and Rpar.

Referenced by G3CLEval().

00036 {
00037     // fill the parameter containers
00038     G3fillParams(tokens,PTgsrotm);
00039 
00040     // interpret the parameters
00041     G4int irot = Ipar[0];
00042     
00043     // the angles in Geant are in degrees
00044     G4double theta1 = Rpar[0];
00045     G4double phi1   = Rpar[1];
00046     G4double theta2 = Rpar[2];
00047     G4double phi2   = Rpar[3];
00048     G4double theta3 = Rpar[4];
00049     G4double phi3   = Rpar[5];
00050 
00051     G4gsrotm(irot, theta1,phi1, theta2,phi2, theta3,phi3);
00052 }


Generated on Mon May 27 17:50:46 2013 for Geant4 by  doxygen 1.4.7