OpenMS
DPosition< D, TCoordinateType > Class Template Reference

Representation of a coordinate in D-dimensional space. More...

#include <OpenMS/DATASTRUCTURES/DPosition.h>

Inheritance diagram for DPosition< D, TCoordinateType >:
[legend]
Collaboration diagram for DPosition< D, TCoordinateType >:
[legend]

Public Types

enum  { DIMENSION = D }
 Dimensions. More...
 
typedef TCoordinateType CoordinateType
 Coordinate type. More...
 
typedef CoordinateTypeIterator
 Mutable iterator. More...
 
typedef const CoordinateTypeConstIterator
 Non-mutable iterator. More...
 
STL compatibility type definitions
typedef CoordinateType value_type
 
typedef CoordinateTypereference
 
typedef CoordinateTypepointer
 
typedef CoordinateTypeiterator
 
typedef const CoordinateTypeconst_iterator
 

Public Member Functions

Constructors and Destructor
 DPosition ()=default
 Default constructor. More...
 
 DPosition (CoordinateType x)
 Constructor that fills all dimensions with the value x. More...
 
 DPosition (CoordinateType x, CoordinateType y)
 Constructor only for DPosition<2> that takes two Coordinates. More...
 
 DPosition (CoordinateType x, CoordinateType y, CoordinateType z)
 Constructor only for DPosition<3> that takes three Coordinates. More...
 
 DPosition (const DPosition &pos)=default
 Copy constructor. More...
 
 DPosition (DPosition &&rhs) noexcept=default
 Move constructor. More...
 
DPositionoperator= (const DPosition &source)=default
 Assignment operator. More...
 
DPositionoperator= (DPosition &&source) noexcept=default
 Move Assignment operator. More...
 
 ~DPosition () noexcept=default
 Destructor (not-virtual as this will save a lot of space!) More...
 
void swap (DPosition &rhs) noexcept
 Swap the two objects. More...
 
DPositionabs () noexcept
 Make all dimension values positive. More...
 

Static Public Member Functions

Static values
static constexpr DPosition zero ()
 all zero More...
 
static constexpr DPosition minPositive ()
 smallest positive More...
 
static constexpr DPosition minNegative ()
 smallest negative More...
 
static constexpr DPosition maxPositive ()
 largest positive More...
 

Iteration

CoordinateType coordinate_ [D] {}
 
ConstIterator begin () const
 Non-mutable begin iterator. More...
 
ConstIterator end () const
 Non-mutable end iterator. More...
 
Iterator begin ()
 Mutable begin iterator. More...
 
Iterator end ()
 Mutable end iterator. More...
 

Accessors

CoordinateType operator[] (Size index) const
 Const accessor for the dimensions. More...
 
CoordinateTypeoperator[] (Size index)
 Accessor for the dimensions. More...
 
CoordinateType getX () const
 Name accessor for the first dimension. Only for DPosition<2>, for visualization. More...
 
CoordinateType getY () const
 Name accessor for the second dimension. Only for DPosition<2>, for visualization. More...
 
void setX (CoordinateType c)
 Name mutator for the first dimension. Only for DPosition<2>, for visualization. More...
 
void setY (CoordinateType c)
 Name mutator for the second dimension. Only for DPosition<2>, for visualization. More...
 
bool operator== (const DPosition &point) const
 Equality operator. More...
 
bool operator!= (const DPosition &point) const
 Equality operator. More...
 
bool operator< (const DPosition &point) const
 Lexicographical less than operator. Lexicographical comparison from dimension 0 to dimension D-1 is done. More...
 
bool operator<= (const DPosition &point) const
 Lexicographical greater less or equal operator. More...
 
bool spatiallyLessEqual (const DPosition &point) const
 Spatially (geometrically) less or equal operator. All coordinates must be "<=". More...
 
bool spatiallyGreaterEqual (const DPosition &point) const
 Spatially (geometrically) greater or equal operator. All coordinates must be ">=". More...
 
bool operator> (const DPosition &point) const
 Lexicographical greater than operator. More...
 
bool operator>= (const DPosition &point) const
 Lexicographical greater or equal operator. More...
 
DPosition operator+ (const DPosition &point) const
 Addition (a bit inefficient) More...
 
