MeVisLab Toolbox Reference
ml::Tvec2< DT > Class Template Reference

Declaration of float vector type traits: More...

#include <mlVector2.h>

Inheritance diagram for ml::Tvec2< DT >:
ml::FloatingPointVector< DT, 2, Vector2DataContainer< DT > > ml::Vector2DataContainer< DT >

Public Types

typedef FloatingPointVector< DT, 2, Vector2DataContainer< DT > > Superclass
 A typedef as a shorthand for the base class. More...
 
typedef DT ComponentType
 A typedef to "export" the type of components. More...
 
- Public Types inherited from ml::FloatingPointVector< DT, 2, Vector2DataContainer< DT > >
enum  
 This enum grants access to the size during compile time, e.g. More...
 
typedef DT ComponentType
 A typedef to "export" the type of components. More...
 

Public Member Functions

Tvec3< DT > affineVec () const
 Builds a homogeneous Tvec3vector from *this and return it, i.e. More...
 
Tvec3< DT > affinePoint () const
 Builds a homogeneous Tvec3point from *this and return it, i.e. More...
 
Constructors
 Tvec2 (const DT value=0)
 Default and value constructor. More...
 
 Tvec2 (const Superclass &v)
 Copy constructor from FloatingPointVector. More...
 
 Tvec2 (const DT px, const DT py)
 Constructor building the vector x (first entry) and y (second entry). More...
 
void assign (const DT px, const DT py)
 Sets all components to the passed values. More...
 
 Tvec2 (const Tvec3< DT > &v, const bool normalize)
 Casts v to Tvec2. More...
 
 Tvec2 (const Tvec3< DT > &v, const int axis)
 Casts v3 to v2. More...
 
- Public Member Functions inherited from ml::FloatingPointVector< DT, 2, Vector2DataContainer< DT > >
 FloatingPointVector (DT value=DT(0))
 Default and value constructor. More...
 
FloatingPointVector< DT, size, Vector2DataContainer< DT > > & operator= (DT value)
 Assignment of scalar value to all components. More...
 
bool operator== (const FloatingPointVector< DT, size, Vector2DataContainer< DT > > &buffer) const
 Returns whether *this and buffer are component wise equal. More...
 
bool operator!= (const FloatingPointVector< DT, size, Vector2DataContainer< DT > > &buffer) const
 Returns whether any components of *this and buffer are not equal. More...
 
bool operator< (const FloatingPointVector< DT, size, Vector2DataContainer< DT > > &buffer) const
 Defines an artificial order for use in sort algorithms (lexicographical order). More...
 
const DT & operator[] (const size_t i) const
 Constant indexing operators. More...
 
DT & operator[] (const size_t i)
 Indexing operators. More...
 
size_t getSize () const
 Returns the number of elements of value buffer. More...
 
DT norm2 () const
 Returns the Euclidean norm (the vector length), i.e., square root of sum of squares of all components. More...
 
DT norm2 (const FloatingPointVector< DT, size, Vector2DataContainer< DT > > &weight) const
 Returns the weighted Euclidean norm, i.e., square root of sum of squares of all components multiplied with corresponding squared component of weight. More...
 
DT dot (const FloatingPointVector< DT, size, Vector2DataContainer< DT > > &buffer) const
 Returns the dot product, i.e., sum of all components multiplied with corresponding components of buffer. More...
 
DT normalize ()
 Normalizes the buffer and returns the Euclidean length of vector before normalization, i.e., norm2. More...
 
DT length () const
 Returns the length of the vector, i.e. norm2(). More...
 
DT distance (const FloatingPointVector< DT, size, Vector2DataContainer< DT > > &buffer) const
 Returns the distance of this vector to a given one. More...
 
DT distanceSquared (const FloatingPointVector< DT, size, Vector2DataContainer< DT > > &buffer) const
 Returns the squared distance of this vector to a given one. More...
 
DT lengthSquared () const
 Returns the squared length of the vector. More...
 
DT compSum () const
 Returns the sum of all components. More...
 
DT compMul () const
 Returns the product of all vector components. More...
 
DT compMaxAbs () const
 Returns the maximum of absolute component values. More...
 
void compMin (FloatingPointVector< DT, size, Vector2DataContainer< DT > > buffer)
 Sets the component wise minimum of *this and buffer in *this. More...
 
void compMax (FloatingPointVector< DT, size, Vector2DataContainer< DT > > buffer)
 Sets the component wise maximum of *this and buffer in *this. More...
 
void compAbs ()
 Kills negative signs from all components. More...
 
void compDiv (const FloatingPointVector< DT, size, Vector2DataContainer< DT > > &d)
 Divides each vector component by the corresponding one of d. More...
 
void compSqr ()
 Calculates and sets the square of all components. More...
 
void compSqrt ()
 Calculates and sets square root of all components. More...
 
void clampMin (const FloatingPointVector< DT, size, Vector2DataContainer< DT > > &lower)
 Calculates and sets all components clamped to lower, i.e., if any component is smaller than the corresponding one in lower then it is set to the one from lower. More...
 
