Public Types | Public Member Functions | Static Public Member Functions | Related Functions

TRTK::Coordinate< T > Class Template Reference

A generic coordinate class. More...

#include <Coordinate.hpp>

List of all members.

Public Types

enum  Error { DIVISION_BY_ZERO, UNKNOWN_ERROR }
typedef T value_type
typedef Eigen::Array< T,
Eigen::Dynamic, 1 > 
data_type
 See also http://eigen.tuxfamily.org.
typedef Eigen::Matrix< T,
Eigen::Dynamic, 1 > 
matrix_type
 See also http://eigen.tuxfamily.org.

Public Member Functions

 Coordinate ()
 Constructs a zero-dimensional coordinate.
 Coordinate (T)
 Constructs a one-dimensional coordinate.
 Coordinate (T, T)
 Constructs a two-dimensional coordinate.
 Coordinate (T, T, T)
 Constructs a three-dimensional coordinate.
 Coordinate (T, T, T, T)
 Constructs a four-dimensional coordinate.
 Coordinate (const Coordinate &)
template<class U >
 Coordinate (const Coordinate< U > &coordinate)
 Coordinate (const CVector &)
template<typename Derived >
 Coordinate (const Eigen::DenseBase< Derived > &vector)
 Constructs a coordinate from an Eigen Array or Eigen Matrix.
virtual ~Coordinate ()
T & x ()
 Returns the first component.
T & y ()
 Returns the second component.
T & z ()
 Returns the third component.
T & w ()
 Returns the fourth component.
const T & x () const
 Returns the first component.
const T & y () const
 Returns the second component.
const T & z () const
 Returns the third component.
const T & w () const
 Returns the fourth component.
T & operator[] (int)
const T & operator[] (int) const
bool operator== (const Coordinate &) const
Coordinateoperator+= (T)
Coordinateoperator-= (T)
Coordinateoperator*= (T)
Coordinateoperator/= (T)
Coordinateoperator+= (const Coordinate &)
 Component-wise addition.
Coordinateoperator-= (const Coordinate &)
 Component-wise subtraction.
Coordinateoperator*= (const Coordinate &)
 Component-wise multiplication.
Coordinateoperator/= (const Coordinate &)
 Component-wise division.
Coordinate operator+ (T) const
Coordinate operator- (T) const
Coordinate operator* (T) const
Coordinate operator/ (T) const
Coordinate operator+ (const Coordinate &) const
 Component-wise addition.
Coordinate operator- (const Coordinate &) const
 Component-wise subtraction.
Coordinate operator* (const Coordinate &) const
 Component-wise multiplication.
Coordinate operator/ (const Coordinate &) const
 Component-wise division.
Coordinate operator, (T) const
 Returns a copy of the coordinate, enlarged by one component.
 operator data_type ()
 Conversion operator; yields an Eigen 3 array.
 operator data_type () const
 Conversion operator; yields an Eigen 3 array.
 operator CVector () const
 Conversion operator; yields an CVector.
Coordinate cross (const Coordinate &) const
 Computes a cross product.
double dot (const Coordinate &) const
 Computes a dot product.
Coordinatefill (T)
double norm () const
 Returns the Euclidean norm.
Coordinatenormalize ()
 Normalizes *this.
Coordinate normalized () const
 Returns a normalized copy of *this.
Coordinate orthogonal () const
 Returns a vector that is orthogonal to *this.
Coordinate orthonormal () const
 Returns a normalized vector that is orthogonal to *this.
Coordinatereserve (unsigned int size)
 Reserves memory to store size elements.
Coordinateresize (unsigned int size, T value=T())
unsigned int size () const
double squaredNorm () const
 Returns the squared Euclidean norm.
data_typetoArray ()
 Returns an Eigen 3 array.
const data_typetoArray () const
 Returns an Eigen 3 array.
matrix_type toMatrix () const
 Returns an Eigen 3 matrix.
std::string toString () const
 Returns the string representation of the coordinate.

Static Public Member Functions

static Coordinate rand (unsigned int size, T a=T(0), T b=T(1))
 Returns a vector filled with uniformly distributed random samples.
static Coordinate randn (unsigned int size, T mu=T(0), T sigma=T(1))
 Returns a vector filled with normally distributed random samples.

Related Functions

(Note that these are not member functions.)