DPositionoperator+= (const DPosition &point)
 Addition. More...
 
DPosition operator- (const DPosition &point) const
 Subtraction (a bit inefficient) More...
 
DPositionoperator-= (const DPosition &point)
 Subtraction. More...
 
DPosition operator- () const
 Negation (a bit inefficient) More...
 
CoordinateType operator* (const DPosition &point) const
 Inner product. More...
 
DPositionoperator*= (CoordinateType scalar)
 Scalar multiplication. More...
 
DPositionoperator/= (CoordinateType scalar)
 Scalar division. More...
 
void clear ()
 Set all dimensions to zero. More...
 
static Size size ()
 Returns the number of dimensions. More...
 

Detailed Description

template<UInt D, typename TCoordinateType = double>
class OpenMS::DPosition< D, TCoordinateType >

Representation of a coordinate in D-dimensional space.

Member Typedef Documentation

◆ const_iterator

◆ ConstIterator

typedef const CoordinateType* ConstIterator

Non-mutable iterator.

◆ CoordinateType

typedef TCoordinateType CoordinateType

Coordinate type.

◆ Iterator

Mutable iterator.

◆ iterator

◆ pointer

◆ reference

◆ value_type

Member Enumeration Documentation

◆ anonymous enum

anonymous enum

Dimensions.

Enumerator
DIMENSION 

Constructor & Destructor Documentation

◆ DPosition() [1/6]

◆ DPosition() [2/6]

DPosition ( CoordinateType  x)
inline

Constructor that fills all dimensions with the value x.

References DPosition< D, TCoordinateType >::coordinate_.

◆ DPosition() [3/6]

DPosition ( CoordinateType  x,
CoordinateType  y 
)
inline

Constructor only for DPosition<2> that takes two Coordinates.

References DPosition< D, TCoordinateType >::coordinate_.

◆ DPosition() [4/6]

Constructor only for DPosition<3> that takes three Coordinates.

References DPosition< D, TCoordinateType >::coordinate_.

◆ DPosition() [5/6]

DPosition ( const DPosition< D, TCoordinateType > &  pos)
default

Copy constructor.

◆ DPosition() [6/6]

DPosition ( DPosition< D, TCoordinateType > &&  rhs)
defaultnoexcept

Move constructor.

◆ ~DPosition()

~DPosition ( )
defaultnoexcept

Destructor (not-virtual as this will save a lot of space!)

Member Function Documentation

◆ abs()

DPosition& abs ( )
inlinenoexcept

Make all dimension values positive.

References DPosition< D, TCoordinateType >::coordinate_.

Referenced by Annotation1DPeakItem< DataPoint >::draw().

◆ begin() [1/2]

Iterator begin ( )
inline

Mutable begin iterator.

References DPosition< D, TCoordinateType >::coordinate_.

◆ begin() [2/2]

◆ clear()

void clear ( )
inline

◆ end() [1/2]

Iterator end ( )
inline

Mutable end iterator.

References DPosition< D, TCoordinateType >::coordinate_.

◆ end() [2/2]

◆ getX()

CoordinateType getX ( ) const
inline

◆ getY()

CoordinateType getY ( ) const
inline

◆ maxPositive()

static constexpr DPosition maxPositive ( )
inlinestaticconstexpr

largest positive

References DPosition< D, TCoordinateType >::DPosition().

◆ minNegative()

static constexpr DPosition minNegative ( )
inlinestaticconstexpr

smallest negative

References DPosition< D, TCoordinateType >::DPosition().

◆ minPositive()

static constexpr DPosition minPositive ( )
inlinestaticconstexpr

smallest positive

References DPosition< D, TCoordinateType >::DPosition().

◆ operator!=()

bool operator!= ( const DPosition< D, TCoordinateType > &  point) const
inline

Equality operator.

References DPosition< D, TCoordinateType >::operator==().

◆ operator*()

CoordinateType operator* ( const DPosition< D, TCoordinateType > &  point) const
inline

◆ operator*=()

DPosition& operator*= ( CoordinateType  scalar)
inline

Scalar multiplication.

References DPosition< D, TCoordinateType >::coordinate_.

◆ operator+()

DPosition operator+ ( const DPosition< D, TCoordinateType > &  point) const
inline