void clampMax (const FloatingPointVector< DT, size, Vector2DataContainer< DT > > &upper)
 Calculates and sets all components clamped to upper, i.e., if any component is greater than the corresponding one in upper then it is set to the one from upper. More...
 
void clamp (const FloatingPointVector< DT, size, Vector2DataContainer< DT > > &lower, const FloatingPointVector< DT, size, Vector2DataContainer< DT > > &upper)
 Calculates and sets all components of *this so that they are between minimum min and maximum max. More...
 
void compRound ()
 Rounds all components of this vector using floor(component + 0.5). More...
 
void compFloor ()
 Rounds all components of this vector using floor(component). More...
 
void compCeil ()
 Rounds all components of this vector to integer using ceil(component). More...
 
FloatingPointVector< DT, 3, Vector2DataContainer< DT > > cross (const FloatingPointVector< DT, 3, Vector2DataContainer< DT > > &b) const
 Returns the cross product for elements, i.e., return vector vertical to *this and b. More...
 
void apply (ML_LA_FROM_DOUBLE_TO_DOUBLE f)
 Applies the function f to each component starting from index 0 to index size-1. More...
 
std::ostream & writeOut (std::ostream &os) const
 Writes all components to ostream os starting from index 0 to size-1. More...
 
std::istream & readIn (std::istream &is)
 Reads all components from istream is starting starting from index 0 to size-1. More...
 

Additional Inherited Members

- Public Attributes inherited from ml::Vector2DataContainer< DT >
union {
   struct {
      DT   x
 X-component of the vector, same as _buffer[0]. More...
 
      DT   y
 Y-component of the vector, same as _buffer[1]. More...
 
   } 
 
   DT   _buffer [2]
 Data members as vector to provide array access, same as x and y members. More...
 
}; 
 

Detailed Description

template<class DT>
class ml::Tvec2< DT >

Declaration of float vector type traits:

Forward declarations to resolve header file dependencies.

A two dimensional vector class for floating point types.

Definition at line 56 of file mlVector2.h.

Member Typedef Documentation

◆ ComponentType

template<class DT >
typedef DT ml::Tvec2< DT >::ComponentType

A typedef to "export" the type of components.

Definition at line 64 of file mlVector2.h.

◆ Superclass

template<class DT >
typedef FloatingPointVector<DT, 2, Vector2DataContainer<DT> > ml::Tvec2< DT >::Superclass

A typedef as a shorthand for the base class.

Definition at line 61 of file mlVector2.h.

Constructor & Destructor Documentation

◆ Tvec2() [1/5]

template<class DT >
ml::Tvec2< DT >::Tvec2 ( const DT  value = 0)
inlineexplicit

Default and value constructor.

Set all entries to a user given value. value is the init value for all entries. 0 is the default value.

Definition at line 72 of file mlVector2.h.

◆ Tvec2() [2/5]

template<class DT >
ml::Tvec2< DT >::Tvec2 ( const Superclass v)
inline

Copy constructor from FloatingPointVector.

This allows the usage of SclarVectorTemplate objects of the same DT in operators using the Tvec2, because the FloatingPointVector objects can implicitly be cast.

Definition at line 79 of file mlVector2.h.

◆ Tvec2() [3/5]

template<class DT >
ml::Tvec2< DT >::Tvec2 ( const DT  px,
const DT  py 
)
inline

Constructor building the vector x (first entry) and y (second entry).

Definition at line 84 of file mlVector2.h.

◆ Tvec2() [4/5]

template<class DT >
ml::Tvec2< DT >::Tvec2 ( const Tvec3< DT > &  v,
const bool  normalize 
)
inline

Casts v to Tvec2.

If normalize is true then the first two components are divided by the last one to implement a homogeneous cast. In that case it is up to the caller to avoid a division by zero. If normalize if false then the first two components are taken unchanged.

Definition at line 100 of file mlVector2.h.

References ML_CHECK_FLOAT_THROW.

◆ Tvec2() [5/5]

template<class DT >
ml::Tvec2< DT >::Tvec2 ( const Tvec3< DT > &  v,
const int  axis 
)
inline

Casts v3 to v2.

axis specifies component to be thrown away. All other components are copied sequentially. If axis is not within [0,2] then the last component is thrown away.

Definition at line 118 of file mlVector2.h.

Member Function Documentation

◆ affinePoint()

template<class DT >
Tvec3<DT> ml::Tvec2< DT >::affinePoint ( ) const
inline

Builds a homogeneous Tvec3point from *this and return it, i.e.

leaves all components unchanged and set the third component to 1.

Definition at line 140 of file mlVector2.h.

◆ affineVec()

template<class DT >
Tvec3<DT> ml::Tvec2< DT >::affineVec ( ) const
inline

Builds a homogeneous Tvec3vector from *this and return it, i.e.

leaves all components unchanged and set the third component to 0.

Definition at line 133 of file mlVector2.h.

◆ assign()

template<class DT >
void ml::Tvec2< DT >::assign ( const DT  px,
const DT  py 
)
inline

Sets all components to the passed values.

Definition at line 90 of file mlVector2.h.


The documentation for this class was generated from the following files: