27 Vector3D(
const float* v) : _x(v[0]),_y(v[1]),_z(v[2]) {}
30 Vector3D(
const double* v) : _x(v[0]),_y(v[1]),_z(v[2]) {}
56 inline double x()
const {
return _x ; }
59 inline double y()
const {
return _y ; }
62 inline double z() {
return _z ; }
65 inline double x() {
return _x ; }
68 inline double y() {
return _y ; }
71 inline double z()
const {
return _z ; }
77 case 0:
return _x ; break ;
78 case 1:
return _y ; break ;
79 case 2:
return _z ; break ;
86 case 0:
return _x ; break ;
87 case 1:
return _y ; break ;
88 case 2:
return _z ; break ;
90 static double dummy(0.0) ;
95 inline double phi()
const {
97 return _x == 0.0 && _y == 0.0 ? 0.0 : atan2(_y,_x);
101 inline double rho()
const {
109 return sqrt( _x*_x + _y*_y ) ;
115 return _x*_x + _y*_y ;
119 inline double r()
const {
121 return sqrt( _x*_x + _y*_y + _z*_z ) ;
126 inline double r2()
const {
128 return _x*_x + _y*_y + _z*_z ;
134 return _x == 0.0 && _y == 0.0 && _z == 0.0 ? 0.0 : atan2(
rho(),_z) ;
139 return _x * v.
x() + _y * v.
y() + _z * v.
z() ;
146 _z * v.
x() - _x * v.
z() ,
147 _x * v.
y() - _y * v.
x() ) ;
154 return Vector3D( _x / n , _y / n , _z / n ) ;
165 inline operator T() {
169 assert( t.x()== _x && t.y()== _y && t.z()== _z ) ;
183 inline T
to() {
return T( _x, _y, _z ) ; }
188 double _x=0,_y=0,_z=0 ;
200 static Cylindrical cylindrical(){
return Cylindrical() ;}
201 static Spherical spherical() {
return Spherical() ; }
218 if( a.
x() == b.
x() && a.
y() == b.
y() && a.
z() == b.
z() )
227 return Vector3D( s * v.
x() , s * v.
y() , s * v.
z() ) ;
248 _x( arho * cos( aphi ) ),
249 _y( arho * sin( aphi ) ),
259 inline Vector3D::Vector3D(
double rr,
double aphi,
double atheta, Vector3D::Spherical (&)() ) {
260 double rst = rr * sin( atheta ) ;
261 _x = rst * cos( aphi ) ;
262 _y = rst * sin( aphi ) ;
263 _z = rr * cos( atheta ) ;
269 std::ostream & operator << (std::ostream & os,
const Vector3D &v) ;
double & operator[](int i)
Accessing x,y,z with bracket operator for assignment.
Vector3D(double xx, double yy, double zz)
Default corrdinate system for initialization is cartesian.
Vector3D(const double *v)
Constructor for double array.
Vector3D unit()
Parallel unit vector.
double operator[](int i) const
Accessing x,y,z with bracket operator.
double theta() const
Polar angle - spherical.
double y()
Assign to cartesian y coordinate.
bool operator==(const Vector3D &a, const Vector3D &b)
Comparison of two vectors.
Simple three dimensional vector providing the components for cartesian, cylindrical and spherical coo...
Vector3D operator-(const Vector3D &a, const Vector3D &b)
Subtraction of two vectors.
double r2() const
Spherical r/magnitude, squared.
Vector3D operator+(const Vector3D &a, const Vector3D &b)
Addition of two vectors.
T to()
Explicit, unchecked conversion to anything that has a c'tor T(x,y,z).
Vector3D operator*(double s, const Vector3D &v)
Multiplication with scalar.
double x() const
Cartesian x coordinate.
double y() const
Cartesian y coordinate.
Vector3D(const float *v)
Constructor for float array.
double z()
Cartesian cartesian z coordinate.
Vector3D(const T &t)
Copy c'tor for three vectors from other packages - requires T::x(),T::y(), T::z().
double rho() const
Transversal component - cylindrical 'r'.
Vector3D cross(const Vector3D &v)
Vector product.
double trans2() const
Transversal component squared.
double phi() const
Azimuthal angle - cylindrical and spherical.
double dot(const Vector3D &v)
Scalar product.
double r() const
Spherical r/magnitude.
double x()
Assign to cartesian x coordinate.
Vector3D()
Default c'tor - zero vector.
double z() const
Assign to cartesian z coordinate.
double trans() const
Transversal component.