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>
#include <mia/core/attributetype.hh>
Include dependency graph for 2d/vector.hh:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  attribute_type< T2DVector< T > >
 
struct  cross_product< T, Vector >
 
struct  EAttributeType_2d
 
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

◆ C2DBounds

typedef T2DVector<unsigned int> C2DBounds

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

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

◆ C2DDVector

typedef T2DVector<double> C2DDVector

double valued 2D vector

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

◆ C2DFVector

typedef T2DVector<float> C2DFVector

float valued 2D vector

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

Function Documentation

◆ cross()

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 475 of file 2d/vector.hh.

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

Referenced by TPolyTriangulator< VertexVector, Polygon >::triangulate().

◆ dot()

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 395 of file 2d/vector.hh.

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

◆ operator*() [1/3]

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 347 of file 2d/vector.hh.

◆ operator*() [2/3]

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 425 of file 2d/vector.hh.

◆ operator*() [3/3]

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 440 of file 2d/vector.hh.

◆ operator+() [1/2]

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 318 of file 2d/vector.hh.

◆ operator+() [2/2]

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 334 of file 2d/vector.hh.

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

◆ operator-()

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 379 of file 2d/vector.hh.

◆ operator/() [1/2]

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 363 of file 2d/vector.hh.

◆ operator/() [2/2]

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 410 of file 2d/vector.hh.

◆ operator<()

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 453 of file 2d/vector.hh.

References T2DVector< T >::x.

◆ operator<<()

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 290 of file 2d/vector.hh.

References T2DVector< T >::print().

◆ operator>>()

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 304 of file 2d/vector.hh.

References T2DVector< T >::read().