21#ifndef MIA_2D_VECTOR_HH
22#define MIA_2D_VECTOR_HH
86 template <
typename In>
99 return T(
x *
x +
y *
y);
105 return T(sqrt(
norm2()));
151 if ( a.
x == 0.0 || a.
y == 0.0)
152 throw std::invalid_argument(
"T2DVector<T>::operator /=: division by zero not allowed");
163 throw std::invalid_argument(
"T2DVector<T>::operator /=: division by zero not allowed");
226 return (
x == a.
x &&
y == a.
y);
232 return (! (*
this == a));
256 is.clear(std::ios::badbit);
264 is.clear(std::ios::badbit);
276 is.clear(std::ios::badbit);
310 static const int size;
314const int atomic_data<T2DVector<T>>::size = 2;
375template <
typename T,
typename S>
439 return b.
x * a.
x + b.
y * a.
y;
494template <
typename T,
typename S>
497 return a.
x < b.
x && a.
y < b.
y;
500template <
typename T,
template <
typename>
class Vector>
505 return a.x * b.y - a.y * b.x;
528 return a.
y < b.
y || (a.
y == b.
y && a.
x < b.
x);
T cross(const T2DVector< T > &a, const T2DVector< T > &b)
T2DVector< T > operator*(const T2DVector< T > &a, const T2DVector< T > &b)
T2DVector< unsigned int > C2DBounds
unsigned int valued 2D vector - used as 2D size parameter
T2DVector< T > operator/(const T2DVector< T > &a, const T2DVector< T > &b)
T2DVector< float > C2DFVector
float valued 2D vector
std::istream & operator>>(std::istream &is, T2DVector< T > &a)
T2DVector< T > operator-(const T2DVector< T > &a, const T2DVector< T > &b)
T2DVector< double > C2DDVector
double valued 2D vector
bool operator<(const T2DVector< T > &a, const T2DVector< S > &b)
T2DVector< T > operator+(const T2DVector< T > &a, const T2DVector< T > &b)
std::ostream & operator<<(std::ostream &os, const T2DVector< T > &a)
T dot(const T2DVector< T > &a, const T2DVector< T > &b)
T2DVector(const T2DVector< In > &in)
T2DVector operator-() const
T value_type
typedef for generic access to the element type
static const T2DVector< T > _1
a static for the value <1,1>.
void print(std::ostream &os) const
print the vector to a stream with special formatting
void fill(T v)
fill all the elements with the given value
T2DVector & operator-=(const T2DVector &a)
in place subtraction
static const T2DVector< T > _0
a static for the value <0,0>.
void read(std::istream &is)
read the properly formatted 2D vector from a stream
T2DVector & operator*=(double a)
in place multiplication with a scalar
size_t size() const
returns the size of this vector, always 2
T2DVector & operator/=(const T2DVector &a)
in place element wise division of two 2D vectors
T2DVector & operator+=(const T2DVector &a)
in place addition
bool operator==(const T2DVector &a) const
Equal operator.
bool operator!=(const T2DVector &a) const
not equal operator
#define NS_MIA_BEGIN
conveniance define to start the mia namespace
#define NS_MIA_END
conveniance define to end the mia namespace
#define DEBUG_ASSERT_RELEASE_THROW(cond, msg...)
static bool is_vector2d(int type)
static const int vector_2d_bit
static return_type apply(const Vector< T > &a, const Vector< T > &b)