19 #ifndef ROOT_Math_GenVector_Polar3D
20 #define ROOT_Math_GenVector_Polar3D 1
52 Polar3D() : fR(0), fTheta(0), fPhi(0) { }
57 Polar3D(T r,T theta,T phi) : fR(r), fTheta(theta), fPhi(phi) { Restrict(); }
63 template <
class CoordSystem >
64 explicit Polar3D(
const CoordSystem & v ) :
65 fR(v.R() ), fTheta(v.Theta() ), fPhi(v.Phi() ) { Restrict(); }
73 Polar3D(
const Polar3D & v) :
74 fR(v.R() ), fTheta(v.Theta() ), fPhi(v.Phi() ) { }
79 Polar3D & operator= (
const Polar3D & v) {
89 void SetCoordinates(
const Scalar src[] )
90 { fR=src[0]; fTheta=src[1]; fPhi=src[2]; Restrict(); }
95 void GetCoordinates( Scalar dest[] )
const
96 { dest[0] = fR; dest[1] = fTheta; dest[2] = fPhi; }
101 void SetCoordinates(Scalar r, Scalar theta, Scalar phi)
102 { fR=r; fTheta=theta; fPhi=phi; Restrict(); }
107 void GetCoordinates(Scalar& r, Scalar& theta, Scalar& phi)
const {r=fR; theta=fTheta; phi=fPhi;}
110 Scalar R()
const {
return fR;}
111 Scalar Phi()
const {
return fPhi; }
112 Scalar Theta()
const {
return fTheta; }
113 Scalar Rho()
const {
return fR * sin(fTheta); }
114 Scalar X()
const {
return Rho() * cos(fPhi); }
115 Scalar Y()
const {
return Rho() * sin(fPhi); }
116 Scalar Z()
const {
return fR * cos(fTheta); }
117 Scalar Mag2()
const {
return fR*fR;}
118 Scalar Perp2()
const {
return Rho() * Rho(); }
123 return Impl::Eta_FromTheta(fTheta, fR);
132 void SetR(
const T & r) {
139 void SetTheta(
const T & theta) {
146 void SetPhi(
const T & phi) {
154 void SetXYZ(Scalar x, Scalar y, Scalar z);
158 inline static Scalar pi() {
return M_PI; }
159 inline void Restrict() {
160 if (fPhi <= -pi() || fPhi > pi()) fPhi = fPhi - floor(fPhi / (2 * pi()) + .5) * 2 * pi();
181 fPhi = ( fPhi > 0 ? fPhi - pi() : fPhi + pi() );
182 fTheta = pi() - fTheta;
189 template <
class CoordSystem >
190 Polar3D & operator= (
const CoordSystem & c ) {
200 bool operator==(
const Polar3D & rhs)
const {
201 return fR == rhs.fR && fTheta == rhs.fTheta && fPhi == rhs.fPhi;
203 bool operator!= (
const Polar3D & rhs)
const {
return !(operator==(rhs));}
210 T x()
const {
return X(); }
211 T y()
const {
return Y(); }
212 T z()
const {
return Z(); }
218 #if defined(__MAKECINT__) || defined(G__DICTIONARY)
228 void SetRho(Scalar rho);
230 void SetEta(Scalar eta);
250 #if defined(__MAKECINT__) || defined(G__DICTIONARY)
261 void Polar3D<T>::SetXYZ(Scalar xx, Scalar yy, Scalar zz) {
262 *
this = Cartesian3D<Scalar>(xx, yy, zz);
265 #if defined(__MAKECINT__) || defined(G__DICTIONARY)
271 void Polar3D<T>::SetX(Scalar xx) {
272 GenVector_exception e(
"Polar3D::SetX() is not supposed to be called");
274 Cartesian3D<Scalar> v(*
this); v.SetX(xx); *
this = Polar3D<Scalar>(v);
277 void Polar3D<T>::SetY(Scalar yy) {
278 GenVector_exception e(
"Polar3D::SetY() is not supposed to be called");
280 Cartesian3D<Scalar> v(*
this); v.SetY(yy); *
this = Polar3D<Scalar>(v);
283 void Polar3D<T>::SetZ(Scalar zz) {
284 GenVector_exception e(
"Polar3D::SetZ() is not supposed to be called");
286 Cartesian3D<Scalar> v(*
this); v.SetZ(zz); *
this = Polar3D<Scalar>(v);
289 void Polar3D<T>::SetRho(Scalar rho) {
290 GenVector_exception e(
"Polar3D::SetRho() is not supposed to be called");
292 CylindricalEta3D<Scalar> v(*
this); v.SetRho(rho);
293 *
this = Polar3D<Scalar>(v);
296 void Polar3D<T>::SetEta(Scalar eta) {
297 GenVector_exception e(
"Polar3D::SetEta() is not supposed to be called");
299 CylindricalEta3D<Scalar> v(*
this); v.SetEta(eta);
300 *
this = Polar3D<Scalar>(v);