CMS 3D CMS Logo

Vector2DBase.h

Go to the documentation of this file.
00001 #ifndef GeometryVector_Vector2DBase_h
00002 #define GeometryVector_Vector2DBase_h
00003 
00004 
00005 #include "DataFormats/GeometryVector/interface/VectorTag.h"
00006 #include "DataFormats/GeometryVector/interface/PV2DBase.h"
00007 
00008 template <class T, class FrameTag> 
00009 class Vector2DBase : public PV2DBase<T, VectorTag, FrameTag> {
00010 public:
00011 
00012   typedef PV2DBase<T, VectorTag, FrameTag>    BaseClass;
00013   typedef Basic2DVector<T>                    BasicVectorType;
00014   typedef typename BaseClass::Polar           Polar;
00015 
00020   Vector2DBase() {}
00021 
00025   template <class U> 
00026   Vector2DBase( const Vector2DBase<U,FrameTag>& p) : BaseClass( p.basicVector()) {}
00027 
00029   Vector2DBase(const T& x, const T& y) : BaseClass(x, y) {}
00030 
00032   explicit Vector2DBase( const Polar& set) : BaseClass( set) {}
00033 
00038   template <class U>
00039   explicit Vector2DBase( const Basic2DVector<U>& v) : BaseClass(v) {}
00040 
00044   Vector2DBase unit() const { return Vector2DBase( this->basicVector().unit());}
00045 
00049   template <class U> 
00050   Vector2DBase& operator+=( const Vector2DBase< U, FrameTag>& v) {
00051     this->basicVector() += v.basicVector();
00052     return *this;
00053   } 
00054 
00058   template <class U> 
00059   Vector2DBase& operator-=( const Vector2DBase< U, FrameTag>& v) {
00060     this->basicVector() -= v.basicVector();
00061     return *this;
00062   } 
00063     
00065   Vector2DBase operator-() const { return Vector2DBase(-this->basicVector());}
00066 
00068   Vector2DBase& operator*= ( const T& t) { 
00069     this->basicVector() *= t;
00070     return *this;
00071   } 
00072 
00074   Vector2DBase& operator/= ( const T& t) { 
00075     this->basicVector() /= t;
00076     return *this;
00077   } 
00078 
00085   template <class U> 
00086   typename PreciseFloatType<T,U>::Type 
00087   dot( const Vector2DBase< U, FrameTag>& v) const { 
00088     return this->basicVector().dot( v.basicVector());
00089   }
00090 
00091 };
00092 
00094 template <class T, class U, class FrameTag>
00095 inline Vector2DBase<typename PreciseFloatType<T,U>::Type, FrameTag>
00096 operator+( const Vector2DBase<T, FrameTag>& v1, const Vector2DBase<U, FrameTag>& v2) {
00097   typedef Vector2DBase<typename PreciseFloatType<T,U>::Type, FrameTag> RT;
00098   return RT(v1.basicVector() + v2.basicVector());
00099 }
00100 
00101 template <class T, class U, class FrameTag>
00102 inline Vector2DBase<typename PreciseFloatType<T,U>::Type, FrameTag>
00103 operator-( const Vector2DBase<T, FrameTag>& v1, const Vector2DBase<U, FrameTag>& v2) {
00104   typedef Vector2DBase<typename PreciseFloatType<T,U>::Type, FrameTag> RT;
00105   return RT(v1.basicVector() - v2.basicVector());
00106 }
00107 
00109 template <class T, class U, class FrameTag>
00110 inline typename PreciseFloatType<T,U>::Type
00111 operator*( const Vector2DBase<T, FrameTag>& v1, const Vector2DBase<U, FrameTag>& v2) {
00112   return v1.basicVector() * v2.basicVector();
00113 }
00114 
00118 template <class T, class FrameTag, class Scalar>
00119 inline Vector2DBase<T, FrameTag> 
00120 operator*( const Vector2DBase<T, FrameTag>& v, const Scalar& s) {
00121   return Vector2DBase<T, FrameTag>( v.basicVector() * s);
00122 }
00123 
00125 template <class T, class FrameTag, class Scalar>
00126 inline Vector2DBase<T, FrameTag> 
00127 operator*( const Scalar& s, const Vector2DBase<T, FrameTag>& v) {
00128   return Vector2DBase<T, FrameTag>( v.basicVector() * s);
00129 }
00130 
00134 template <class T, class FrameTag, class Scalar>
00135 inline Vector2DBase<T, FrameTag> 
00136 operator/( const Vector2DBase<T, FrameTag>& v, const Scalar& s) {
00137   return Vector2DBase<T, FrameTag>( v.basicVector() / s);
00138 }
00139 
00140 #endif // GeometryVector_Vector2DBase_h

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