17 #ifndef ROOT_Math_GenVector_RotationY
18 #define ROOT_Math_GenVector_RotationY 1
47 typedef double Scalar;
55 RotationY() : fAngle(0), fSin(0), fCos(1) { }
60 explicit RotationY( Scalar angle ) : fAngle(angle),
61 fSin(std::sin(angle)),
73 if ( std::fabs(fAngle) >= M_PI ) {
74 double x = fAngle / (2.0 * M_PI);
75 fAngle = (2.0 * M_PI) * ( x + std::floor(.5-x) );
76 fSin = std::sin(fAngle);
77 fCos = std::cos(fAngle);
86 void SetAngle (Scalar angle) {
92 void SetComponents (Scalar angle) { SetAngle(angle); }
97 void GetAngle(Scalar &angle)
const { angle = atan2(fSin, fCos); }
98 void GetComponents ( Scalar & angle )
const { GetAngle(angle); }
103 Scalar Angle()
const {
return atan2(fSin, fCos); }
108 Scalar SinAngle ()
const {
return fSin; }
109 Scalar CosAngle ()
const {
return fCos; }
125 template <
class CoordSystem,
class U>
126 DisplacementVector3D<CoordSystem,U>
127 operator() (
const DisplacementVector3D<CoordSystem,U> & v)
const {
128 DisplacementVector3D< Cartesian3D<double>,U > xyz;
129 xyz.SetXYZ( fCos*v.x()+fSin*v.z(), v.y(), fCos*v.z()-fSin*v.x() );
130 return DisplacementVector3D<CoordSystem,U>(xyz);
136 template <
class CoordSystem,
class U>
137 PositionVector3D<CoordSystem, U>
138 operator() (
const PositionVector3D<CoordSystem,U> & v)
const {
139 DisplacementVector3D< Cartesian3D<double>,U > xyz(v);
140 DisplacementVector3D< Cartesian3D<double>,U > rxyz = operator()(xyz);
141 return PositionVector3D<CoordSystem,U> ( rxyz );
147 template <
class CoordSystem>
148 LorentzVector<CoordSystem>
149 operator() (
const LorentzVector<CoordSystem> & v)
const {
150 DisplacementVector3D< Cartesian3D<double> > xyz(v.Vect());
151 xyz = operator()(xyz);
152 LorentzVector< PxPyPzE4D<double> > xyzt (xyz.X(), xyz.Y(), xyz.Z(), v.E());
153 return LorentzVector<CoordSystem> ( xyzt );
161 template <
class ForeignVector>
163 operator() (
const ForeignVector & v)
const {
164 DisplacementVector3D< Cartesian3D<double> > xyz(v);
165 DisplacementVector3D< Cartesian3D<double> > rxyz = operator()(xyz);
166 return ForeignVector ( rxyz.X(), rxyz.Y(), rxyz.Z() );
172 template <
class AVector>
174 AVector operator* (
const AVector & v)
const
176 return operator()(v);
182 void Invert() { fAngle = -fAngle; fSin = -fSin; }
187 RotationY Inverse()
const { RotationY t(*
this); t.Invert();
return t; }
194 RotationY operator * (
const RotationY & r)
const {
196 double x = (fAngle + r.fAngle) / (2.0 * M_PI);
197 ans.fAngle = (2.0 * M_PI) * ( x + std::floor(.5-x) );
198 ans.fSin = fSin*r.fCos + fCos*r.fSin;
199 ans.fCos = fCos*r.fCos - fSin*r.fSin;
206 RotationY & operator *= (
const RotationY & r) {
return *
this = (*this)*r; }
211 bool operator == (
const RotationY & rhs)
const {
212 if( fAngle != rhs.fAngle )
return false;
215 bool operator != (
const RotationY & rhs)
const {
216 return ! operator==(rhs);
234 typename RotationY::Scalar
235 Distance (
const RotationY& r1,
const R & r2) {
return gv_detail::dist(r1,r2);}
243 std::ostream & operator<< (std::ostream & os,
const RotationY & r) {
244 os <<
" RotationY(" << r.Angle() <<
") ";
252 #endif // ROOT_Math_GenVector_RotationY