CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CoordinateSets.h
Go to the documentation of this file.
1 #ifndef GeometryVector_Geom_CoordinateSets_h
2 #define GeometryVector_Geom_CoordinateSets_h
3 
4 #include <cmath>
5 
6 namespace Geom {
7 
13  template <typename T>
15  public:
17  Polar2Cartesian( const T& r, const T& phi) :
18  r_(r), phi_(phi) {}
19 
20  const T& r() const {return r_;}
21  const T& phi() const {return phi_;}
22 
23  T x() const {return r_ * cos(phi_);}
24  T y() const {return r_ * sin(phi_);}
25 
26  private:
27  T r_;
29  };
30 
34  template <typename T>
36  public:
40  Cylindrical2Cartesian( const T& r, const T& phi, const T& z) :
41  r_(r), phi_(phi), z_(z) {}
42 
43  const T& r() const {return r_;}
44  const T& phi() const {return phi_;}
45  const T& z() const {return z_;}
46 
47  T x() const {return r_ * cos(phi_);}
48  T y() const {return r_ * sin(phi_);}
49 
50  private:
51  T r_;
53  T z_;
54  };
55 
59  template <typename T>
61  public:
65  Spherical2Cartesian( const T& theta, const T& phi, const T& mag) :
66  theta_(theta), phi_(phi), r_(mag),
67  transv_( sin(theta)*mag) {}
68 
69  const T& theta() const {return theta_;}
70  const T& phi() const {return phi_;}
71  const T& r() const {return r_;}
72 
73  T x() const {return transv_ * cos(phi());}
74  T y() const {return transv_ * sin(phi());}
75  T z() const {return cos(theta()) * r();}
76 
77  private:
80  T r_;
82  };
83 
84 
88  template <typename T>
90  public:
91  Cartesian2Cartesian3D( const T& x, const T& y, const T& z) :
92  x_(x), y_(y), z_(z) {}
93 
94  const T& x() const {return x_;}
95  const T& y() const {return y_;}
96  const T& z() const {return z_;}
97  private:
98  T x_;
99  T y_;
100  T z_;
101  };
102 }
103 
104 #endif
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Spherical2Cartesian(const T &theta, const T &phi, const T &mag)
Cartesian2Cartesian3D(const T &x, const T &y, const T &z)
const T & phi() const
Polar2Cartesian(const T &r, const T &phi)
Construct from radius and polar angle.
const T & r() const
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
const T & phi() const
const T & r() const
const T & theta() const
const T & phi() const
long double T
Cylindrical2Cartesian(const T &r, const T &phi, const T &z)