Coordinate< double > operator+ (int value, const Coordinate< double > &coordinate)
Coordinate< double > operator- (int value, const Coordinate< double > &coordinate)
Coordinate< double > operator* (int value, const Coordinate< double > &coordinate)
Coordinate< double > operator/ (int value, const Coordinate< double > &coordinate)
Coordinate< int > operator+ (double value, const Coordinate< int > &coordinate)
Coordinate< int > operator- (double value, const Coordinate< int > &coordinate)
Coordinate< int > operator* (double value, const Coordinate< int > &coordinate)
Coordinate< int > operator/ (double value, const Coordinate< int > &coordinate)
template<class T >
Coordinate< T > operator+ (T value, const Coordinate< T > &coordinate)
template<class T >
Coordinate< T > operator- (T value, const Coordinate< T > &coordinate)
template<class T >
Coordinate< T > operator* (T value, const Coordinate< T > &coordinate)
template<class T >
Coordinate< T > operator/ (T value, const Coordinate< T > &coordinate)
template<class T >
std::istream & operator>> (std::istream &input, Coordinate< T > &coordinate)
template<class T >
std::ostream & operator<< (std::ostream &output, const Coordinate< T > &coordinate)

Detailed Description

template<class T>
class TRTK::Coordinate< T >

A generic coordinate class.

Template Parameters:
Tscalar type

Coordinate represents an ordinary coordinate vector of arbitrary size. Its elements (i.e. the scalars) are of type T and can be freely chosen, thus also allowing the use of classes with arbitrary precision (like CLN or GMP), for instance. Conversions between distinctive specializations like Coordinate<int> and Coordinate<double> are done fully automatically. The size of a coordinate can be changed at any time; Coordinate is a column vector.

Most functions check for certain assertions (e.g. if an index is in a valid range) and trigger an assertion failure if the assumption does not hold. This is meant for debugging purposes only and can be disabled by defining the macro NDEBUG.

Since Coordinate builds on top of Eigen, it can be seamlessly converted to Eigen::Array using the toArray() method.

Here are some examples:

 using namespace TRTK;

 Coordinate<double> c1(1, 0);
 Coordinate<double> c2(0, 1);

 Coordinate<double> c3 = c1 + c2 * 2 + 2;

 cout << c3        << endl
      << c3.norm() << endl
      << (c3, 1)   << endl;

Output:

 (3, 4)
 5
 (3, 4, 1)
Warning:
Be careful when performing computations with two coordinates having different scalar types! The type of the result is the same as the one of the first operand:
 // use typedefs due to the limited space in this box...

 typedef Coordinate<double> CoordinateD;
 typedef Coordinate<int> CoordinateI;

 CoordinateD(1, 1) * CoordinateI(1, 1);       // result is of type CoordinateD
 CoordinateI(1, 1) * CoordinateD(1, 1));      // result is of type CoordinateI
In all other cases automatic type conversion works as expected:
 CoordinateI(1, 1) * 1;                       // result is of type CoordinateI
 CoordinateI(1, 1) * 1.0;                     // result is of type CoordinateI

 CoordinateD(1, 1) * 1;                       // result is of type CoordinateD
 CoordinateD(1, 1) * 1.0;                     // result is of type CoordinateD

   1 * CoordinateI(1, 1);                     // result is of type CoordinateI
 1.0 * CoordinateI(1, 1);                     // result is of type CoordinateI

   1 * CoordinateD(1, 1);                     // result is of type CoordinateD
 1.0 * CoordinateD(1, 1);                     // result is of type CoordinateD

 CoordinateD(1, 1) * CoordinateD(1, 1);       // result is of type CoordinateD
Macros:
If TRTK_SUPPORT_CVECTOR is defined, Coordinate will support the mediTEC CVector class. That is, an constructor as well as a conversion operator is defined.
See also:
Transform2D and Transform3D
Author:
Christoph Haenisch
Version:
0.8.1
Date:
last changed on 2016-04-15

Definition at line 148 of file Coordinate.hpp.


Member Enumeration Documentation

template<class T>
enum TRTK::Coordinate::Error

Error codes that might be set when ErrorObj is thrown.

Enumerator:
DIVISION_BY_ZERO 

a division by zero occurred

UNKNOWN_ERROR 

an unknown error occurred

Definition at line 241 of file Coordinate.hpp.


Constructor & Destructor Documentation

template<class T>
TRTK::Coordinate< T >::Coordinate ( x )

Constructs a one-dimensional coordinate.

Template Parameters:
Tscalar type
Parameters:
[in]xfirst element

