Go to the documentation of this file.
21 #ifndef __MIA_3DVECTOR_HH
22 #define __MIA_3DVECTOR_HH 1
30 #include <type_traits>
84 x(T(org.
x)),
y(T(org.
y)),
z(T(org.
z))
101 return x *
x +
y *
y +
z *
z;
112 return sqrt(
norm2());
150 throw std::logic_error(
"Access to vectorelement out of range");
177 throw std::logic_error(
"Access to vectorelement out of range");
236 os <<
x <<
"," <<
y <<
"," <<
z;
254 is.clear(std::ios::badbit);
262 is.clear(std::ios::badbit);
270 is.clear(std::ios::badbit);
283 is.clear(std::ios::badbit);
291 is.clear(std::ios::badbit);
359 template <
typename T>
366 template <
typename T>
369 static const int size;
372 template <
typename T>
373 const int atomic_data<T3DVector<T>>::size = 3;
384 template <
typename T>
388 a.
y * b.
z - b.
y * a.
z,
389 a.
z * b.
x - b.
z * a.
x,
390 a.
x * b.
y - b.
x * a.
y
404 return a.
x * b.
x + a. y * b.
y + a.
z * b.
z;
453 template <
typename T,
typename S>
493 assert(b.
x != 0.0 && b.
y != 0.0 && b.
z != 0.0);
521 a.
z * b.
x - b.
z * a.
x,
522 a.
x * b.
y - b.
x * a.
y);
529 return (b.
x == a.
x && b.
y == a.
y && b.
z == a.
z);
543 return (a.
x < b.
x && a.
y < b.
y && a.
z < b.
z);
550 return (b.
x <= a.
x && b.
y <= a.
y && b.
z <= a.
z);
557 return (b.
x > a.
x && b.
y > a.
y && b.
z > a.
z);
564 return (b.
x >= a.
x && b.
y >= a.
y && b.
z >= a.
z);
566 template <
typename T >
569 template <
typename T >
572 template <
typename T>
578 (a.
y < b.
y || (a.
y == b.
y && a.
x < b.
x)));
T value_type
typedef for generic programming
const T3DVector< T > operator+(const T3DVector< T > &a, const T3DVector< T > &b)
vector addition
bool operator<=(const T3DVector< T > &b, const T3DVector< T > &a)
comparison less or equal, returns true if all components of a are less or equal then those of b
const T operator[](size_t i) const
const T3DVector< T > xzy() const
swizzle operator
std::ostream & operator<<(std::ostream &os, const T3DVector< T > &v)
stream output operator for 3DVector
void fill(T v)
Fill the vector elements with value v.
T3DVector operator-() const
bool operator==(const T3DVector< T > &a, const T3DVector< T > &b)
comparison operator equal
T3DVector< unsigned int > C3DBounds
A unsinged int 3D Vector (used for 3D field sizes)
#define NS_MIA_BEGIN
conveniance define to start the mia namespace
bool operator>(const T3DVector< T > &b, const T3DVector< T > &a)
comparison greater, returns true if all components of a are greater then those of b
T3DVector< T > & operator*=(const double a)
inplace multiplication
const T3DVector< T > & xyz() const
swizzle operator
T3DVector< double > C3DDVector
A double 3D Vector.
#define NS_MIA_END
conveniance define to end the mia namespace
T3DVector()
standart constructor
const T3DVector< T > operator-(const T3DVector< T > &a, const T3DVector< T > &b)
vector subtraction
double norm2() const
square of Euclidian norm of the vector
T3DVector< T > & operator=(const T3DVector< T > &other)=default
we provide the default copy mechanisms
T3DVector(int dim)
create a zero-vector, dim must be 3
T3DVector(const T &x_, const T &y_, const T &z_)
constructor to construct vector from values
void read(std::istream &is)
read the vector from a formatted string
T3DVector< T > & operator-=(const T3DVector< T > &a)
inplace subtraction
double fabs(const T3DVector< T > &t)
A way to get the norm of a T3DVector using faba syntax.
const T3DVector< T > zyx() const
swizzle operator
const T3DVector< T > operator^(const T3DVector< T > &a, const T3DVector< T > &b)
3D vector cross product
bool operator>=(const T3DVector< T > &b, const T3DVector< T > &a)
comparison greater or equal, returns true if all components of a are greater or equal then those of b
static const int vector_3d_bit
bool operator<(const T3DVector< T > &a, const T3DVector< T > &b)
comparison less, returns true if all components of a are less then those of b
T3DVector< float > C3DFVector
A float 3D Vector.
static T3DVector< T > _1
declare the vector (1,1,1)
T3DVector< T > & operator/=(const double a)
inplace divisison by a scalar
std::istream & operator>>(std::istream &is, T3DVector< T > &v)
stream input operator for 3DVector
const T3DVector< T > operator*(const T3DVector< T > &a, const T3DVector< T > &b)
vector scalar product
double dot(const T3DVector< T > &a, const T3DVector< T > &b)
T3DVector< T > cross(const T3DVector< T > &a, const T3DVector< T > &b)
const T3DVector< T > yzx() const
swizzle operator
void write(std::ostream &os) const
print out the formatted vector to the stream
static bool is_vector3d(int type)
const T3DVector< T > zxy() const
swizzle operator
T3DVector(const T3DVector< in > &org)
type casting copy constructor
const T3DVector< T > operator/(const T3DVector< T > &a, double f)
vector division by scalar
bool operator!=(const T3DVector< T > &a, const T3DVector< T > &b)
comparison operator not equal
static T3DVector< T > _0
declare the vector (0,0,0)
const T3DVector< T > yxz() const
swizzle operator
T3DVector< T > & operator+=(const T3DVector< T > &a)
inplace addition
static const unsigned int elements
the number of elements this vector holds (=3)