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
typedef T2DVector< double > | C2DDVector
| double valued 2D vector
typedef T2DVector< float > | C2DFVector
| float valued 2D vector

## Functions

template<typename T>
T | cross (const T2DVector< T > &a, const T2DVector< T > &b)
template<typename T>
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, 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, 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)

## Variables

template<typename T>
const T2DVector< T > | T2DVector< T >::_0 = T2DVector<T>(0, 0)
template<typename T>
const T2DVector< T > | T2DVector< T >::_1 = T2DVector<T>(1, 1)

## Typedef Documentation

## C2DBounds

typedef T2DVector<unsigned int> C2DBounds

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

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

## C2DDVector

typedef T2DVector<double> C2DDVector

double valued 2D vector

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

## C2DFVector

typedef T2DVector<float> C2DFVector

float valued 2D vector

Definition at line 534 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 518 of file 2d/vector.hh.

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

## 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

  type | of the vector values

Parameters

  a |
  b |

Returns
  a.x*b.x + a.y*b.y

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

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

Referenced by colorize_mesh(), operator*(), and operator*().

## 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

  type | of the vector values

Parameters

  a |
  b |

Returns
  <a.x*b.x, a.y*b.y>

Definition at line 389 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

  type | of the vector values

Parameters

  a | vector
  f | scalar

Returns
  <a.x*f, b.y*f>

Definition at line 467 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

  type | of the vector values

Parameters

  f | scalar
  a | vector

Returns
  <a.x*f, b.y*f>

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

## operator+() [1/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

  type | of the vector values

Parameters

  a |
  b |

Returns
  a+b

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

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

## operator+() [2/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

  type | of the vector values

Parameters

  a |
  b |

Returns
  a+b

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

## 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

  type | of the vector values

Parameters

  a |
  b |

Returns
  a-b

Definition at line 421 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

  type | of the vector values

Parameters

  a |
  b |

Returns
  <a.x/b.x, a.y/b.y>

Definition at line 405 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

  type | of the vector values

Parameters

  a |
  f |

Returns
  <a.x/f, b.y/f>

Definition at line 452 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

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

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

## 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

  type | of the vector values

Parameters

  os | output stream
  a | vector

Returns
  reference to stream to allow chaining of the operator

Definition at line 332 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

  type | of the vector values

Parameters

  is | input stream
  a | vector

Returns
  reference to stream to allow chaining of the operator

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

References T2DVector< T >::read().

## Variable Documentation

## T2DVector< T >::_0

template<typename T>

const T2DVector<T> T2DVector< T >::_0 = T2DVector<T>(0, 0)

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

## T2DVector< T >::_1

template<typename T>

const T2DVector<T> T2DVector< T >::_1 = T2DVector<T>(1, 1)

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