CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_3/src/DataFormats/GeometryVector/interface/Point2DBase.h

Go to the documentation of this file.
00001 #ifndef GeometryVector_Point2DBase_h
00002 #define GeometryVector_Point2DBase_h
00003 
00004 
00005 #include "DataFormats/GeometryVector/interface/PointTag.h"
00006 #include "DataFormats/GeometryVector/interface/PV2DBase.h"
00007 #include "DataFormats/GeometryVector/interface/Vector2DBase.h"
00008 
00009 template <class T, class FrameTag>
00010 class Point2DBase : public PV2DBase< T, PointTag, FrameTag> {
00011 public:
00012 
00013   typedef PV2DBase< T, PointTag, FrameTag>    BaseClass;
00014   typedef Vector2DBase< T, FrameTag>          VectorType;
00015   typedef Basic2DVector<T>                    BasicVectorType;
00016   typedef typename BaseClass::Polar           Polar;
00017 
00022   Point2DBase() {}
00023 
00027   template <class U> 
00028   Point2DBase( const Point2DBase<U,FrameTag>& p) : BaseClass( p.basicVector()) {}
00029 
00031   Point2DBase(const T& x, const T& y) : BaseClass(x, y) {}
00032 
00034   explicit Point2DBase( const Polar& set) : BaseClass( set) {}
00035 
00040   template <class U>
00041   explicit Point2DBase( const Basic2DVector<U>& v) : BaseClass(v) {}
00042 
00046   template <class U> 
00047   Point2DBase& operator+=( const Vector2DBase< U, FrameTag>& v) {
00048     this->basicVector() += v.basicVector();
00049     return *this;
00050   } 
00051 
00052   template <class U> 
00053   Point2DBase& operator-=( const Vector2DBase< U, FrameTag>& v) {
00054     this->basicVector() -= v.basicVector();
00055     return *this;
00056   } 
00057 
00058 };
00059 
00064 template< typename T, typename U, class Frame>
00065 inline Point2DBase< typename PreciseFloatType<T,U>::Type, Frame> 
00066 operator+( const Point2DBase<T,Frame>& p, const Vector2DBase<U,Frame>& v) {
00067   typedef Point2DBase< typename PreciseFloatType<T,U>::Type, Frame> RT;
00068   return RT( p.basicVector() + v.basicVector());
00069 }
00070 
00073 template< typename T, typename U, class Frame>
00074 inline Point2DBase< typename PreciseFloatType<T,U>::Type, Frame> 
00075 operator+( const Vector2DBase<T,Frame>& p, const Point2DBase<U,Frame>& v) {
00076   typedef Point2DBase< typename PreciseFloatType<T,U>::Type, Frame> RT;
00077   return RT( p.basicVector() + v.basicVector());
00078 }
00079 
00084 template< typename T, typename U, class Frame>
00085 inline Vector2DBase< typename PreciseFloatType<T,U>::Type, Frame>
00086 operator-( const Point2DBase<T,Frame>& p1, const Point2DBase<U,Frame>& p2) {
00087   typedef Vector2DBase< typename PreciseFloatType<T,U>::Type, Frame> RT;
00088   return RT( p1.basicVector() - p2.basicVector());
00089 }
00090 
00091 #endif // GeometryVector_Point2DBase_h