CMS 3D CMS Logo

CoordinateSets.h

Go to the documentation of this file.
00001 #ifndef GeometryVector_Geom_CoordinateSets_h
00002 #define GeometryVector_Geom_CoordinateSets_h
00003 
00004 #include <cmath>
00005 
00006 namespace Geom {
00007 
00013     template <typename T>
00014     class Polar2Cartesian {
00015     public:
00017         Polar2Cartesian( const T& r, const T& phi) :
00018             r_(r), phi_(phi) {}
00019 
00020         const T& r() const   {return r_;}
00021         const T& phi() const {return phi_;}
00022 
00023         T x() const {return r_ * cos(phi_);}
00024         T y() const {return r_ * sin(phi_);}
00025 
00026     private:
00027         T r_;
00028         T phi_;
00029     };
00030 
00034     template <typename T>
00035     class Cylindrical2Cartesian {
00036     public:
00040         Cylindrical2Cartesian( const T& r, const T& phi, const T& z) :
00041             r_(r), phi_(phi), z_(z) {}
00042 
00043         const T& r() const   {return r_;}
00044         const T& phi() const {return phi_;}
00045         const T& z() const   {return z_;}
00046 
00047         T x() const {return r_ * cos(phi_);}
00048         T y() const {return r_ * sin(phi_);}
00049 
00050     private:
00051         T r_;
00052         T phi_;
00053         T z_;
00054     };
00055 
00059     template <typename T>
00060     class Spherical2Cartesian {
00061     public:
00065         Spherical2Cartesian( const T& theta, const T& phi, const T& mag) :
00066             theta_(theta), phi_(phi), r_(mag), 
00067             transv_( sin(theta)*mag) {}
00068 
00069         const T& theta() const   {return theta_;}
00070         const T& phi() const     {return phi_;}
00071         const T& r() const       {return r_;}
00072 
00073         T x() const {return transv_ * cos(phi());}
00074         T y() const {return transv_ * sin(phi());}
00075         T z() const {return cos(theta()) * r();}
00076 
00077     private:
00078         T theta_;
00079         T phi_;
00080         T r_;
00081         T transv_;
00082     };
00083 
00084 
00088     template <typename T>
00089     class Cartesian2Cartesian3D {
00090     public:
00091         Cartesian2Cartesian3D( const T& x, const T& y, const T& z) :
00092             x_(x), y_(y), z_(z) {}
00093 
00094         const T& x() const   {return x_;}
00095         const T& y() const   {return y_;}
00096         const T& z() const   {return z_;}
00097    private:
00098         T x_;
00099         T y_;
00100         T z_;
00101     };
00102 }
00103 
00104 #endif

Generated on Tue Jun 9 17:30:52 2009 for CMSSW by  doxygen 1.5.4