#ifndef ROOT_Math_GenVector_Polar3D 
#define ROOT_Math_GenVector_Polar3D  1
#ifndef ROOT_Math_Math
#include "Math/Math.h"
#endif
#ifndef ROOT_Math_GenVector_eta
#include "Math/GenVector/eta.h"
#endif
 
namespace ROOT { 
  namespace Math { 
   
template <class T> 
class Polar3D { 
public : 
   typedef T Scalar;
   
   Polar3D() : fR(0), fTheta(0), fPhi(0) {  }
   
   Polar3D(T r,T theta,T phi) : fR(r), fTheta(theta), fPhi(phi) { Restrict(); }
    
   template <class CoordSystem > 
   explicit Polar3D( const CoordSystem & v ) : 
      fR(v.R() ),  fTheta(v.Theta() ),  fPhi(v.Phi() )  { Restrict(); } 
   
   
   
   Polar3D(const Polar3D & v) :
      fR(v.R() ),  fTheta(v.Theta() ),  fPhi(v.Phi() )  {   } 
   
   Polar3D & operator= (const Polar3D & v) { 
      fR     = v.R();  
      fTheta = v.Theta(); 
      fPhi   = v.Phi(); 
      return *this;
   } 
    
   void SetCoordinates( const Scalar src[] ) 
   { fR=src[0]; fTheta=src[1]; fPhi=src[2]; Restrict(); }
    
   void GetCoordinates( Scalar dest[] ) const 
   { dest[0] = fR; dest[1] = fTheta; dest[2] = fPhi; }
    
   void SetCoordinates(Scalar r, Scalar  theta, Scalar  phi) 
   { fR=r; fTheta=theta; fPhi=phi; Restrict(); }
    
   void GetCoordinates(Scalar& r, Scalar& theta, Scalar& phi) const {r=fR; theta=fTheta; phi=fPhi;}  				
   
   Scalar R()     const { return fR;}
   Scalar Phi()   const { return fPhi; }
   Scalar Theta() const { return fTheta; } 
   Scalar Rho()   const { return fR*std::sin(fTheta); }
   Scalar X()     const { return Rho()*std::cos(fPhi);}
   Scalar Y()     const { return Rho()*std::sin(fPhi);}
   Scalar Z()     const { return fR*std::cos(fTheta); } 
   Scalar Mag2()  const { return fR*fR;}
   Scalar Perp2() const { return Rho()*Rho(); }
   
   Scalar Eta() const 
   { 
      return Impl::Eta_FromTheta(fTheta, fR);
   }
   
  
    
   void SetR(const T & r) { 
      fR = r;      
   }
    
   void SetTheta(const T & theta) { 
      fTheta = theta;      
   }
    
   void SetPhi(const T & phi) { 
      fPhi = phi;      
      Restrict();
   }
   
   void SetXYZ(Scalar x, Scalar y, Scalar z); 
private:
   inline static double pi()  { return M_PI; } 
   inline void Restrict() {
      if ( fPhi <= -pi() || fPhi > pi() ) 
         fPhi = fPhi - std::floor( fPhi/(2*pi()) +.5 ) * 2*pi();
      return;
   } 
public:   
   
   void Scale (T a) { 
      if (a < 0) {
         Negate();
         a = -a;
      }
      
      fR *= a;     
   }
    
   void Negate ( ) { 
      fPhi = ( fPhi > 0 ? fPhi - pi() : fPhi + pi() );
      fTheta = pi() - fTheta;
   }
   
    
   template <class CoordSystem > 
   Polar3D & operator= ( const CoordSystem & c ) { 
      fR     = c.R();  
      fTheta = c.Theta(); 
      fPhi   = c.Phi(); 
      return *this;
   } 
     
   bool operator==(const Polar3D & rhs) const {
      return fR == rhs.fR && fTheta == rhs.fTheta && fPhi == rhs.fPhi;
   }
   bool operator!= (const Polar3D & rhs) const {return !(operator==(rhs));}
  
   
  
   
   
   T x() const { return X();}
   T y() const { return Y();}
   T z() const { return Z(); } 
  
   
   
#if defined(__MAKECINT__) || defined(G__DICTIONARY) 
   
   void SetX(Scalar x);
   void SetY(Scalar y); 
   void SetZ(Scalar z);
   void SetRho(Scalar rho);  
   void SetEta(Scalar eta); 
#endif
private:
   T fR;
   T fTheta;
   T fPhi;
};
  } 
} 
#ifndef ROOT_Math_Cartesian3D
#include "Math/GenVector/Cartesian3D.h"
#endif
#if defined(__MAKECINT__) || defined(G__DICTIONARY) 
#include "Math/GenVector/GenVector_exception.h"
#include "Math/GenVector/CylindricalEta3D.h"
#endif
namespace ROOT { 
  namespace Math { 
template <class T>  
void Polar3D<T>::SetXYZ(Scalar x, Scalar y, Scalar z) {  
   *this = Cartesian3D<Scalar>(x, y, z);
}
#if defined(__MAKECINT__) || defined(G__DICTIONARY) 
  
template <class T>  
void Polar3D<T>::SetX(Scalar x) {  
   GenVector_exception e("Polar3D::SetX() is not supposed to be called");
   Throw(e);
   Cartesian3D<Scalar> v(*this); v.SetX(x); *this = Polar3D<Scalar>(v);
}
template <class T>  
void Polar3D<T>::SetY(Scalar y) {  
   GenVector_exception e("Polar3D::SetY() is not supposed to be called");
   Throw(e);
   Cartesian3D<Scalar> v(*this); v.SetY(y); *this = Polar3D<Scalar>(v);
}
template <class T>  
void Polar3D<T>::SetZ(Scalar z) {  
   GenVector_exception e("Polar3D::SetZ() is not supposed to be called");
   Throw(e);
   Cartesian3D<Scalar> v(*this); v.SetZ(z); *this = Polar3D<Scalar>(v);
}
template <class T>  
void Polar3D<T>::SetRho(Scalar rho) {  
   GenVector_exception e("Polar3D::SetRho() is not supposed to be called");
   Throw(e);
   CylindricalEta3D<Scalar> v(*this); v.SetRho(rho); 
   *this = Polar3D<Scalar>(v);
}
template <class T>  
void Polar3D<T>::SetEta(Scalar eta) {  
   GenVector_exception e("Polar3D::SetEta() is not supposed to be called");
   Throw(e);
   CylindricalEta3D<Scalar> v(*this); v.SetEta(eta); 
   *this = Polar3D<Scalar>(v);
}
#endif  
  } 
} 
#endif /* ROOT_Math_GenVector_Polar3D  */
This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.