6 #ifndef WIRECELLDATA_VECTOR 7 #define WIRECELLDATA_VECTOR 26 friend std::ostream & operator<<( std::ostream & , const D3Vector<U> & ) ;
40 D3Vector(
const T d[3] ) : m_v(3) { this->
set(d[0], d[1], d[2]); }
44 this->
set(o.
x(), o.
y(), o.
z());
49 void set(
const T&
a=0,
const T&
b=0,
const T&
c=0) {
65 T x()
const {
return m_v[0]; }
66 T y()
const {
return m_v[1]; }
67 T z()
const {
return m_v[2]; }
81 T scalar =
x() * rhs.
x() +
y() * rhs.
y() +
z() * rhs.
z() ;
87 return std::sqrt(
x()*
x()+
y()*
y()+
z()*
z());
101 T a =
y() * rhs.
z() -
z() * rhs.
y() ;
102 T b =
z() * rhs.
x() -
x() * rhs.
z() ;
103 T c =
x() * rhs.
y() -
y() * rhs.
x() ;
118 if (
z() < rhs.
z())
return true;
119 if (
y() < rhs.
y())
return true;
120 if (
x() < rhs.
x())
return true;
125 this->
set(
x()+other.
x(),
y()+other.
y(),
z()+other.
z());
130 return m_v.size() != 3;
133 return m_v.size() == 3;
144 std::ostream & operator<< ( std::ostream & os , const D3Vector<T> & vec ) {
145 os <<
"(" << vec.x() <<
" " << vec.y() <<
" " << vec.z() <<
")" ;
171 return a.
x() == b.
x() && a.
y() == b.
y() && a.
z() == b.
z();
D3Vector(const D3Vector &o)
bool operator==(const D3Vector< T > &a, const D3Vector< T > &b)
D3Vector(const T &a=0, const T &b=0, const T &c=0)
Construct from elements.
T magnitude() const
Return the magnitude of this vector.
D3Vector< T > operator*(const D3Vector< T > a, T s)
D3Vector & operator+=(const D3Vector &other)
D3Vector & operator=(const D3Vector &o)
D3Vector triplevec(D3Vector &a, D3Vector &b) const
Return the triple cross product of this vector and the other two.
T operator[](std::size_t index) const
Access elements by copy.
T & operator[](std::size_t index)
Access elements by reference.
T triplescal(D3Vector &a, D3Vector &b) const
Return the dot-cross product of this vector and the other two.
D3Vector norm() const
Return a normalized vector in the direction of this vector.
D3Vector(const D3Vector< TT > &o)
Convert from other typed vector.
bool operator<(const D3Vector &rhs) const
D3Vector< T > operator/(const D3Vector< T > a, T s)
T x() const
Access elements by name.
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
T dot(const D3Vector &rhs) const
Return the dot product of this vector and the other.
std::vector< T > D3VectorStore
D3Vector cross(const D3Vector &rhs) const
Return the cross product of this vector and the other.
bool operator!=(const D3Vector< T > &a, const D3Vector< T > &b)
D3Vector< T > operator-(const D3Vector< T > a, const D3Vector< T > b)
D3Vector< T > operator+(const D3Vector< T > a, const D3Vector< T > b)