A generic coordinate class. More...
#include <Coordinate.hpp>
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 |
Coordinate & | operator+= (T) |
Coordinate & | operator-= (T) |
Coordinate & | operator*= (T) |
Coordinate & | operator/= (T) |
Coordinate & | operator+= (const Coordinate &) |
Component-wise addition. | |
Coordinate & | operator-= (const Coordinate &) |
Component-wise subtraction. | |
Coordinate & | operator*= (const Coordinate &) |
Component-wise multiplication. | |
Coordinate & | operator/= (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. | |
Coordinate & | fill (T) |
double | norm () const |
Returns the Euclidean norm. | |
Coordinate & | normalize () |
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 . | |
Coordinate & | reserve (unsigned int size) |
Reserves memory to store size elements. | |
Coordinate & | resize (unsigned int size, T value=T()) |
unsigned int | size () const |
double | squaredNorm () const |
Returns the squared Euclidean norm. | |
data_type & | toArray () |
Returns an Eigen 3 array. | |
const data_type & | toArray () 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) |
A generic coordinate class.
T | scalar 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)
// 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
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
TRTK_SUPPORT_CVECTOR
is defined, Coordinate will support the mediTEC CVector
class. That is, an constructor as well as a conversion operator is defined.Definition at line 148 of file Coordinate.hpp.
enum TRTK::Coordinate::Error |
Error codes that might be set when ErrorObj is thrown.
Definition at line 241 of file Coordinate.hpp.
TRTK::Coordinate< T >::Coordinate | ( | T | x ) |
Constructs a one-dimensional coordinate.
T | scalar type |
[in] | x | first element |
Definition at line 328 of file Coordinate.hpp.
TRTK::Coordinate< T >::Coordinate | ( | T | x, |
T | y | ||
) |
Constructs a two-dimensional coordinate.
T | scalar type |
[in] | x | first element |
[in] | y | second element |
Definition at line 341 of file Coordinate.hpp.
TRTK::Coordinate< T >::Coordinate | ( | T | x, |
T | y, | ||
T | z | ||
) |
Constructs a three-dimensional coordinate.
T | scalar type |
[in] | x | first element |
[in] | y | second element |
[in] | z | third element |
Definition at line 356 of file Coordinate.hpp.
TRTK::Coordinate< T >::Coordinate | ( | T | x, |
T | y, | ||
T | z, | ||
T | w | ||
) |
Constructs a four-dimensional coordinate.
T | scalar type |
[in] | x | first element |
[in] | y | second element |
[in] | z | third element |
[in] | w | fourth element |
Definition at line 373 of file Coordinate.hpp.
TRTK::Coordinate< T >::Coordinate | ( | const Coordinate< T > & | coordinate ) |
Copy constructor.
T | scalar type |
[in] | coordinate | coordinate of the same type |
Definition at line 390 of file Coordinate.hpp.
TRTK::Coordinate< T >::Coordinate | ( | const Coordinate< U > & | coordinate ) |
Copy constructor.
T | scalar type of the newly created coordinate |
U | scalar type of the copied coordinate |
[in] | coordinate | Coordinate with scalar type U |
Definition at line 406 of file Coordinate.hpp.
TRTK::Coordinate< T >::Coordinate | ( | const CVector & | cVector ) |
Constructs a Coordinate.
T | scalar type |
[in] | cVector | instance of the CVector class |
This constructor converts a CVector
into a Coordinate.
TRTK_SUPPORT_CVECTOR
must be defined to enable this function. Definition at line 434 of file Coordinate.hpp.
TRTK::Coordinate< T >::Coordinate | ( | const Eigen::DenseBase< Derived > & | vector ) | [explicit] |
Constructs a coordinate from an Eigen Array or Eigen Matrix.
T | scalar type of the newly created coordinate |
Derived | actual type of vector |
[in] | vector | Eigen 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);
Definition at line 471 of file Coordinate.hpp.
TRTK::Coordinate< T >::~Coordinate | ( | ) | [virtual] |
Destructs the coordinate.
T | scalar type |
Definition at line 484 of file Coordinate.hpp.
Coordinate< T > TRTK::Coordinate< T >::cross | ( | const Coordinate< T > & | other ) | const |
Computes a cross product.
T | scalar type |
[in] | other | coordinate |
*this
and other
. Definition at line 1128 of file Coordinate.hpp.
double TRTK::Coordinate< T >::dot | ( | const Coordinate< T > & | other ) | const |
Computes a dot product.
T | scalar type |
[in] | other | coordinate |
*this
and other
. Definition at line 1154 of file Coordinate.hpp.
Coordinate< T > & TRTK::Coordinate< T >::fill | ( | T | value ) | [inline] |
T | scalar type |
[in] | value |
Sets each component of *this
to value
.
*this
. Definition at line 1172 of file Coordinate.hpp.
double TRTK::Coordinate< T >::norm | ( | ) | const [inline] |
Returns the Euclidean norm.
T | scalar type |
Definition at line 1182 of file Coordinate.hpp.
Coordinate< T > & TRTK::Coordinate< T >::normalize | ( | ) |
Normalizes *this
.
T | scalar type |
If this function is called, *this
is divided by its Euclidean norm.
*this
. Definition at line 1196 of file Coordinate.hpp.
Coordinate< T > TRTK::Coordinate< T >::normalized | ( | ) | const |
Returns a normalized copy of *this
.
T | scalar type |
Definition at line 1206 of file Coordinate.hpp.
TRTK::Coordinate< T >::operator CVector | ( | ) | const |
Conversion operator; yields an CVector.
T | scalar type |
*this
(converted)This operator performs an automatic type conversion from Coordinate to CVector
.
TRTK_SUPPORT_CVECTOR
must be defined to enable this function. Definition at line 1103 of file Coordinate.hpp.
TRTK::Coordinate< T >::operator data_type | ( | ) |
Conversion operator; yields an Eigen 3 array.
T | scalar type |
*this
(converted)This operator performs an automatic conversion of *this
to Coordinate::data_type, i.e. an Eigen::Array
Definition at line 1065 of file Coordinate.hpp.
TRTK::Coordinate< T >::operator data_type | ( | ) | const |
Conversion operator; yields an Eigen 3 array.
T | scalar type |
*this
(converted)This operator performs an automatic conversion of *this
to Coordinate::const_data_type, i.e. an Eigen::Array
Definition at line 1083 of file Coordinate.hpp.
Coordinate< T > TRTK::Coordinate< T >::operator* | ( | T | value ) | const |
T | scalar type |
[in] | value | scalar to be multiplied with |
Multiplies value
with each component of *this
.
Definition at line 869 of file Coordinate.hpp.
Coordinate< T > TRTK::Coordinate< T >::operator* | ( | const Coordinate< T > & | coordinate ) | const |
Component-wise multiplication.
T | scalar type |
[in] | coordinate |
Definition at line 958 of file Coordinate.hpp.
Coordinate< T > & TRTK::Coordinate< T >::operator*= | ( | T | value ) | [inline] |
T | scalar type |
[in] | value | scalar to be multiplied with |
Multiplies each component of *this
with value
.
Definition at line 690 of file Coordinate.hpp.
Coordinate< T > & TRTK::Coordinate< T >::operator*= | ( | const Coordinate< T > & | coordinate ) | [inline] |
Component-wise multiplication.
T | scalar type |
[in] | coordinate | other |
Component-wise multiplication of other
and *this
.
Definition at line 777 of file Coordinate.hpp.
Coordinate< T > TRTK::Coordinate< T >::operator+ | ( | T | value ) | const |
T | scalar type |
[in] | value | scalar to be added |
Adds value
to each component of *this
.
Definition at line 831 of file Coordinate.hpp.
Coordinate< T > TRTK::Coordinate< T >::operator+ | ( | const Coordinate< T > & | coordinate ) | const |
Component-wise addition.
T | scalar type |
[in] | coordinate |
Definition at line 920 of file Coordinate.hpp.
Coordinate< T > & TRTK::Coordinate< T >::operator+= | ( | const Coordinate< T > & | coordinate ) | [inline] |
Component-wise addition.
T | scalar type |
[in] | coordinate | other |
Component-wise addition of other
and *this
.
Definition at line 739 of file Coordinate.hpp.
Coordinate< T > & TRTK::Coordinate< T >::operator+= | ( | T | value ) | [inline] |
T | scalar type |
[in] | value | scalar to be added |
Adds value
to each component of *this
.
Definition at line 656 of file Coordinate.hpp.
Coordinate< T > TRTK::Coordinate< T >::operator, | ( | T | value ) | const |
Returns a copy of the coordinate, enlarged by one component.
T | scalar type |
[in] | value | component added to 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)
Definition at line 1040 of file Coordinate.hpp.
Coordinate< T > TRTK::Coordinate< T >::operator- | ( | T | value ) | const |
T | scalar type |
[in] | value | scalar to be subtracted |
Subtracts value
from each component of *this
.
Definition at line 850 of file Coordinate.hpp.
Coordinate< T > TRTK::Coordinate< T >::operator- | ( | const Coordinate< T > & | coordinate ) | const |
Component-wise subtraction.
T | scalar type |
[in] | coordinate |
Definition at line 939 of file Coordinate.hpp.
Coordinate< T > & TRTK::Coordinate< T >::operator-= | ( | const Coordinate< T > & | coordinate ) | [inline] |
Component-wise subtraction.
T | scalar type |
[in] | coordinate | other |
Component-wise subtraction of other
and *this
.
Definition at line 758 of file Coordinate.hpp.
Coordinate< T > & TRTK::Coordinate< T >::operator-= | ( | T | value ) | [inline] |
T | scalar type |
[in] | value | scalar to be subtracted |
Subtracts value
from each component of *this
.
Definition at line 673 of file Coordinate.hpp.
Coordinate< T > TRTK::Coordinate< T >::operator/ | ( | T | value ) | const |
T | scalar type |
[in] | value | divisor |
ErrorObj | If value is zero, an error object is thrown and its error code set to DIVISION_BY_ZERO . |
Divides each component of *this
by value
.
Definition at line 893 of file Coordinate.hpp.
Coordinate< T > TRTK::Coordinate< T >::operator/ | ( | const Coordinate< T > & | coordinate ) | const |
Component-wise division.
T | scalar type |
[in] | coordinate |
ErrorObj | If one or more components of coordinate are zero, an error object is thrown and its error code set to DIVISION_BY_ZERO . |
Definition at line 982 of file Coordinate.hpp.
Coordinate< T > & TRTK::Coordinate< T >::operator/= | ( | const Coordinate< T > & | coordinate ) |
Component-wise division.
T | scalar type |
[in] | coordinate | coordinate containing the divisors |
ErrorObj | If 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
.
Definition at line 801 of file Coordinate.hpp.
Coordinate< T > & TRTK::Coordinate< T >::operator/= | ( | T | value ) |
T | scalar type |
[in] | value | divisor |
ErrorObj | If value is zero, an error object is thrown and its error code set to DIVISION_BY_ZERO . |
Divides each component of *this
by value
.
Definition at line 712 of file Coordinate.hpp.
bool TRTK::Coordinate< T >::operator== | ( | const Coordinate< T > & | coordinate ) | const [inline] |
T | scalar type |
[in] | coordinate | coordinate to be compared with *this |
*this
and coordinate
are equal to each other Definition at line 638 of file Coordinate.hpp.
T & TRTK::Coordinate< T >::operator[] | ( | int | index ) | [inline] |
T | scalar type |
[in] | index | position of the element to be returned |
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.
const T & TRTK::Coordinate< T >::operator[] | ( | int | index ) | const [inline] |
T | scalar type |
[in] | index | position of the element to be returned |
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.
Coordinate< T > TRTK::Coordinate< T >::orthogonal | ( | ) | const |
Returns a vector that is orthogonal to *this
.
T | scalar type |
The returned vector is not normalized!
Definition at line 1218 of file Coordinate.hpp.
Coordinate< T > TRTK::Coordinate< T >::orthonormal | ( | ) | const |
Returns a normalized vector that is orthogonal to *this
.
T | scalar type |
The returned vector is normalized!
Definition at line 1268 of file Coordinate.hpp.
Coordinate< T > TRTK::Coordinate< T >::rand | ( | unsigned int | size, |
T | a = T(0) , |
||
T | b = T(1) |
||
) | [static] |
Returns a vector filled with uniformly distributed random samples.
T | scalar type |
[in] | size | coordinate size |
[in] | a | minimum value of the distribution |
[in] | b | maximum value of the distribution |
Properties of the uniform distribution \( \mathcal{U}(a, b) \):
Coordinate<T>
.Definition at line 1334 of file Coordinate.hpp.
Coordinate< T > TRTK::Coordinate< T >::randn | ( | unsigned int | size, |
T | mu = T(0) , |
||
T | sigma = T(1) |
||
) | [static] |
Returns a vector filled with normally distributed random samples.
T | scalar type |
[in] | size | coordinate size |
[in] | mu | mean of the distribution |
[in] | sigma | standard deviation of the distribution |
Properties of the normal distribution \( \mathcal{N}(\mu, \sigma^2) \):
Coordinate<T>
.Definition at line 1366 of file Coordinate.hpp.
Coordinate< T > & TRTK::Coordinate< T >::reserve | ( | unsigned int | size ) |
Reserves memory to store size
elements.
T | scalar type |
[in] | size | new coordinate size |
*this
.Definition at line 1392 of file Coordinate.hpp.
Coordinate< T > & TRTK::Coordinate< T >::resize | ( | unsigned int | size, |
T | value = T() |
||
) |
T | scalar type |
[in] | size | new coordinate size |
[in] | value | values of appended elements in case *this is enlarged |
Changes the coordinate size to size
.
*this
.Definition at line 1412 of file Coordinate.hpp.
unsigned int TRTK::Coordinate< T >::size | ( | ) | const [inline] |
T | scalar type |
*this
Definition at line 1446 of file Coordinate.hpp.
double TRTK::Coordinate< T >::squaredNorm | ( | ) | const [inline] |
Returns the squared Euclidean norm.
T | scalar type |
Definition at line 1455 of file Coordinate.hpp.
const Coordinate< T >::data_type & TRTK::Coordinate< T >::toArray | ( | ) | const [inline] |
Returns an Eigen 3 array.
T | scalar type |
Definition at line 1483 of file Coordinate.hpp.
Coordinate< T >::data_type & TRTK::Coordinate< T >::toArray | ( | ) | [inline] |
Returns an Eigen 3 array.
T | scalar type |
Definition at line 1469 of file Coordinate.hpp.
Coordinate< T >::matrix_type TRTK::Coordinate< T >::toMatrix | ( | ) | const [inline] |
Returns an Eigen 3 matrix.
T | scalar type |
coordinate.toArray().matrix()
Definition at line 1504 of file Coordinate.hpp.
std::string TRTK::Coordinate< T >::toString | ( | ) | const |
Returns the string representation of the coordinate.
T | scalar type |
std::cout << Coordinate<double>(1, 2, 3);
Definition at line 1524 of file Coordinate.hpp.
const T & TRTK::Coordinate< T >::w | ( | ) | const [inline] |
Returns the fourth component.
T | scalar type |
Definition at line 569 of file Coordinate.hpp.
T & TRTK::Coordinate< T >::w | ( | ) | [inline] |
Returns the fourth component.
T | scalar type |
Definition at line 525 of file Coordinate.hpp.
T & TRTK::Coordinate< T >::x | ( | ) | [inline] |
Returns the first component.
T | scalar type |
Definition at line 492 of file Coordinate.hpp.
const T & TRTK::Coordinate< T >::x | ( | ) | const [inline] |
Returns the first component.
T | scalar type |
Definition at line 536 of file Coordinate.hpp.
T & TRTK::Coordinate< T >::y | ( | ) | [inline] |
Returns the second component.
T | scalar type |
Definition at line 503 of file Coordinate.hpp.
const T & TRTK::Coordinate< T >::y | ( | ) | const [inline] |
Returns the second component.
T | scalar type |
Definition at line 547 of file Coordinate.hpp.
const T & TRTK::Coordinate< T >::z | ( | ) | const [inline] |
Returns the third component.
T | scalar type |
Definition at line 558 of file Coordinate.hpp.
T & TRTK::Coordinate< T >::z | ( | ) | [inline] |
Returns the third component.
T | scalar type |
Definition at line 514 of file Coordinate.hpp.
Coordinate< double > operator* | ( | int | value, |
const Coordinate< double > & | coordinate | ||
) | [related] |
[in] | value | |
[in] | coordinate |
Multiplies each component of coordinate
with value
.
Definition at line 73 of file Coordinate.cpp.
Coordinate< T > operator* | ( | T | value, |
const Coordinate< T > & | coordinate | ||
) | [related] |
T | scalar type of coordinate |
[in] | value | |
[in] | coordinate |
Multiplies each component of coordinate
with value
.
Definition at line 1619 of file Coordinate.hpp.
Coordinate< int > operator* | ( | double | value, |
const Coordinate< int > & | coordinate | ||
) | [related] |
[in] | value | |
[in] | coordinate |
Multiplies each component of coordinate
with value
.
Definition at line 148 of file Coordinate.cpp.
Coordinate< T > operator+ | ( | T | value, |
const Coordinate< T > & | coordinate | ||
) | [related] |
T | scalar type of coordinate |
[in] | value | |
[in] | coordinate |
Adds value
to each component of coordinate
.
Definition at line 1580 of file Coordinate.hpp.
Coordinate< int > operator+ | ( | double | value, |
const Coordinate< int > & | coordinate | ||
) | [related] |
[in] | value | |
[in] | coordinate |
Adds int(value)
to each component of coordinate
.
Definition at line 111 of file Coordinate.cpp.
Coordinate< double > operator+ | ( | int | value, |
const Coordinate< double > & | coordinate | ||
) | [related] |
[in] | value | |
[in] | coordinate |
Adds value
to each component of coordinate
.
Definition at line 40 of file Coordinate.cpp.
Coordinate< double > operator- | ( | int | value, |
const Coordinate< double > & | coordinate | ||
) | [related] |
[in] | value | |
[in] | coordinate |
Element-wise subtraction where coordinate
is subtracted from \( (value, value, ..., value)^T \).
Definition at line 57 of file Coordinate.cpp.
Coordinate< T > operator- | ( | T | value, |
const Coordinate< T > & | coordinate | ||
) | [related] |
T | scalar type of coordinate |
[in] | value | |
[in] | coordinate |
Element-wise subtraction where coordinate
is subtracted from \( (value, value, ..., value)^T \).
Definition at line 1600 of file Coordinate.hpp.
Coordinate< int > operator- | ( | double | value, |
const Coordinate< int > & | coordinate | ||
) | [related] |
[in] | value | |
[in] | 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.
Coordinate< int > operator/ | ( | double | value, |
const Coordinate< int > & | coordinate | ||
) | [related] |
[in] | value | |
[in] | coordinate |
Element-wise division of \( (value, value, \dots, value)^T \) by coordinate
.
Definition at line 168 of file Coordinate.cpp.
Coordinate< double > operator/ | ( | int | value, |
const Coordinate< double > & | coordinate | ||
) | [related] |
[in] | value | |
[in] | coordinate |
Element-wise division of \( (value, value, \dots, value)^T \) by coordinate
.
Definition at line 90 of file Coordinate.cpp.
Coordinate< T > operator/ | ( | T | value, |
const Coordinate< T > & | coordinate | ||
) | [related] |
T | scalar type of coordinate |
[in] | value | |
[in] | coordinate |
Element-wise division of \( (value, value, \dots, value)^T \) by coordinate
.
Definition at line 1639 of file Coordinate.hpp.
std::ostream & operator<< | ( | std::ostream & | output, |
const Coordinate< T > & | coordinate | ||
) | [related] |
T | scalar type |
[out] | ouput | output stream (e.g. std::out ) |
[in] | coordinate | coordinate |
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)
Definition at line 1793 of file Coordinate.hpp.
std::istream & operator>> | ( | std::istream & | input, |
Coordinate< T > & | coordinate | ||
) | [related] |
T | scalar type |
[in] | input | input stream (e.g. std::cin ) |
[out] | coordinate | target coordinate |
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)
std::exception | (see text above) |
Definition at line 1709 of file Coordinate.hpp.
Documentation generated by Doxygen