1 #ifndef DDSurfaces_Vector3D_h
2 #define DDSurfaces_Vector3D_h 1
44 Vector3D(
double x_val,
double y_val,
double z_val ) :
72 _x = v[0] ;
_y = v[1] ;
_z = v[2] ;
79 _x = v[0] ;
_y = v[1] ;
_z = v[2] ;
84 inline const Vector3D&
fill(
double x_val,
double y_val,
double z_val) {
85 _x = x_val ;
_y = y_val ;
_z = z_val ;
91 inline double x()
const {
return _x ; }
94 inline double y()
const {
return _y ; }
97 inline double z()
const {
return _z ; }
100 inline double&
x() {
return _x ; }
103 inline double&
y() {
return _y ; }
106 inline double&
z() {
return _z ; }
112 case 0:
return _x ; break ;
113 case 1:
return _y ; break ;
114 case 2:
return _z ; break ;
121 case 0:
return _x ; break ;
122 case 1:
return _y ; break ;
123 case 2:
return _z ; break ;
125 static double dummy(0.0) ;
130 inline double phi()
const {
132 return _x == 0.0 &&
_y == 0.0 ? 0.0 : atan2(
_y,
_x);
136 inline double rho()
const {
154 inline double r()
const {
161 inline double r2()
const {
169 return _x == 0.0 &&
_y == 0.0 &&
_z == 0.0 ? 0.0 : atan2(
rho(),
_z) ;
174 return _x * v.
x() +
_y * v.
y() +
_z * v.
z() ;
183 _x * v.
y() -
_y * v.
x() ) ;
195 inline operator const double*()
const {
212 if( fabs(
x() - b.
x() ) < epsilon &&
213 fabs(
y() - b.
y() ) < epsilon &&
214 fabs(
z() - b.
z() ) < epsilon )
284 if( a.
x() == b.
x() && a.
y() == b.
y() && a.
z() == b.
z() )
293 return Vector3D( s * v.
x() , s * v.
y() , s * v.
z() ) ;
304 return v0.
dot( v1 ) ;
326 _x = rho_val * cos( phi_val ) ;
327 _y = rho_val * sin( phi_val ) ;
336 double rst = r_val * sin( theta_val ) ;
337 _x = rst * cos( phi_val ) ;
338 _y = rst * sin( phi_val ) ;
339 _z = r_val * cos( theta_val ) ;
351 <<
" ) - [ phi: " << v.
phi()
352 <<
" , rho: " << v.
rho() <<
" ] "
353 <<
" [ theta: " << v.
theta()
354 <<
" , r: " << v.
r() <<
" ] " ;
std::ostream & operator<<(std::ostream &os, const BitField64 &b)
Vector3D(double x_val, double y_val, double z_val)
const Vector3D & fill(const T &v)
fill vector from arbitrary class that defines operator[]
static Cylindrical cylindrical()
double & operator[](int i)
static Spherical spherical()
const Vector3D & fill(double x_val, double y_val, double z_val)
fill from double values
Vector3D(const double *v)
double dot(const Vector3D &v) const
Vector3D operator-(const Vector3D &a, const Vector3D &b)
Vector3D(double x_val=0., double y_val=0., double z_val=0.)
Default constructor.
double operator[](int i) const
Vector3D & operator=(const Vector3D &v)
Vector3D cross(const Vector3D &v) const
Vector3D operator+(const Vector3D &a, const Vector3D &b)
Vector3D operator*(double s, const Vector3D &v)
const double * const_array() const
direct access to data as const double*
double * array()
direct access to data as double* - allows modification
Vector3D(const Vector3D &v)
const Vector3D & fill(const double *v)
fill vector from double array
bool isEqual(const Vector3D &b, double epsilon=1e-6)
static Cartesian cartesian()
bool operator==(const Vector3D &a, const Vector3D &b)