00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include "MdcRecoUtil/DifRotation.h"
00024
00025 DifRotation::DifRotation()
00026 :_xnew(1.0,0.0,0.0),_ynew(0.0,1.0,0.0),_znew(0.0,0.0,1.0)
00027 {
00028 }
00029
00030 DifRotation::DifRotation
00031 (const DifNumber& alpha,const DifNumber& beta,const DifNumber& gamma)
00032 {
00033
00034
00035 DifNumber calpha=cos(alpha); DifNumber salpha=-sin(alpha);
00036 DifNumber cbeta=cos(beta); DifNumber sbeta=-sin(beta);
00037 DifNumber cgamma=cos(gamma); DifNumber sgamma=-sin(gamma);
00038
00039 _xnew.x=cbeta*calpha*cgamma-salpha*sgamma;
00040 _xnew.y=cbeta*salpha*cgamma+calpha*sgamma;
00041 _xnew.z=-sbeta*cgamma;
00042
00043 _ynew.x=-cbeta*calpha*sgamma-salpha*cgamma;
00044 _ynew.y=-cbeta*salpha*sgamma+calpha*cgamma;
00045 _ynew.z=sbeta*sgamma;
00046
00047 _znew.x=sbeta*calpha;
00048 _znew.y=sbeta*salpha;
00049 _znew.z=cbeta;
00050 }
00051
00052 DifRotation::DifRotation
00053 (const DifVector& xp,const DifVector& yp,const DifVector &zp)
00054 :_xnew(xp),_ynew(yp),_znew(zp)
00055 {}
00056
00057 DifRotation::DifRotation
00058 (const DifVector& xp,const DifVector& yp)
00059 :_xnew(xp),_ynew(yp),_znew()
00060 {
00061 _znew=cross(_xnew,_ynew);
00062 }
00063
00064 int DifRotation::fail()const {
00065 return 0;
00066 }
00067
00068 void DifRotation::rotate(DifVector &v)const {
00069 DifNumber xcomp=xnew()*v;
00070 DifNumber ycomp=ynew()*v;
00071 DifNumber zcomp=znew()*v;
00072 v.x=xcomp; v.y=ycomp; v.z=zcomp;
00073 }