21#ifndef __MIA_3DVECTOR_HH
22#define __MIA_3DVECTOR_HH 1
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);
369 static const int size;
373const int atomic_data<T3DVector<T>>::size = 3;
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;
453template <
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);
566template <
typename T >
569template <
typename T >
578 (a.
y < b.
y || (a.
y == b.
y && a.
x < b.
x)));
T3DVector< unsigned int > C3DBounds
A unsinged int 3D Vector (used for 3D field sizes)
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
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 > cross(const T3DVector< T > &a, const T3DVector< T > &b)
double fabs(const T3DVector< T > &t)
A way to get the norm of a T3DVector using faba syntax.
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
const T3DVector< T > operator+(const T3DVector< T > &a, const T3DVector< T > &b)
vector addition
bool operator!=(const T3DVector< T > &a, const T3DVector< T > &b)
comparison operator not equal
double dot(const T3DVector< T > &a, const T3DVector< T > &b)
T3DVector< double > C3DDVector
A double 3D Vector.
T3DVector< float > C3DFVector
A float 3D Vector.
const T3DVector< T > operator-(const T3DVector< T > &a, const T3DVector< T > &b)
vector subtraction
bool operator==(const T3DVector< T > &a, const T3DVector< T > &b)
comparison operator equal
const T3DVector< T > operator/(const T3DVector< T > &a, double f)
vector division by scalar
const T3DVector< T > operator*(const T3DVector< T > &a, const T3DVector< T > &b)
vector scalar product
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 less or equal, returns true if all components of a are less or equal then those of b
std::istream & operator>>(std::istream &is, T3DVector< T > &v)
stream input operator for 3DVector
std::ostream & operator<<(std::ostream &os, const T3DVector< T > &v)
stream output operator for 3DVector
T3DVector< T > & operator=(const T3DVector< T > &other)=default
we provide the default copy mechanisms
const T3DVector< T > & xyz() const
swizzle operator
T3DVector< T > & operator*=(const double a)
inplace multiplication
void read(std::istream &is)
read the vector from a formatted string
static T3DVector< T > _0
declare the vector (0,0,0)
T value_type
typedef for generic programming
T3DVector< T > & operator/=(const double a)
inplace divisison by a scalar
T3DVector operator-() const
void write(std::ostream &os) const
print out the formatted vector to the stream
double norm2() const
square of Euclidian norm of the vector
static T3DVector< T > _1
declare the vector (1,1,1)
T3DVector(const T3DVector< in > &org)
type casting copy constructor
const T3DVector< T > yzx() const
swizzle operator
T3DVector(const T &x_, const T &y_, const T &z_)
constructor to construct vector from values
static const unsigned int elements
the number of elements this vector holds (=3)
T3DVector()
standart constructor
T3DVector< T > & operator+=(const T3DVector< T > &a)
inplace addition
const T3DVector< T > xzy() const
swizzle operator
void fill(T v)
Fill the vector elements with value v.
T3DVector(const T3DVector< T > &other)=default
we provide the default copy mechanisms
const T3DVector< T > yxz() const
swizzle operator
const T3DVector< T > zxy() const
swizzle operator
const T operator[](size_t i) const
T3DVector< T > & operator-=(const T3DVector< T > &a)
inplace subtraction
const T3DVector< T > zyx() const
swizzle operator
T3DVector(int dim)
create a zero-vector, dim must be 3
#define NS_MIA_BEGIN
conveniance define to start the mia namespace
#define NS_MIA_END
conveniance define to end the mia namespace
static const int vector_3d_bit
static bool is_vector3d(int type)