12 #ifndef BASIC_VECTOR3D_H
13 #define BASIC_VECTOR3D_H
17 #include "CLHEP/Vector/ThreeVector.h"
28 template<
class T>
class BasicVector3D {
62 v_[0] = v.
x();
v_[1] = v.
y();
v_[2] = v.
z();
75 operator T * () {
return v_; }
79 operator const T * ()
const {
return v_; }
95 v_[0] = v.v_[0];
v_[1] = v.v_[1];
v_[2] = v.v_[2];
return *
this;
100 v_[0] += v.v_[0];
v_[1] += v.v_[1];
v_[2] += v.v_[2];
return *
this;
105 v_[0] -= v.v_[0];
v_[1] -= v.v_[1];
v_[2] -= v.v_[2];
return *
this;
110 v_[0] *=
a;
v_[1] *=
a;
v_[2] *=
a;
return *
this;
115 v_[0] /=
a;
v_[1] /=
a;
v_[2] /=
a;
return *
this;
142 T
x()
const {
return v_[0]; }
145 T
y()
const {
return v_[1]; }
148 T
z()
const {
return v_[2]; }
162 void set(T x1, T y1, T z1) {
v_[0] = x1;
v_[1] = y1;
v_[2] = z1; }
183 factor = rh/factor;
v_[0] *= factor;
v_[1] *= factor;
203 return x() == 0 &&
y() == 0 ? 0 : std::atan2(
y(),
x());
208 return x() == 0 &&
y() == 0 &&
z() == 0 ? 0 : std::atan2(
perp(),
z());
229 factor = ma/factor;
v_[0] *= factor;
v_[1] *= factor;
v_[2] *= factor;
243 set(ma*std::sin(th)*std::cos(ph), ma*std::sin(th)*std::sin(ph), ma*std::cos(th));
271 return x()*v.x()+
y()*v.y()+
z()*v.z();
279 x()*v.y()-v.x()*
y());
285 T tot = v.mag2(), s =
dot(v);
286 return tot > 0 ?
mag2()-s*s/tot :
mag2();
292 return std::sqrt(
perp2(v));
314 T dx =
x() < 0 ? -
x() :
x();
315 T dy =
y() < 0 ? -
y() :
y();
316 T dz =
z() < 0 ? -
z() :
z();
355 operator<<(std::ostream &, const BasicVector3D<float> &);
362 operator>>(std::istream &, BasicVector3D<float> &);
368 inline BasicVector3D<float>
440 return (a.
x()==b.
x() && a.
y()==b.
y() && a.
z()==b.
z());
449 return (a.
x()!=b.
x() || a.
y()!=b.
y() || a.
z()!=b.
z());
463 operator<<(std::ostream &, const BasicVector3D<double> &);
549 return (a.
x()==b.
x() && a.
y()==b.
y() && a.
z()==b.
z());
559 return (a.
x()!=b.
x() || a.
y()!=b.
y() || a.
z()!=b.
z());
563 #ifdef ENABLE_BACKWARDS_COMPATIBILITY
565 using namespace HepGeom;