Addition (a bit inefficient)

References DPosition< D, TCoordinateType >::coordinate_.

◆ operator+=()

DPosition& operator+= ( const DPosition< D, TCoordinateType > &  point)
inline

◆ operator-() [1/2]

DPosition operator- ( ) const
inline

Negation (a bit inefficient)

References DPosition< D, TCoordinateType >::coordinate_.

◆ operator-() [2/2]

DPosition operator- ( const DPosition< D, TCoordinateType > &  point) const
inline

Subtraction (a bit inefficient)

References DPosition< D, TCoordinateType >::coordinate_.

◆ operator-=()

DPosition& operator-= ( const DPosition< D, TCoordinateType > &  point)
inline

◆ operator/=()

DPosition& operator/= ( CoordinateType  scalar)
inline

Scalar division.

References DPosition< D, TCoordinateType >::coordinate_.

◆ operator<()

bool operator< ( const DPosition< D, TCoordinateType > &  point) const
inline

Lexicographical less than operator. Lexicographical comparison from dimension 0 to dimension D-1 is done.

References DPosition< D, TCoordinateType >::coordinate_.

Referenced by DPosition< D, TCoordinateType >::operator>=().

◆ operator<=()

bool operator<= ( const DPosition< D, TCoordinateType > &  point) const
inline

Lexicographical greater less or equal operator.

References DPosition< D, TCoordinateType >::coordinate_.

Referenced by DPosition< D, TCoordinateType >::operator>().

◆ operator=() [1/2]

DPosition& operator= ( const DPosition< D, TCoordinateType > &  source)
default

Assignment operator.

◆ operator=() [2/2]

DPosition& operator= ( DPosition< D, TCoordinateType > &&  source)
defaultnoexcept

Move Assignment operator.

◆ operator==()

bool operator== ( const DPosition< D, TCoordinateType > &  point) const
inline

◆ operator>()

bool operator> ( const DPosition< D, TCoordinateType > &  point) const
inline

Lexicographical greater than operator.

References DPosition< D, TCoordinateType >::operator<=().

◆ operator>=()

bool operator>= ( const DPosition< D, TCoordinateType > &  point) const
inline

Lexicographical greater or equal operator.

References DPosition< D, TCoordinateType >::operator<().

◆ operator[]() [1/2]

CoordinateType& operator[] ( Size  index)
inline

Accessor for the dimensions.

References DPosition< D, TCoordinateType >::coordinate_, and OPENMS_PRECONDITION.

◆ operator[]() [2/2]

CoordinateType operator[] ( Size  index) const
inline

Const accessor for the dimensions.

References DPosition< D, TCoordinateType >::coordinate_, and OPENMS_PRECONDITION.

◆ setX()

void setX ( CoordinateType  c)
inline

Name mutator for the first dimension. Only for DPosition<2>, for visualization.

References OpenMS::Constants::c, DPosition< D, TCoordinateType >::coordinate_, and OPENMS_PRECONDITION.

◆ setY()

void setY ( CoordinateType  c)
inline

Name mutator for the second dimension. Only for DPosition<2>, for visualization.

References OpenMS::Constants::c, DPosition< D, TCoordinateType >::coordinate_, and OPENMS_PRECONDITION.

◆ size()

static Size size ( )
inlinestatic

Returns the number of dimensions.

◆ spatiallyGreaterEqual()

bool spatiallyGreaterEqual ( const DPosition< D, TCoordinateType > &  point) const
inline

Spatially (geometrically) greater or equal operator. All coordinates must be ">=".

References DPosition< D, TCoordinateType >::coordinate_.

◆ spatiallyLessEqual()

bool spatiallyLessEqual ( const DPosition< D, TCoordinateType > &  point) const
inline

Spatially (geometrically) less or equal operator. All coordinates must be "<=".

References DPosition< D, TCoordinateType >::coordinate_.

◆ swap()

void swap ( DPosition< D, TCoordinateType > &  rhs)
inlinenoexcept

Swap the two objects.

References DPosition< D, TCoordinateType >::coordinate_.

◆ zero()

static constexpr DPosition zero ( )
inlinestaticconstexpr

Member Data Documentation

◆ coordinate_