CMS 3D CMS Logo

Vector3DBase.h
Go to the documentation of this file.
1 #ifndef GeometryVector_Vector3DBase_h
2 #define GeometryVector_Vector3DBase_h
3 
6 
7 template <class T, class FrameTag>
8 class Vector3DBase : public PV3DBase<T, VectorTag, FrameTag> {
9 public:
13  typedef typename BaseClass::Spherical Spherical;
14  typedef typename BaseClass::Polar Polar;
16 
22 
26  template <class U>
28 
30  Vector3DBase(const T& x, const T& y, const T& z) : BaseClass(x, y, z) {}
31 
34  explicit Vector3DBase(const Cylindrical& set) : BaseClass(set) {}
35 
37  explicit Vector3DBase(const Polar& set) : BaseClass(set) {}
38 
42  Vector3DBase(const Geom::Theta<T>& th, const Geom::Phi<T>& ph, const T& r) : BaseClass(th, ph, r) {}
43 
48  template <class U>
49  explicit Vector3DBase(const Basic3DVector<U>& v) : BaseClass(v) {}
50 
54  Vector3DBase unit() const { return Vector3DBase(this->basicVector().unit()); }
55 
56  // equality
57  bool operator==(const Vector3DBase& rh) const { return this->basicVector() == rh.basicVector(); }
58 
62  template <class U>
64  this->theVector += v.basicVector();
65  return *this;
66  }
67 
71  template <class U>
73  this->theVector -= v.basicVector();
74  return *this;
75  }
76 
78  Vector3DBase operator-() const { return Vector3DBase(-this->basicVector()); }
79 
82  this->theVector *= t;
83  return *this;
84  }
85 
88  this->theVector /= t;
89  return *this;
90  }
91 
98  template <class U>
100  return this->theVector.dot(v.basicVector());
101  }
102 
109  template <class U>
112  return RT(this->theVector.cross(v.basicVector()));
113  }
114 };
115 
117 template <class T, class U, class FrameTag>
119  const Vector3DBase<U, FrameTag>& v2) {
121  return RT(v1.basicVector() + v2.basicVector());
122 }
123 
124 template <class T, class U, class FrameTag>
126  const Vector3DBase<U, FrameTag>& v2) {
128  return RT(v1.basicVector() - v2.basicVector());
129 }
130 
132 template <class T, class U, class FrameTag>
134  const Vector3DBase<U, FrameTag>& v2) {
135  return v1.basicVector() * v2.basicVector();
136 }
137 
141 template <class T, class FrameTag, class Scalar>
143  return Vector3DBase<T, FrameTag>(v.basicVector() * s);
144 }
145 
147 template <class T, class FrameTag, class Scalar>
149  return Vector3DBase<T, FrameTag>(v.basicVector() * s);
150 }
151 
155 template <class T, class FrameTag, class Scalar>
157  return Vector3DBase<T, FrameTag>(v.basicVector() / s);
158 }
159 
160 #endif // GeometryVector_Vector3DBase_h
Vector3DBase operator-() const
Unary minus, returns a vector with components (-x(),-y(),-z())
Definition: Vector3DBase.h:78
bool operator==(const Vector3DBase &rh) const
Definition: Vector3DBase.h:57
Vector3DBase< typename PreciseFloatType< T, U >::Type, FrameTag > cross(const Vector3DBase< U, FrameTag > &v) const
Definition: Vector3DBase.h:110
Vector3DBase< T, FrameTag > operator/(const Vector3DBase< T, FrameTag > &v, const Scalar &s)
Definition: Vector3DBase.h:156
PreciseFloatType< T, U >::Type operator*(const Vector3DBase< T, FrameTag > &v1, const Vector3DBase< U, FrameTag > &v2)
scalar product of vectors of possibly different precision
Definition: Vector3DBase.h:133
double Scalar
Definition: Definitions.h:25
PreciseFloatType< T, U >::Type dot(const Vector3DBase< U, FrameTag > &v) const
Definition: Vector3DBase.h:99
Vector3DBase(const Cylindrical &set)
Definition: Vector3DBase.h:34
Vector3DBase(const Geom::Theta< T > &th, const Geom::Phi< T > &ph, const T &r)
Definition: Vector3DBase.h:42
BaseClass::Spherical Spherical
Definition: Vector3DBase.h:13
Vector3DBase(const Basic3DVector< U > &v)
Definition: Vector3DBase.h:49
Vector3DBase(const Polar &set)
construct from polar coordinates
Definition: Vector3DBase.h:37
BaseClass::Polar Polar
Definition: Vector3DBase.h:14
Vector3DBase & operator/=(const T &t)
Scaling by a scalar value (division)
Definition: Vector3DBase.h:87
Vector3DBase< typename PreciseFloatType< T, U >::Type, FrameTag > operator+(const Vector3DBase< T, FrameTag > &v1, const Vector3DBase< U, FrameTag > &v2)
vector sum and subtraction of vectors of possibly different precision
Definition: Vector3DBase.h:118
Vector3DBase & operator+=(const Vector3DBase< U, FrameTag > &v)
Definition: Vector3DBase.h:63
Basic3DVector cross(const Basic3DVector &lh) const
Vector product, or "cross" product, with a vector of same type.
BaseClass::Cylindrical Cylindrical
Definition: Vector3DBase.h:12
Vector3DBase & operator*=(const T &t)
Scaling by a scalar value (multiplication)
Definition: Vector3DBase.h:81
const BasicVectorType & basicVector() const
Definition: PV3DBase.h:53
Vector3DBase(const T &x, const T &y, const T &z)
construct from cartesian coordinates
Definition: Vector3DBase.h:30
Vector3DBase(const Vector3DBase< U, FrameTag > &v)
Definition: Vector3DBase.h:27
PV3DBase< T, VectorTag, FrameTag > BaseClass
Definition: Vector3DBase.h:10
Vector3DBase & operator-=(const Vector3DBase< U, FrameTag > &v)
Definition: Vector3DBase.h:72
BaseClass::BasicVectorType BasicVectorType
Definition: Vector3DBase.h:15
Vector3DBase unit() const
Definition: Vector3DBase.h:54
long double T
T dot(const Basic3DVector &rh) const
Scalar product, or "dot" product, with a vector of same type.
Vector3DBase< typename PreciseFloatType< T, U >::Type, FrameTag > operator-(const Vector3DBase< T, FrameTag > &v1, const Vector3DBase< U, FrameTag > &v2)
Definition: Vector3DBase.h:125
Definition: Phi.h:52
Vector3DBase< T, FrameTag > VectorType
Definition: Vector3DBase.h:11