Data Structures | Typedefs | Functions
2d/vector.hh File Reference
#include <cmath>
#include <cassert>
#include <stdexcept>
#include <ostream>
#include <istream>
#include <iomanip>
#include <type_traits>
#include <mia/core/type_traits.hh>
#include <mia/core/errormacro.hh>

Go to the source code of this file.

Data Structures

struct  cross_product< T, Vector >
 
struct  less_then< T2DVector< T > >
 
class  T2DVector< T >
 a 2D vector More...
 

Typedefs

typedef T2DVector< unsigned int > C2DBounds
 unsigned int valued 2D vector - used as 2D size parameter More...
 
typedef T2DVector< double > C2DDVector
 double valued 2D vector More...
 
typedef T2DVector< float > C2DFVector
 float valued 2D vector More...
 

Functions

template<typename T >
cross (const T2DVector< T > &a, const T2DVector< T > &b)
 
template<typename T >
dot (const T2DVector< T > &a, const T2DVector< T > &b)
 
template<typename T >
T2DVector< T > operator* (const T2DVector< T > &a, const T2DVector< T > &b)
 
template<typename T >
T2DVector< T > operator* (const T2DVector< T > &a, double f)
 
template<typename T >
T2DVector< T > operator* (double f, const T2DVector< T > &a)
 
template<typename T >
T2DVector< T > operator+ (const T2DVector< T > &a, const T2DVector< T > &b)
 
template<typename T , typename S >
T2DVector< T > operator+ (const T2DVector< T > &a, const T2DVector< S > &b)
 
template<typename T >
T2DVector< T > operator- (const T2DVector< T > &a, const T2DVector< T > &b)
 
template<typename T >
T2DVector< T > operator/ (const T2DVector< T > &a, const T2DVector< T > &b)
 
template<typename T >
T2DVector< T > operator/ (const T2DVector< T > &a, double f)
 
template<typename T , typename S >
bool operator< (const T2DVector< T > &a, const T2DVector< S > &b)
 
template<typename T >
std::ostream & operator<< (std::ostream &os, const T2DVector< T > &a)
 
template<typename T >
std::istream & operator>> (std::istream &is, T2DVector< T > &a)
 

Typedef Documentation

typedef T2DVector<unsigned int> C2DBounds

unsigned int valued 2D vector - used as 2D size parameter

Definition at line 475 of file 2d/vector.hh.

typedef T2DVector<double> C2DDVector

double valued 2D vector

Definition at line 472 of file 2d/vector.hh.

typedef T2DVector<float> C2DFVector

float valued 2D vector

Definition at line 469 of file 2d/vector.hh.

Function Documentation

template<typename T >
T cross ( const T2DVector< T > &  a,
const T2DVector< T > &  b 
)

Cross product of two 2D vectors. Technically it's the 3D cross product with the z-elements set to zero and ignoring all zero elements of the output vector

Parameters
a
b
Returns
2D cross product
Todo:
Check why does it use indirection to the apply-function?

Definition at line 454 of file 2d/vector.hh.

References cross_product< T, Vector >::apply().

template<typename T >
T dot ( const T2DVector< T > &  a,
const T2DVector< T > &  b 
)

dot product for two 2D vectors that hold the same data type.

Template Parameters
typeof the vector values
Parameters
a
b
Returns
a.x*b.x + a.y*b.y

Definition at line 374 of file 2d/vector.hh.

References T2DVector< T >::x, and T2DVector< T >::y.

Referenced by colorize_mesh(), T3DMatrix< T >::get_det(), and operator*().

template<typename T >
T2DVector<T> operator* ( const T2DVector< T > &  a,
const T2DVector< T > &  b 
)

Element wise multiplication operator for two 2D vectors that hold the same data type

Template Parameters
typeof the vector values
Parameters
a
b
Returns
<a.x*b.x, a.y*b.y>

Definition at line 326 of file 2d/vector.hh.

template<typename T >
T2DVector<T> operator* ( const T2DVector< T > &  a,
double  f 
)

Multiplication of a vector with a scalar.

Template Parameters
typeof the vector values
Parameters
avector
fscalar
Returns
<a.x*f, b.y*f>

Definition at line 404 of file 2d/vector.hh.

template<typename T >
T2DVector<T> operator* ( double  f,
const T2DVector< T > &  a 
)

Multiplication of a scalar with a vector.

Template Parameters
typeof the vector values
Parameters
fscalar
avector
Returns
<a.x*f, b.y*f>

Definition at line 419 of file 2d/vector.hh.

template<typename T >
T2DVector<T> operator+ ( const T2DVector< T > &  a,
const T2DVector< T > &  b 
)

Add operator for two 2D vectors that hold the same data type

Template Parameters
typeof the vector values
Parameters
a
b
Returns
a+b

Definition at line 297 of file 2d/vector.hh.

template<typename T , typename S >
T2DVector<T> operator+ ( const T2DVector< T > &  a,
const T2DVector< S > &  b 
)

Add operator for two 2D vectors that hold different data types Target type is taken from the lhs operator

Template Parameters
typeof the vector values
Parameters
a
b
Returns
a+b

Definition at line 313 of file 2d/vector.hh.

References T2DVector< T >::x, and T2DVector< T >::y.

template<typename T >
T2DVector<T> operator- ( const T2DVector< T > &  a,
const T2DVector< T > &  b 
)

Element wise subtraction operator for two 2D vectors that hold the same data type.

Template Parameters
typeof the vector values
Parameters
a
b
Returns
a-b

Definition at line 358 of file 2d/vector.hh.

template<typename T >
T2DVector<T> operator/ ( const T2DVector< T > &  a,
const T2DVector< T > &  b 
)

Element wise division operator for two 2D vectors that hold the same data type. Throws a std::invalid_argument exception if b.x=== or b.y==0.

Template Parameters
typeof the vector values
Parameters
a
b
Returns
<a.x/b.x, a.y/b.y>

Definition at line 342 of file 2d/vector.hh.

template<typename T >
T2DVector<T> operator/ ( const T2DVector< T > &  a,
double  f 
)

Division of a vector by a scalar. Throws a std::invalid_argument exception if f==0.

Template Parameters
typeof the vector values
Parameters
a
f
Returns
<a.x/f, b.y/f>

Definition at line 389 of file 2d/vector.hh.

template<typename T , typename S >
bool operator< ( const T2DVector< T > &  a,
const T2DVector< S > &  b 
)

Comparison of a vector. Not the this less operator does not define an order, since it is possible that a =/= b and !a<b && !b<a.

Parameters
a
b
Returns
true if both elements in a are less the the corresponding elements in b.

Definition at line 432 of file 2d/vector.hh.

References T2DVector< T >::x.

template<typename T >
std::ostream& operator<< ( std::ostream &  os,
const T2DVector< T > &  a 
)

operator to write a 2D vector to a stream

Template Parameters
typeof the vector values
Parameters
osoutput stream
avector
Returns
reference to stream to allow chaining of the operator

Definition at line 269 of file 2d/vector.hh.

References T2DVector< T >::print().

template<typename T >
std::istream& operator>> ( std::istream &  is,
T2DVector< T > &  a 
)

operator to read a 2D vector from a stream

Template Parameters
typeof the vector values
Parameters
isinput stream
avector
Returns
reference to stream to allow chaining of the operator

Definition at line 283 of file 2d/vector.hh.

References T2DVector< T >::read().