61 {
62
66
67 if(_ry==0 ||_rz==0) {
68 report(
ERROR,
"") <<
"Euler angle calculation specified by zero modules of the axis!"<<endl;
69 report(
ERROR,
"EvtGen") <<
"Will terminate execution!"<<endl;
70 ::abort();
71 }
72 double tolerance=1e-10;
73 bool Y1is0=fabs(_Yaxis.
get(0))<tolerance;
74 bool Y2is0=fabs(_Yaxis.
get(1))<tolerance;
75 bool Y3is0=fabs(_Yaxis.
get(2))<tolerance;
76 bool Z1is0=fabs(_Zaxis.
get(0))<tolerance;
77 bool Z2is0=fabs(_Zaxis.
get(1))<tolerance;
78 bool Z3is0=fabs(_Zaxis.
get(2))<tolerance;
79
80 if(Y1is0 && Y3is0 && Z1is0 && Z2is0 ){
81 _alpha=0; _beta=0; _gamma=0;
82 return;
83 }
84
85 if( Z1is0 && Z2is0 && !Y2is0){
86 _alpha=0; _beta=0;
87 _gamma=acos(_Yaxis.
get(0)/_ry);
88 if(_Yaxis.
get(1)<0) _gamma=2*
pi - _gamma;
89 return;
90 }
91
92
93
94
95 if(Z1is0 && Z2is0) {
96 _beta=0;
97 }
else{ _beta =acos(_Zaxis.
get(2)/_rz);}
98
99
100
101 if(_beta==0){
102 _alpha=0.0;
103 }else {
104 double cosalpha=_Zaxis.
get(0)/_rz/
sin(_beta);
105 if(fabs(cosalpha)>1.0) cosalpha=cosalpha/fabs(cosalpha);
106 _alpha=acos(cosalpha);
107 if(_Zaxis.
get(1)<0.0) _alpha=2*
pi - _alpha;
108 }
109
110
111
112 double singamma=_Yaxis.
get(2)/_ry/
sin(_beta);
113 double cosgamma=(-_Yaxis.
get(0)/_ry-
cos(_alpha)*
cos(_beta)*singamma)/
sin(_alpha);
114 if(fabs(singamma)>1.0) singamma=singamma/fabs(singamma);
115 _gamma=asin(singamma);
116 if(singamma>0 && cosgamma<0 ) _gamma=
pi - _gamma;
117 if(singamma<0 && cosgamma<0 ) _gamma=
pi - _gamma;
118 if(singamma<0 && cosgamma>0 ) _gamma=2*
pi + _gamma;
119
120
121}
double sin(const BesAngle a)
double cos(const BesAngle a)
ostream & report(Severity severity, const char *facility)