Definition at line 328 of file Coordinate.hpp.

template<class T>
TRTK::Coordinate< T >::Coordinate ( x,
y 
)

Constructs a two-dimensional coordinate.

Template Parameters:
Tscalar type
Parameters:
[in]xfirst element
[in]ysecond element

Definition at line 341 of file Coordinate.hpp.

template<class T>
TRTK::Coordinate< T >::Coordinate ( x,
y,
z 
)

Constructs a three-dimensional coordinate.

Template Parameters:
Tscalar type
Parameters:
[in]xfirst element
[in]ysecond element
[in]zthird element

Definition at line 356 of file Coordinate.hpp.

template<class T>
TRTK::Coordinate< T >::Coordinate ( x,
y,
z,
w 
)

Constructs a four-dimensional coordinate.

Template Parameters:
Tscalar type
Parameters:
[in]xfirst element
[in]ysecond element
[in]zthird element
[in]wfourth element

Definition at line 373 of file Coordinate.hpp.

template<class T>
TRTK::Coordinate< T >::Coordinate ( const Coordinate< T > &  coordinate )

Copy constructor.

Template Parameters:
Tscalar type
Parameters:
[in]coordinatecoordinate of the same type

Definition at line 390 of file Coordinate.hpp.

template<class T >
template<class U >
TRTK::Coordinate< T >::Coordinate ( const Coordinate< U > &  coordinate )

Copy constructor.

Template Parameters:
Tscalar type of the newly created coordinate
Uscalar type of the copied coordinate
Parameters:
[in]coordinateCoordinate with scalar type U

Definition at line 406 of file Coordinate.hpp.

template<class T>
TRTK::Coordinate< T >::Coordinate ( const CVector &  cVector )

Constructs a Coordinate.

Template Parameters:
Tscalar type
Parameters:
[in]cVectorinstance of the CVector class

This constructor converts a CVector into a Coordinate.

Note:
TRTK_SUPPORT_CVECTOR must be defined to enable this function.

Definition at line 434 of file Coordinate.hpp.

template<class T >
template<typename Derived >
TRTK::Coordinate< T >::Coordinate ( const Eigen::DenseBase< Derived > &  vector ) [explicit]

Constructs a coordinate from an Eigen Array or Eigen Matrix.

Template Parameters:
Tscalar type of the newly created coordinate
Derivedactual type of vector
Parameters:
[in]vectorEigen Array or Eigen Matrix

The type of vector must be T, otherwise an assertion is thrown.

Example:

 Eigen::Array3d array(1, 2, 3);
 TRTK::Coordinate<double> coordinate(array);
