12#ifndef BASIC_VECTOR3D_H
13#define BASIC_VECTOR3D_H
17#include "CLHEP/Geometry/defs.h"
18#include "CLHEP/Vector/ThreeVector.h"
61 template<
typename U = T,
62 typename =
typename std::enable_if<!std::is_same<U,float>::value >::type>
64 v_[0] = v.
x();
v_[1] = v.
y();
v_[2] = v.
z();
81 operator T * () {
return v_; }
85 operator const T * ()
const {
return v_; }
107 v_[0] += v.
v_[0];
v_[1] += v.
v_[1];
v_[2] += v.
v_[2];
return *
this;
112 v_[0] -= v.
v_[0];
v_[1] -= v.
v_[1];
v_[2] -= v.
v_[2];
return *
this;
117 v_[0] *= a;
v_[1] *= a;
v_[2] *= a;
return *
this;
122 v_[0] /= a;
v_[1] /= a;
v_[2] /= a;
return *
this;
149 T
x()
const {
return v_[0]; }
152 T
y()
const {
return v_[1]; }
155 T
z()
const {
return v_[2]; }
169 void set(T x1, T y1, T z1) {
v_[0] = x1;
v_[1] = y1;
v_[2] = z1; }
190 factor = rh/factor;
v_[0] *= factor;
v_[1] *= factor;
210 return x() == 0 &&
y() == 0 ? 0 : std::atan2(
y(),
x());
215 return x() == 0 &&
y() == 0 &&
z() == 0 ? 0 : std::atan2(
perp(),
z());
236 factor = ma/factor;
v_[0] *= factor;
v_[1] *= factor;
v_[2] *= factor;
250 set(ma*std::sin(th)*std::cos(ph), ma*std::sin(th)*std::sin(ph), ma*std::cos(th));
278 return x()*v.
x()+
y()*v.
y()+
z()*v.
z();
286 x()*v.
y()-v.
x()*
y());
293 return tot > 0 ?
mag2()-s*s/tot :
mag2();
299 return std::sqrt(
perp2(v));
321 T dx =
x() < 0 ? -
x() :
x();
322 T dy =
y() < 0 ? -
y() :
y();
323 T dz =
z() < 0 ? -
z() :
z();
411 return BasicVector3D<float>(v.
x()*
static_cast<float>(a), v.
y()*
static_cast<float>(a), v.
z()*
static_cast<float>(a));
429 return BasicVector3D<float>(
static_cast<float>(a)*v.
x(),
static_cast<float>(a)*v.
y(),
static_cast<float>(a)*v.
z());
438 return BasicVector3D<float>(v.
x()/
static_cast<float>(a), v.
y()/
static_cast<float>(a), v.
z()/
static_cast<float>(a));
447 return (a.
x()==b.
x() && a.
y()==b.
y() && a.
z()==b.
z());
456 return (a.
x()!=b.
x() || a.
y()!=b.
y() || a.
z()!=b.
z());
556 return (a.
x()==b.
x() && a.
y()==b.
y() && a.
z()==b.
z());
566 return (a.
x()!=b.
x() || a.
y()!=b.
y() || a.
z()!=b.
z());
570#ifdef ENABLE_BACKWARDS_COMPATIBILITY
BasicVector3D< float > operator-(const BasicVector3D< float > &a, const BasicVector3D< float > &b)
BasicVector3D< T > cross(const BasicVector3D< T > &v) const
BasicVector3D< float > operator*(const BasicVector3D< float > &v, double a)
float operator*(const BasicVector3D< float > &a, const BasicVector3D< float > &b)
BasicVector3D< T > & rotateZ(T a)
BasicVector3D< double > operator*(const BasicVector3D< double > &v, double a)
bool operator!=(const BasicVector3D< float > &a, const BasicVector3D< float > &b)
BasicVector3D< T > & operator/=(double a)
BasicVector3D< T > & rotateX(T a)
BasicVector3D< T > & rotate(T a, const BasicVector3D< T > &v)
BasicVector3D< float > operator+(const BasicVector3D< float > &a, const BasicVector3D< float > &b)
BasicVector3D< float > operator/(const BasicVector3D< float > &v, double a)
T operator[](int i) const
T angle(const BasicVector3D< T > &v) const
BasicVector3D< T > & operator*=(double a)
BasicVector3D< double > operator+(const BasicVector3D< double > &a, const BasicVector3D< double > &b)
bool operator==(const BasicVector3D< float > &a, const BasicVector3D< float > &b)
BasicVector3D< float > operator-(const BasicVector3D< float > &v)
virtual ~BasicVector3D()=default
bool operator==(const BasicVector3D< double > &a, const BasicVector3D< double > &b)
BasicVector3D< double > operator+(const BasicVector3D< double > &v)
BasicVector3D(T x1, T y1, T z1)
BasicVector3D< double > operator-(const BasicVector3D< double > &v)
BasicVector3D< T > & rotateY(T a)
BasicVector3D(BasicVector3D< T > &&)=default
BasicVector3D< double > operator/(const BasicVector3D< double > &v, double a)
BasicVector3D< double > operator-(const BasicVector3D< double > &a, const BasicVector3D< double > &b)
BasicVector3D(const BasicVector3D< T > &)=default
bool operator!=(const BasicVector3D< double > &a, const BasicVector3D< double > &b)
BasicVector3D< T > unit() const
BasicVector3D< float > operator*(double a, const BasicVector3D< float > &v)
BasicVector3D< double > operator*(double a, const BasicVector3D< double > &v)
BasicVector3D< T > & operator+=(const BasicVector3D< T > &v)
BasicVector3D(const BasicVector3D< float > &v)
BasicVector3D< T > & operator-=(const BasicVector3D< T > &v)
double operator*(const BasicVector3D< double > &a, const BasicVector3D< double > &b)
T perp2(const BasicVector3D< T > &v) const
BasicVector3D< T > & operator=(const BasicVector3D< T > &)=default
void set(T x1, T y1, T z1)
BasicVector3D< T > orthogonal() const
T perp(const BasicVector3D< T > &v) const
BasicVector3D< float > operator+(const BasicVector3D< float > &v)
T dot(const BasicVector3D< T > &v) const
T operator()(int i) const
std::istream & operator>>(std::istream &is, BasicVector3D< float > &a)
std::ostream & operator<<(std::ostream &os, const BasicVector3D< float > &a)