00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #include "G4tgbRotationMatrix.hh"
00037 #include "G4RotationMatrix.hh"
00038 #include "G4tgrMessenger.hh"
00039 #include "G4tgrUtils.hh"
00040 #include "G4UIcommand.hh"
00041
00042
00043 G4tgbRotationMatrix::G4tgbRotationMatrix()
00044 : theTgrRM(0)
00045 {
00046 }
00047
00048
00049
00050 G4tgbRotationMatrix::~G4tgbRotationMatrix()
00051 {
00052 }
00053
00054
00055
00056 G4tgbRotationMatrix::G4tgbRotationMatrix( G4tgrRotationMatrix* tgr )
00057 : theTgrRM(tgr)
00058 {
00059 }
00060
00061
00062
00063 G4RotationMatrix* G4tgbRotationMatrix::BuildG4RotMatrix()
00064 {
00065 std::vector<G4double> values = theTgrRM->GetValues();
00066
00067 if( values.size() == 3 ) {
00068 return BuildG4RotMatrixFrom3( values );
00069 } else if( values.size() == 6 ) {
00070 return BuildG4RotMatrixFrom6( values );
00071 } else if( values.size() == 9 ) {
00072 return BuildG4RotMatrixFrom9( values );
00073 }
00074 else
00075 {
00076 G4String ErrMessage = "Number of values is: "
00077 + G4UIcommand::ConvertToString(G4int(values.size()))
00078 + G4String(". It should be 3, 6, or 9 !");
00079 G4Exception("G4tgbRotationMatrix::BuildG4RotMatrix()",
00080 "InvalidData", FatalException, ErrMessage);
00081 }
00082 return 0;
00083 }
00084
00085
00086
00087 G4RotationMatrix*
00088 G4tgbRotationMatrix::BuildG4RotMatrixFrom3( std::vector<G4double>& values )
00089 {
00090 G4RotationMatrix* rotMat = new G4RotationMatrix();
00091
00092 rotMat->rotateX( values[0] );
00093 rotMat->rotateY( values[1] );
00094 rotMat->rotateZ( values[2] );
00095
00096 #ifdef G4VERBOSE
00097 if( G4tgrMessenger::GetVerboseLevel() >= 1 )
00098 {
00099 G4cout << " Constructing new G4RotationMatrix from 3 numbers "
00100 << GetName() << " : " << *rotMat << G4endl;
00101 }
00102 #endif
00103
00104 return rotMat;
00105 }
00106
00107
00108
00109 G4RotationMatrix*
00110 G4tgbRotationMatrix::BuildG4RotMatrixFrom6( std::vector<G4double>& values )
00111 {
00112 G4double thetaX = values[0];
00113 G4double phiX = values[1];
00114 G4double thetaY = values[2];
00115 G4double phiY = values[3];
00116 G4double thetaZ = values[4];
00117 G4double phiZ = values[5];
00118
00119
00120 G4ThreeVector colx(std::sin(thetaX)*std::cos(phiX),
00121 std::sin(thetaX)*std::sin(phiX),std::cos(thetaX));
00122 G4ThreeVector coly(std::sin(thetaY)*std::cos(phiY),
00123 std::sin(thetaY)*std::sin(phiY),std::cos(thetaY));
00124 G4ThreeVector colz(std::sin(thetaZ)*std::cos(phiZ),
00125 std::sin(thetaZ)*std::sin(phiZ),std::cos(thetaZ));
00126
00127
00128
00129
00130
00131 G4Rep3x3 rottemp(colx.x(),coly.x(),colz.x(),
00132 colx.y(),coly.y(),colz.y(),
00133 colx.z(),coly.z(),colz.z());
00134
00135 G4RotationMatrix* rotMat = new G4RotationMatrix(rottemp);
00136
00137 #ifdef G4VERBOSE
00138 if( G4tgrMessenger::GetVerboseLevel() >= 1 )
00139 {
00140 G4cout << " Constructing new G4RotationMatrix from 6 numbers "
00141 << GetName() << " : " << *rotMat << G4endl;
00142 }
00143 #endif
00144
00145 return rotMat;
00146 }
00147
00148
00149 G4RotationMatrix*
00150 G4tgbRotationMatrix::BuildG4RotMatrixFrom9( std::vector<G4double>& values )
00151 {
00152
00153 G4ThreeVector colx(values[0],values[1],values[2]);
00154 G4ThreeVector coly(values[3],values[4],values[5]);
00155 G4ThreeVector colz(values[6],values[7],values[8]);
00156
00157
00158
00159
00160
00161 G4Rep3x3 rottemp(colx.x(),coly.x(),colz.x(),
00162 colx.y(),coly.y(),colz.y(),
00163 colx.z(),coly.z(),colz.z());
00164
00165 G4RotationMatrix* rotMat = new G4RotationMatrix(rottemp);
00166
00167 #ifdef G4VERBOSE
00168 if( G4tgrMessenger::GetVerboseLevel() >= 1 )
00169 {
00170 G4cout << " Constructing new G4RotationMatrix from 9 numbers "
00171 << GetName() << " : " << *rotMat << G4endl;
00172 }
00173 #endif
00174
00175 return rotMat;
00176 }