Note:
The constructor is defined explicit to avoid automatic conversion clashes with the Eigen libraray.
See also:
Eigen (http://eigen.tuxfamily.org)

Definition at line 471 of file Coordinate.hpp.

template<class T >
TRTK::Coordinate< T >::~Coordinate (  ) [virtual]

Destructs the coordinate.

Template Parameters:
Tscalar type

Definition at line 484 of file Coordinate.hpp.


Member Function Documentation

template<class T >
Coordinate< T > TRTK::Coordinate< T >::cross ( const Coordinate< T > &  other ) const

Computes a cross product.

Template Parameters:
Tscalar type
Parameters:
[in]othercoordinate
Returns:
Returns the cross product of *this and other.

Definition at line 1128 of file Coordinate.hpp.

template<class T >
double TRTK::Coordinate< T >::dot ( const Coordinate< T > &  other ) const

Computes a dot product.

Template Parameters:
Tscalar type
Parameters:
[in]othercoordinate
Returns:
Returns the dot product of *this and other.

Definition at line 1154 of file Coordinate.hpp.

template<class T>
Coordinate< T > & TRTK::Coordinate< T >::fill ( value ) [inline]
Template Parameters:
Tscalar type
Parameters:
[in]value

Sets each component of *this to value.

Returns:
Returns *this.

Definition at line 1172 of file Coordinate.hpp.

template<class T >
double TRTK::Coordinate< T >::norm (  ) const [inline]

Returns the Euclidean norm.

Template Parameters:
Tscalar type

Definition at line 1182 of file Coordinate.hpp.

template<class T >
Coordinate< T > & TRTK::Coordinate< T >::normalize (  )

Normalizes *this.

Template Parameters:
Tscalar type

If this function is called, *this is divided by its Euclidean norm.

Returns:
Returns *this.

Definition at line 1196 of file Coordinate.hpp.

template<class T >
Coordinate< T > TRTK::Coordinate< T >::normalized (  ) const

Returns a normalized copy of *this.

Template Parameters:
Tscalar type

Definition at line 1206 of file Coordinate.hpp.

template<class T >
TRTK::Coordinate< T >::operator CVector (  ) const

Conversion operator; yields an CVector.

Template Parameters:
Tscalar type
Returns:
*this (converted)

This operator performs an automatic type conversion from Coordinate to CVector.

Note:
TRTK_SUPPORT_CVECTOR must be defined to enable this function.

Definition at line 1103 of file Coordinate.hpp.

template<class T >
TRTK::Coordinate< T >::operator data_type (  )

Conversion operator; yields an Eigen 3 array.

Template Parameters:
Tscalar type
Returns:
*this (converted)

This operator performs an automatic conversion of *this to Coordinate::data_type, i.e. an Eigen::Array

See also:
http://eigen.tuxfamily.org

Definition at line 1065 of file Coordinate.hpp.

template<class T >
TRTK::Coordinate< T >::operator data_type (  ) const

Conversion operator; yields an Eigen 3 array.

Template Parameters:
Tscalar type
Returns:
*this (converted)

This operator performs an automatic conversion of *this to Coordinate::const_data_type, i.e. an Eigen::Array

See also:
http://eigen.tuxfamily.org

Definition at line 1083 of file Coordinate.hpp.

template<class T>
Coordinate< T > TRTK::Coordinate< T >::operator* ( value ) const
Template Parameters:
Tscalar type
Parameters:
[in]valuescalar to be multiplied with
Returns:
Coordinate

Multiplies value with each component of *this.

Definition at line 869 of file Coordinate.hpp.

template<class T>
Coordinate< T > TRTK::Coordinate< T >::operator* ( const Coordinate< T > &  coordinate ) const

Component-wise multiplication.

Template Parameters:
Tscalar type
Parameters:
[in]coordinate
Returns:
Coordinate

Definition at line 958 of file Coordinate.hpp.

template<class T>
Coordinate< T > & TRTK::Coordinate< T >::operator*= ( value ) [inline]
Template Parameters:
Tscalar type
Parameters:
[in]valuescalar to be multiplied with
Returns:
*this

Multiplies each component of *this with value.

Definition at line 690 of file Coordinate.hpp.

template<class T>
Coordinate< T > & TRTK::Coordinate< T >::operator*= ( const Coordinate< T > &  coordinate ) [inline]

Component-wise multiplication.

Template Parameters:
Tscalar type
Parameters:
[in]coordinateother
Returns:
*this

Component-wise multiplication of other and *this.

Definition at line 777 of file Coordinate.hpp.

template<class T>
Coordinate< T > TRTK::Coordinate< T >::operator+ ( value ) const
Template Parameters:
Tscalar type
Parameters:
[in]valuescalar to be added
Returns:
Coordinate

Adds value to each component of *this.

Definition at line 831 of file Coordinate.hpp.

template<class T>
Coordinate< T > TRTK::Coordinate< T >::operator+ ( const Coordinate< T > &  coordinate ) const

Component-wise addition.

Template Parameters:
Tscalar type
Parameters:
[in]coordinate
Returns:
Coordinate

Definition at line 920 of file Coordinate.hpp.

template<class T>
Coordinate< T > & TRTK::Coordinate< T >::operator+= ( const Coordinate< T > &  coordinate ) [inline]

Component-wise addition.

Template Parameters:
Tscalar type
Parameters:
[in]coordinateother
Returns:
*this

Component-wise addition of other and *this.

Definition at line 739 of file Coordinate.hpp.

template<class T>
Coordinate< T > & TRTK::Coordinate< T >::operator+= ( value ) [inline]
Template Parameters:
Tscalar type
Parameters:
[in]valuescalar to be added
Returns:
*this

Adds value to each component of *this.

Definition at line 656 of file Coordinate.hpp.

template<class T>
Coordinate< T > TRTK::Coordinate< T >::operator, ( value ) const

Returns a copy of the coordinate, enlarged by one component.

Template Parameters:
Tscalar type
Parameters:
[in]valuecomponent added to the coordinate
Returns:
enlarged copy of the coordinate

With the comma operator it is possible to enlarge a coordinate by one or more scalars. This can be usefull, if you need to convert an ordinary coordinate into a homogeneous coordinate, as shown in the example below.

Example:

 Coordinate<double> a(1, 2, 3);

 cout << a << endl
      << (a, 1) << endl
      << (a, 4, 4) << endl;

Output:

 (1, 2, 3)
 (1, 2, 3, 1)
 (1, 2, 3, 4, 4)
Note:
You need to embrace the expression, otherwise the comma is not recognized as an operator!

Definition at line 1040 of file Coordinate.hpp.

template<class T>
Coordinate< T > TRTK::Coordinate< T >::operator- ( value ) const
Template Parameters:
Tscalar type
Parameters:
[in]valuescalar to be subtracted
Returns:
Coordinate

Subtracts value from each component of *this.

Definition at line 850 of file Coordinate.hpp.

template<class T>
Coordinate< T > TRTK::Coordinate< T >::operator- ( const Coordinate< T > &  coordinate ) const

Component-wise subtraction.

Template Parameters:
Tscalar type
Parameters:
[in]coordinate
Returns:
Coordinate

Definition at line 939 of file Coordinate.hpp.

template<class T>
Coordinate< T > & TRTK::Coordinate< T >::operator-= ( const Coordinate< T > &  coordinate ) [inline]

Component-wise subtraction.

Template Parameters:
Tscalar type
Parameters:
[in]coordinateother
Returns:
*this

Component-wise subtraction of other and *this.

Definition at line 758 of file Coordinate.hpp.

template<class T>
Coordinate< T > & TRTK::Coordinate< T >::operator-= ( value ) [inline]
Template Parameters:
Tscalar type
Parameters:
[in]valuescalar to be subtracted
Returns:
*this

Subtracts value from each component of *this.

Definition at line 673 of file Coordinate.hpp.

template<class T>
Coordinate< T > TRTK::Coordinate< T >::operator/ ( value ) const
Template Parameters:
Tscalar type
Parameters:
[in]valuedivisor
Returns:
Coordinate
Exceptions:
ErrorObjIf value is zero, an error object is thrown and its error code set to DIVISION_BY_ZERO.

Divides each component of *this by value.

See also:
Enumerator Coordinate::Error

Definition at line 893 of file Coordinate.hpp.

template<class T>
Coordinate< T > TRTK::Coordinate< T >::operator/ ( const Coordinate< T > &  coordinate ) const

Component-wise division.

Template Parameters:
Tscalar type
Parameters:
[in]coordinate
Returns:
Coordinate
Exceptions:
ErrorObjIf one or more components of coordinate are zero, an error object is thrown and its error code set to DIVISION_BY_ZERO.
See also:
Enumerator Coordinate::Error

Definition at line 982 of file Coordinate.hpp.

template<class T>
Coordinate< T > & TRTK::Coordinate< T >::operator/= ( const Coordinate< T > &  coordinate )

Component-wise division.

Template Parameters:
Tscalar type
Parameters:
[in]coordinatecoordinate containing the divisors
Returns:
*this
Exceptions:
ErrorObjIf one or more components of coordinate are zero, an error object is thrown and its error code set to DIVISION_BY_ZERO.

Component-wise division of *this by other.

See also:
Enumerator Coordinate::Error

Definition at line 801 of file Coordinate.hpp.

template<class T>
Coordinate< T > & TRTK::Coordinate< T >::operator/= ( value )
Template Parameters:
Tscalar type
Parameters:
[in]valuedivisor
Returns:
*this
Exceptions:
ErrorObjIf value is zero, an error object is thrown and its error code set to DIVISION_BY_ZERO.

Divides each component of *this by value.

See also:
Enumerator Coordinate::Error

Definition at line 712 of file Coordinate.hpp.

template<class T >
bool TRTK::Coordinate< T >::operator== ( const Coordinate< T > &  coordinate ) const [inline]
Template Parameters:
Tscalar type
Parameters:
[in]coordinatecoordinate to be compared with *this
Returns:
true if all elements of *this and coordinate are equal to each other

Definition at line 638 of file Coordinate.hpp.

template<class T >
T & TRTK::Coordinate< T >::operator[] ( int  index ) [inline]
Template Parameters:
Tscalar type
Parameters:
[in]indexposition of the element to be returned
Returns:
scalar

Returns the element at index position index. The first element has index 0.

Example:

 Coordinate<double> c(1, 2, 3);
 double a = c[1]; // a == 2

Definition at line 595 of file Coordinate.hpp.

template<class T >
const T & TRTK::Coordinate< T >::operator[] ( int  index ) const [inline]
Template Parameters:
Tscalar type
Parameters:
[in]indexposition of the element to be returned
Returns:
scalar

Returns the element at index position index. The first element has index 0.

Example:

 Coordinate<double> c(1, 2, 3);
 double a = c[1]; // a == 2

Definition at line 621 of file Coordinate.hpp.

template<class T >
Coordinate< T > TRTK::Coordinate< T >::orthogonal (  ) const

Returns a vector that is orthogonal to *this.

Template Parameters:
Tscalar type

The returned vector is not normalized!

Definition at line 1218 of file Coordinate.hpp.

template<class T >
Coordinate< T > TRTK::Coordinate< T >::orthonormal (  ) const

Returns a normalized vector that is orthogonal to *this.

Template Parameters:
Tscalar type

The returned vector is normalized!

Definition at line 1268 of file Coordinate.hpp.

template<class T>
Coordinate< T > TRTK::Coordinate< T >::rand ( unsigned int  size,
a = T(0),
b = T(1) 
) [static]

Returns a vector filled with uniformly distributed random samples.

Template Parameters:
Tscalar type
Parameters:
[in]sizecoordinate size
[in]aminimum value of the distribution
[in]bmaximum value of the distribution

Properties of the uniform distribution \( \mathcal{U}(a, b) \):

  • pdf: \( f(x) = \begin{cases} \frac{1}{b - a} & \text{for } a \leq x \leq b \\ 0 & \text{otherwise} \end{cases} \)
  • support: \( x \in [a; b] \)
  • mean value: \( 0.5 (a + b) \)
  • variance: \( \frac{1}{12} (b - a)^2 \)
Returns:
Returns a Coordinate<T>.
See also:
size()

Definition at line 1334 of file Coordinate.hpp.

template<class T>
Coordinate< T > TRTK::Coordinate< T >::randn ( unsigned int  size,
mu = T(0),
sigma = T(1) 
) [static]

Returns a vector filled with normally distributed random samples.

Template Parameters:
Tscalar type
Parameters:
[in]sizecoordinate size
[in]mumean of the distribution
[in]sigmastandard deviation of the distribution

Properties of the normal distribution \( \mathcal{N}(\mu, \sigma^2) \):

  • pdf: \( f(x) = \frac{1}{\sqrt{2\pi\sigma^2}} e^{-\frac{(x-\mu)^2}{2\sigma^2}} \)
  • support: \( x \in R \)
  • mean value: \( \mu \)
  • variance: \( \sigma^2 \)
Returns:
Returns a Coordinate<T>.
See also:
size()

Definition at line 1366 of file Coordinate.hpp.

template<class T >
Coordinate< T > & TRTK::Coordinate< T >::reserve ( unsigned int  size )

Reserves memory to store size elements.

Template Parameters:
Tscalar type
Parameters:
[in]sizenew coordinate size
Note:
This call invalidates the data currently hold!
Returns:
Returns *this.
See also:
size()

Definition at line 1392 of file Coordinate.hpp.

template<class T>
Coordinate< T > & TRTK::Coordinate< T >::resize ( unsigned int  size,
value = T() 
)
Template Parameters:
Tscalar type
Parameters:
[in]sizenew coordinate size
[in]valuevalues of appended elements in case *this is enlarged

Changes the coordinate size to size.

Returns:
Returns *this.
See also:
size()

Definition at line 1412 of file Coordinate.hpp.

template<class T >
unsigned int TRTK::Coordinate< T >::size (  ) const [inline]
Template Parameters:
Tscalar type
Returns:
size of *this
See also:
resize(const int size, const T value)

Definition at line 1446 of file Coordinate.hpp.

template<class T >
double TRTK::Coordinate< T >::squaredNorm (  ) const [inline]

Returns the squared Euclidean norm.

Template Parameters:
Tscalar type

Definition at line 1455 of file Coordinate.hpp.

template<class T >
const Coordinate< T >::data_type & TRTK::Coordinate< T >::toArray (  ) const [inline]

Returns an Eigen 3 array.

Template Parameters:
Tscalar type
Returns:
returns an Eigen 3 column vector
See also:
Eigen (http://eigen.tuxfamily.org)

Definition at line 1483 of file Coordinate.hpp.

template<class T >
Coordinate< T >::data_type & TRTK::Coordinate< T >::toArray (  ) [inline]

Returns an Eigen 3 array.

Template Parameters:
Tscalar type
Returns:
returns an Eigen 3 column vector
See also:
Eigen (http://eigen.tuxfamily.org)

Definition at line 1469 of file Coordinate.hpp.

template<class T >
Coordinate< T >::matrix_type TRTK::Coordinate< T >::toMatrix (  ) const [inline]

Returns an Eigen 3 matrix.

Template Parameters:
Tscalar type
Returns:
returns an Eigen 3 column vector
Note:
This functions copies the actual coordinate. Alternatively, you can use
 coordinate.toArray().matrix()
which is more efficient (since no copying is done).
See also:
Eigen (http://eigen.tuxfamily.org)

Definition at line 1504 of file Coordinate.hpp.

template<class T >
std::string TRTK::Coordinate< T >::toString (  ) const

Returns the string representation of the coordinate.

Template Parameters:
Tscalar type
Returns:
returns a standard string
Note:
The stream operator is overloaded which alows you to write code like
 std::cout << Coordinate<double>(1, 2, 3);
See also:
operator >> (std::istream & input, Coordinate<T> & coordinate)

Definition at line 1524 of file Coordinate.hpp.

template<class T >
const T & TRTK::Coordinate< T >::w (  ) const [inline]

Returns the fourth component.

Template Parameters:
Tscalar type

Definition at line 569 of file Coordinate.hpp.

template<class T >
T & TRTK::Coordinate< T >::w (  ) [inline]

Returns the fourth component.

Template Parameters:
Tscalar type

Definition at line 525 of file Coordinate.hpp.

template<class T >
T & TRTK::Coordinate< T >::x (  ) [inline]

Returns the first component.

Template Parameters:
Tscalar type

Definition at line 492 of file Coordinate.hpp.

template<class T >
const T & TRTK::Coordinate< T >::x (  ) const [inline]

Returns the first component.

Template Parameters:
Tscalar type

Definition at line 536 of file Coordinate.hpp.

template<class T >
T & TRTK::Coordinate< T >::y (  ) [inline]

Returns the second component.

Template Parameters:
Tscalar type

Definition at line 503 of file Coordinate.hpp.

template<class T >
const T & TRTK::Coordinate< T >::y (  ) const [inline]

Returns the second component.

Template Parameters:
Tscalar type

Definition at line 547 of file Coordinate.hpp.

template<class T >
const T & TRTK::Coordinate< T >::z (  ) const [inline]

Returns the third component.

Template Parameters:
Tscalar type

Definition at line 558 of file Coordinate.hpp.

template<class T >
T & TRTK::Coordinate< T >::z (  ) [inline]

Returns the third component.

Template Parameters:
Tscalar type

Definition at line 514 of file Coordinate.hpp.


Friends And Related Function Documentation

template<class T>
Coordinate< double > operator* ( int  value,
const Coordinate< double > &  coordinate 
) [related]
Parameters:
[in]value
[in]coordinate
Returns:
Coordinate

Multiplies each component of coordinate with value.

Definition at line 73 of file Coordinate.cpp.

template<class T >
Coordinate< T > operator* ( value,
const Coordinate< T > &  coordinate 
) [related]
Template Parameters:
Tscalar type of coordinate
Parameters:
[in]value
[in]coordinate
Returns:
Coordinate with scalar type T

Multiplies each component of coordinate with value.

Definition at line 1619 of file Coordinate.hpp.

template<class T>
Coordinate< int > operator* ( double  value,
const Coordinate< int > &  coordinate 
) [related]
Parameters:
[in]value
[in]coordinate
Returns:
Coordinate

Multiplies each component of coordinate with value.

Note:
Internally, the computations are done with doubles.

Definition at line 148 of file Coordinate.cpp.

template<class T >
Coordinate< T > operator+ ( value,
const Coordinate< T > &  coordinate 
) [related]
Template Parameters:
Tscalar type of coordinate
Parameters:
[in]value
[in]coordinate
Returns:
Coordinate with scalar type T

Adds value to each component of coordinate.

Definition at line 1580 of file Coordinate.hpp.

template<class T>
Coordinate< int > operator+ ( double  value,
const Coordinate< int > &  coordinate 
) [related]
Parameters:
[in]value
[in]coordinate
Returns:
Coordinate

Adds int(value) to each component of coordinate.

Definition at line 111 of file Coordinate.cpp.

template<class T>
Coordinate< double > operator+ ( int  value,
const Coordinate< double > &  coordinate 
) [related]
Parameters:
[in]value
[in]coordinate
Returns:
Coordinate

Adds value to each component of coordinate.

Definition at line 40 of file Coordinate.cpp.

template<class T>
Coordinate< double > operator- ( int  value,
const Coordinate< double > &  coordinate 
) [related]
Parameters:
[in]value
[in]coordinate
Returns:
Coordinate

Element-wise subtraction where coordinate is subtracted from \( (value, value, ..., value)^T \).

Definition at line 57 of file Coordinate.cpp.

template<class T >
Coordinate< T > operator- ( value,
const Coordinate< T > &  coordinate 
) [related]
Template Parameters:
Tscalar type of coordinate
Parameters:
[in]value
[in]coordinate
Returns:
Coordinate with scalar type T

Element-wise subtraction where coordinate is subtracted from \( (value, value, ..., value)^T \).

Definition at line 1600 of file Coordinate.hpp.

template<class T>
Coordinate< int > operator- ( double  value,
const Coordinate< int > &  coordinate 
) [related]
Parameters:
[in]value
[in]coordinate
Returns:
Coordinate

Element-wise subtraction where, first, value is typecasted into an integer and then, coordinate is subtracted from \( (value, value, ..., value)^T \).

Definition at line 129 of file Coordinate.cpp.

template<class T>
Coordinate< int > operator/ ( double  value,
const Coordinate< int > &  coordinate 
) [related]
Parameters:
[in]value
[in]coordinate
Returns:
Coordinate

Element-wise division of \( (value, value, \dots, value)^T \) by coordinate.

Note:
Internally, the computation is done with doubles.

Definition at line 168 of file Coordinate.cpp.

template<class T>
Coordinate< double > operator/ ( int  value,
const Coordinate< double > &  coordinate 
) [related]
Parameters:
[in]value
[in]coordinate
Returns:
Coordinate

Element-wise division of \( (value, value, \dots, value)^T \) by coordinate.

Definition at line 90 of file Coordinate.cpp.

template<class T >
Coordinate< T > operator/ ( value,
const Coordinate< T > &  coordinate 
) [related]
Template Parameters:
Tscalar type of coordinate
Parameters:
[in]value
[in]coordinate
Returns:
Coordinate with scalar type T

Element-wise division of \( (value, value, \dots, value)^T \) by coordinate.

Definition at line 1639 of file Coordinate.hpp.

template<class T >
std::ostream & operator<< ( std::ostream &  output,
const Coordinate< T > &  coordinate 
) [related]
Template Parameters:
Tscalar type
Parameters:
[out]ouputoutput stream (e.g. std::out)
[in]coordinatecoordinate
Returns:
Returns a reference to the output stream to allow constructs like
 Coordinate<double> c(1, 2);
 std::cout << c << std::endl;

Writes a Coordinate as formatted text to an output stream. The output format is a comma separated list enclosed by round brackets.

Example:

 Coordinate<double> c(1, 2, 3);
 std::cout << c << std::endl;

Output:

 (1, 2, 3)
See also:
operator >> (std::istream & input, Coordinate<T> & coordinate)

Definition at line 1793 of file Coordinate.hpp.

template<class T >
std::istream & operator>> ( std::istream &  input,
Coordinate< T > &  coordinate 
) [related]
Template Parameters:
Tscalar type
Parameters:
[in]inputinput stream (e.g. std::cin)
[out]coordinatetarget coordinate
Returns:
Returns a reference to the input stream to allow constructs like
 Coordinate<double> c1(0, 0), c2(0, 0);
 std::cin >> c1 >> c2;

Reads a Coordinate from input and saves it to coordinate. The input format is a comma separated list enclosed by round brackets. Anything diverging from it, leads to an exception. The dimension of the input coordinate must coincide with the dimension of the target coordinate, otherwise an exception is thrown.

Here is an more elaborate example:

 #include <Coordinate.hpp>
 #include <iostream>
 #include <sstream>

 int main()
 {
     Coordinate<double> c(1, 2, 3);

     std::cout << c << std::endl;

     std::stringstream ss;
     ss << "(4, 2, 1)";
     ss >> c;

     std::cout << c << std::endl;

     return 0;
 }

Output:

 (1, 2, 3)
 (4, 2, 1)
Exceptions:
std::exception(see text above)
See also:
operator >> (std::istream & input, Coordinate<T> & coordinate)

Definition at line 1709 of file Coordinate.hpp.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines