#ifndef ROOT_Math_GenVector_Polar2D 
#define ROOT_Math_GenVector_Polar2D  1
#ifndef ROOT_Math_Math
#include "Math/Math.h"
#endif
#ifndef ROOT_Math_GenVector_etaMax
#include "Math/GenVector/etaMax.h"
#endif
 
namespace ROOT { 
   namespace Math { 
       
template <class T> 
class Polar2D { 
public : 
   typedef T Scalar;
   
   Polar2D() : fR(1.), fPhi(0) {  }
   
   Polar2D(T r,T phi) : fR(r), fPhi(phi) { Restrict(); }
    
   template <class CoordSystem > 
   explicit Polar2D( const CoordSystem & v ) : 
      fR(v.R() ),  fPhi(v.Phi() )  { Restrict(); } 
   
   
   
   Polar2D(const Polar2D & v) :
      fR(v.R() ),  fPhi(v.Phi() )  {   } 
   
   Polar2D & operator= (const Polar2D & v) { 
      fR     = v.R();  
      fPhi   = v.Phi(); 
      return *this;
   } 
    
   void SetCoordinates(Scalar r, Scalar  phi) 
   { fR=r; fPhi=phi; Restrict(); }
    
   void GetCoordinates(Scalar& r, Scalar& phi) const {r=fR; phi=fPhi;}  				
   
   Scalar R()     const { return fR;}
   Scalar Phi()   const { return fPhi; }
   Scalar X()     const { return fR*std::cos(fPhi);}
   Scalar Y()     const { return fR*std::sin(fPhi);}
   Scalar Mag2()  const { return fR*fR;}
   
  
    
   void SetR(const T & r) { 
      fR = r;      
   }
    
   void SetPhi(const T & phi) { 
      fPhi = phi;      
      Restrict();
   }
   
   void SetXY(Scalar x, Scalar y); 
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() );
   }
   
   void Rotate(T angle) { 
      fPhi += angle; 
      Restrict();
   }
   
    
   template <class CoordSystem > 
   Polar2D & operator= ( const CoordSystem & c ) { 
      fR     = c.R();  
      fPhi   = c.Phi(); 
      return *this;
   } 
     
   bool operator==(const Polar2D & rhs) const {
      return fR == rhs.fR && fPhi == rhs.fPhi;
   }
   bool operator!= (const Polar2D & rhs) const {return !(operator==(rhs));}
  
   
  
   
   
   T x() const { return X();}
   T y() const { return Y();}
  
   
   
#if defined(__MAKECINT__) || defined(G__DICTIONARY) 
   
   void SetX(Scalar x);
   void SetY(Scalar y); 
#endif
private:
   T fR;
   T fPhi;
};
   } 
} 
#ifndef ROOT_Math_Cartesian2D
#include "Math/GenVector/Cartesian2D.h"
#endif
#if defined(__MAKECINT__) || defined(G__DICTIONARY) 
#include "Math/GenVector/GenVector_exception.h"
#include "Math/GenVector/Cartesian2D.h"
#endif
namespace ROOT { 
   namespace Math { 
template <class T>  
void Polar2D<T>::SetXY(Scalar x, Scalar y) {  
   *this = Cartesian2D<Scalar>(x, y);
}
#if defined(__MAKECINT__) || defined(G__DICTIONARY) 
      template <class T>  
      void Polar2D<T>::SetX(Scalar x) {  
         GenVector_exception e("Polar2D::SetX() is not supposed to be called");
         Throw(e);
         Cartesian2D<Scalar> v(*this); v.SetX(x); *this = Polar2D<Scalar>(v);
      }
      template <class T>  
      void Polar2D<T>::SetY(Scalar y) {  
         GenVector_exception e("Polar2D::SetY() is not supposed to be called");
         Throw(e);
         Cartesian2D<Scalar> v(*this); v.SetY(y); *this = Polar2D<Scalar>(v);
      }
#endif  
   } 
} 
#endif /* ROOT_Math_GenVector_Polar2D  */
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.