28 TRotMatrix::TRotMatrix()
30 for (
int i=0;i<9;i++) fMatrix[i] = 0;
41 TRotMatrix::TRotMatrix(
const char *name,
const char *title, Double_t *matrix)
50 if (!matrix) { Error(
"ctor",
"No rotation is supplied");
return; }
53 if (!gGeometry) gGeometry =
new TGeometry();
54 fNumber = gGeometry->GetListOfMatrices()->GetSize();
55 gGeometry->GetListOfMatrices()->Add(
this);
61 TRotMatrix::TRotMatrix(
const char *name,
const char *title, Double_t theta, Double_t phi, Double_t psi)
64 printf(
"ERROR: This form of TRotMatrix constructor not implemented yet\n");
71 for (i=0;i<9;i++) fMatrix[i] = 0;
72 fMatrix[0] = 1; fMatrix[4] = 1; fMatrix[8] = 1;
74 if (!gGeometry) gGeometry =
new TGeometry();
75 fNumber = gGeometry->GetListOfMatrices()->GetSize();
76 gGeometry->GetListOfMatrices()->Add(
this);
99 TRotMatrix::TRotMatrix(
const char *name,
const char *title, Double_t theta1, Double_t phi1
100 , Double_t theta2, Double_t phi2
101 , Double_t theta3, Double_t phi3)
104 SetAngles(theta1,phi1,theta2,phi2,theta3,phi3);
106 if (!gGeometry) gGeometry =
new TGeometry();
107 fNumber = gGeometry->GetListOfMatrices()->GetSize();
108 gGeometry->GetListOfMatrices()->Add(
this);
114 TRotMatrix::~TRotMatrix()
116 if (gGeometry) gGeometry->GetListOfMatrices()->Remove(
this);
122 Double_t TRotMatrix::Determinant()
const
125 fMatrix[0] * (fMatrix[4]*fMatrix[8] - fMatrix[7]*fMatrix[5])
126 - fMatrix[3] * (fMatrix[1]*fMatrix[8] - fMatrix[7]*fMatrix[2])
127 + fMatrix[6] * (fMatrix[1]*fMatrix[5] - fMatrix[4]*fMatrix[2]);
148 Double_t* TRotMatrix::GetGLMatrix(Double_t *rGLMatrix)
const
150 Double_t *glmatrix = rGLMatrix;
151 const Double_t *matrix = fMatrix;
154 for (Int_t i=0;i<3;i++) {
155 for (Int_t j=0;j<3;j++) memcpy(glmatrix,matrix,3*
sizeof(Double_t));
161 for (Int_t j=0;j<3;j++) {
187 const Double_t* TRotMatrix::SetAngles(Double_t theta1, Double_t phi1,
188 Double_t theta2, Double_t phi2,Double_t theta3, Double_t phi3)
190 const Double_t degrad = 0.0174532925199432958;
197 if (!strcmp(GetName(),
"Identity")) fType = 0;
199 fMatrix[0] = TMath::Sin(theta1*degrad)*TMath::Cos(phi1*degrad);
200 fMatrix[1] = TMath::Sin(theta1*degrad)*TMath::Sin(phi1*degrad);
201 fMatrix[2] = TMath::Cos(theta1*degrad);
202 fMatrix[3] = TMath::Sin(theta2*degrad)*TMath::Cos(phi2*degrad);
203 fMatrix[4] = TMath::Sin(theta2*degrad)*TMath::Sin(phi2*degrad);
204 fMatrix[5] = TMath::Cos(theta2*degrad);
205 fMatrix[6] = TMath::Sin(theta3*degrad)*TMath::Cos(phi3*degrad);
206 fMatrix[7] = TMath::Sin(theta3*degrad)*TMath::Sin(phi3*degrad);
207 fMatrix[8] = TMath::Cos(theta3*degrad);
216 void TRotMatrix::SetMatrix(
const Double_t *matrix)
224 memcpy(fMatrix,matrix,9*
sizeof(Double_t));
233 void TRotMatrix::SetReflection()
235 ResetBit(kReflection);
236 if (Determinant() < 0) { fType=1; SetBit(kReflection);}
242 void TRotMatrix::Streamer(TBuffer &R__b)
244 if (R__b.IsReading()) {
246 Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
248 R__b.ReadClassBuffer(TRotMatrix::Class(),
this, R__v, R__s, R__c);
252 TNamed::Streamer(R__b);
258 R__b.ReadStaticArray(fMatrix);
259 R__b.CheckByteCount(R__s, R__c, TRotMatrix::IsA());
263 R__b.WriteClassBuffer(TRotMatrix::Class(),
this);