ICF 3.0.5.47
Technical documentation of ICF Libraries
imath::TVector< Size, Element > Class Template Reference

Implementation of fixed-size mathematical vector with specified type of elements. More...

#include <TVector.h>

Inheritance diagram for imath::TVector< Size, Element >:
Collaboration diagram for imath::TVector< Size, Element >:

Public Types

typedef Element ElementType
 
typedef std::array< Element, Size > Elements
 

Public Member Functions

 TVector ()
 Create an uninitialized point.
 
 TVector (const TVector< Size, Element > &vector)
 Copy constructor.
 
 TVector (TVector< Size, Element > &&vector) noexcept
 Move constructor.
 
const Element & GetElement (int i) const
 Get element at specified i.
 
Element & GetElementRef (int i)
 Get reference to element at specified i.
 
void SetElement (int i, const Element &value)
 Set element at specified i.
 
void SetAllElements (const Element &value)
 Set some value to all elements.
 
void Reset ()
 Set all coordinates to zero.
 
void Clear ()
 Set all coordinates to zero.
 
const TVector< Size, Element >::ElementsGetElements () const
 Get read-only access to internal element container.
 
TVector< Size, Element >::ElementsGetElementsRef ()
 Get access to internal element container.
 
void Translate (const TVector< Size, Element > &vector)
 Translate the point.
 
TVector< Size, Element > GetTranslated (const TVector< Size, Element > &vector)
 Get translated point.
 
void GetTranslated (const TVector< Size, Element > &vector, TVector< Size, Element > &result)
 /overloaded
 
void ScaledCumulate (const TVector< Size, Element > &vector, Element scale)
 Add second vector scaled by specified factor.
 
bool IsNull (Element tolerance=I_BIG_EPSILON) const
 Check if this vector is null.
 
Element GetDotProduct (const TVector< Size, Element > &vector) const
 Return dot product of two vectors.
 
Element GetLength2 () const
 Return euclidian length square.
 
Element GetLength () const
 Return euclidian length.
 
Element GetDistance2 (const TVector< Size, Element > &vector) const
 Return distance square between two vectors.
 
Element GetDistance (const TVector< Size, Element > &vector) const
 Return distance between two vectors.
 
Element GetElementsSum () const
 Get simple sum of all elements.
 
bool Normalize (Element length=1.0)
 Normalize vector to specified length.
 
bool GetNormalized (TVector< Size, Element > &result, Element length=1.0) const
 Return normalized vector with the same direction and specified length.
 
void GetMinimal (const TVector< Size, Element > &vector, TVector< Size, Element > &result) const
 Get vector with minimal elements values.
 
void GetMaximal (const TVector< Size, Element > &vector, TVector< Size, Element > &result) const
 Get vector with maximal elements values.
 
bool Serialize (iser::IArchive &archive)
 Serialize this vector to specified archive.
 
bool operator== (const TVector< Size, Element > &vector) const
 
bool operator!= (const TVector< Size, Element > &vector) const
 
bool operator< (const TVector< Size, Element > &vector) const
 
bool operator> (const TVector< Size, Element > &vector) const
 
bool operator<= (const TVector< Size, Element > &vector) const
 
bool operator>= (const TVector< Size, Element > &vector) const
 
TVector< Size, Element > operator- () const
 
TVector< Size, Element > operator+ (const TVector< Size, Element > &vector) const
 
TVector< Size, Element > operator- (const TVector< Size, Element > &vector) const
 
TVector< Size, Element > operator* (Element scalar) const
 
TVector< Size, Element > operator/ (Element scalar) const
 
TVector< Size, Element > & operator= (const TVector< Size, Element > &vector)
 
TVector< Size, Element > & operator= (TVector< Size, Element > &&vector)
 
TVector< Size, Element > & operator+= (const TVector< Size, Element > &vector)
 
TVector< Size, Element > & operator-= (const TVector< Size, Element > &vector)
 
TVector< Size, Element > & operator*= (Element scalar)
 
TVector< Size, Element > & operator/= (Element scalar)
 
const Element & operator[] (int i) const
 
Element & operator[] (int i)
 

Static Public Member Functions

static int GetElementsCount ()
 Get number of elements.
 
static bool SetElementsCount (int count)
 Set number of elements.
 
static const TVector< Size, Element > & GetZero ()
 Get vector with all coordinates set to 0.
 

Protected Attributes

Elements m_elements
 

Detailed Description

template<int Size, class Element = double>
class imath::TVector< Size, Element >

Implementation of fixed-size mathematical vector with specified type of elements.

Definition at line 31 of file TVector.h.

Member Typedef Documentation

◆ Elements

template<int Size, class Element = double>
std::array<Element, Size> imath::TVector< Size, Element >::Elements

Definition at line 35 of file TVector.h.

◆ ElementType

template<int Size, class Element = double>
Element imath::TVector< Size, Element >::ElementType

Definition at line 34 of file TVector.h.

Constructor & Destructor Documentation

◆ TVector() [1/3]

template<int Size, class Element >
imath::TVector< Size, Element >::TVector ( )
inline

Create an uninitialized point.

Definition at line 230 of file TVector.h.

◆ TVector() [2/3]

template<int Size, class Element >
imath::TVector< Size, Element >::TVector ( const TVector< Size, Element > & vector)
inline

Copy constructor.

Definition at line 236 of file TVector.h.

References imath::TVector< Size, Element >::m_elements.

◆ TVector() [3/3]

template<int Size, class Element >
imath::TVector< Size, Element >::TVector ( TVector< Size, Element > && vector)
inlinenoexcept

Move constructor.

Definition at line 243 of file TVector.h.

Member Function Documentation

◆ Clear()

template<int Size, class Element >
void imath::TVector< Size, Element >::Clear ( )
inline

Set all coordinates to zero.

It makes the same as Clear() and is used for compatibility with other vector implementations.

Definition at line 291 of file TVector.h.

◆ GetDistance()

template<int Size, class Element >
Element imath::TVector< Size, Element >::GetDistance ( const TVector< Size, Element > & vector) const
inline

Return distance between two vectors.

Definition at line 387 of file TVector.h.

◆ GetDistance2()

template<int Size, class Element >
Element imath::TVector< Size, Element >::GetDistance2 ( const TVector< Size, Element > & vector) const
inline

Return distance square between two vectors.

Definition at line 380 of file TVector.h.

◆ GetDotProduct()

template<int Size, class Element >
Element imath::TVector< Size, Element >::GetDotProduct ( const TVector< Size, Element > & vector) const
inline

Return dot product of two vectors.

Definition at line 353 of file TVector.h.

References imath::TVector< Size, Element >::m_elements.

◆ GetElement()

◆ GetElementRef()

template<int Size, class Element >
Element & imath::TVector< Size, Element >::GetElementRef ( int i)
inline

Get reference to element at specified i.

Definition at line 259 of file TVector.h.

◆ GetElements()

template<int Size, class Element >
const TVector< Size, Element >::Elements & imath::TVector< Size, Element >::GetElements ( ) const
inline

Get read-only access to internal element container.

Definition at line 300 of file TVector.h.

◆ GetElementsCount()

template<int Size, class Element >
int imath::TVector< Size, Element >::GetElementsCount ( )
inlinestatic

Get number of elements.

Definition at line 628 of file TVector.h.

Referenced by icmm::qHash().

◆ GetElementsRef()

template<int Size, class Element >
TVector< Size, Element >::Elements & imath::TVector< Size, Element >::GetElementsRef ( )
inline

Get access to internal element container.

Definition at line 307 of file TVector.h.

◆ GetElementsSum()

template<int Size, class Element >
Element imath::TVector< Size, Element >::GetElementsSum ( ) const

Get simple sum of all elements.

Definition at line 651 of file TVector.h.

◆ GetLength()

template<int Size, class Element >
Element imath::TVector< Size, Element >::GetLength ( ) const
inline

Return euclidian length.

Definition at line 373 of file TVector.h.

◆ GetLength2()

template<int Size, class Element >
Element imath::TVector< Size, Element >::GetLength2 ( ) const
inline

Return euclidian length square.

Definition at line 366 of file TVector.h.

Referenced by i2d::CLine2d::GetAlphaAndCastDistance(), i2d::CLine2d::GetCastAlpha(), and ialgo::CHoughSpace2d::GetSpaceDistance2().

◆ GetMaximal()

template<int Size, class Element >
void imath::TVector< Size, Element >::GetMaximal ( const TVector< Size, Element > & vector,
TVector< Size, Element > & result ) const

Get vector with maximal elements values.

Definition at line 713 of file TVector.h.

References imath::TVector< Size, Element >::GetElement(), and imath::TVector< Size, Element >::SetElement().

◆ GetMinimal()

template<int Size, class Element >
void imath::TVector< Size, Element >::GetMinimal ( const TVector< Size, Element > & vector,
TVector< Size, Element > & result ) const

Get vector with minimal elements values.

Definition at line 704 of file TVector.h.

References imath::TVector< Size, Element >::GetElement(), and imath::TVector< Size, Element >::SetElement().

◆ GetNormalized()

template<int Size, class Element >
bool imath::TVector< Size, Element >::GetNormalized ( TVector< Size, Element > & result,
Element length = 1.0 ) const

Return normalized vector with the same direction and specified length.

Parameters
lengthnew vector length.
Returns
true, if normalization successed.

Definition at line 684 of file TVector.h.

References imath::TVector< Size, Element >::m_elements.

◆ GetTranslated() [1/2]

template<int Size, class Element >
TVector< Size, Element > imath::TVector< Size, Element >::GetTranslated ( const TVector< Size, Element > & vector)

Get translated point.

Definition at line 323 of file TVector.h.

◆ GetTranslated() [2/2]

template<int Size, class Element >
void imath::TVector< Size, Element >::GetTranslated ( const TVector< Size, Element > & vector,
TVector< Size, Element > & result )

/overloaded

Definition at line 330 of file TVector.h.

◆ GetZero()

template<int Size, class Element >
const TVector< Size, Element > & imath::TVector< Size, Element >::GetZero ( )
inlinestatic

Get vector with all coordinates set to 0.

Definition at line 642 of file TVector.h.

◆ IsNull()

template<int Size, class Element >
bool imath::TVector< Size, Element >::IsNull ( Element tolerance = I_BIG_EPSILON) const
inline

Check if this vector is null.

Definition at line 346 of file TVector.h.

◆ Normalize()

template<int Size, class Element >
bool imath::TVector< Size, Element >::Normalize ( Element length = 1.0)

Normalize vector to specified length.

Parameters
lengthnew vector length.
Returns
true, if normalization successed.

Definition at line 664 of file TVector.h.

◆ operator!=()

template<int Size, class Element >
bool imath::TVector< Size, Element >::operator!= ( const TVector< Size, Element > & vector) const
inline

Definition at line 408 of file TVector.h.

◆ operator*()

template<int Size, class Element >
TVector< Size, Element > imath::TVector< Size, Element >::operator* ( Element scalar) const
inline

Definition at line 580 of file TVector.h.

References imath::TVector< Size, Element >::m_elements.

◆ operator*=()

template<int Size, class Element >
TVector< Size, Element > & imath::TVector< Size, Element >::operator*= ( Element scalar)
inline

Definition at line 519 of file TVector.h.

◆ operator+()

template<int Size, class Element >
TVector< Size, Element > imath::TVector< Size, Element >::operator+ ( const TVector< Size, Element > & vector) const
inline

Definition at line 554 of file TVector.h.

References imath::TVector< Size, Element >::m_elements.

◆ operator+=()

template<int Size, class Element >
TVector< Size, Element > & imath::TVector< Size, Element >::operator+= ( const TVector< Size, Element > & vector)
inline

Definition at line 497 of file TVector.h.

References imath::TVector< Size, Element >::m_elements.

◆ operator-() [1/2]

template<int Size, class Element >
TVector< Size, Element > imath::TVector< Size, Element >::operator- ( ) const
inline

Definition at line 541 of file TVector.h.

References imath::TVector< Size, Element >::m_elements.

◆ operator-() [2/2]

template<int Size, class Element >
TVector< Size, Element > imath::TVector< Size, Element >::operator- ( const TVector< Size, Element > & vector) const
inline

Definition at line 567 of file TVector.h.

References imath::TVector< Size, Element >::m_elements.

◆ operator-=()

template<int Size, class Element >
TVector< Size, Element > & imath::TVector< Size, Element >::operator-= ( const TVector< Size, Element > & vector)
inline

Definition at line 508 of file TVector.h.

References imath::TVector< Size, Element >::m_elements.

◆ operator/()

template<int Size, class Element >
TVector< Size, Element > imath::TVector< Size, Element >::operator/ ( Element scalar) const
inline

Definition at line 593 of file TVector.h.

References imath::TVector< Size, Element >::m_elements.

◆ operator/=()

template<int Size, class Element >
TVector< Size, Element > & imath::TVector< Size, Element >::operator/= ( Element scalar)
inline

Definition at line 530 of file TVector.h.

◆ operator<()

template<int Size, class Element >
bool imath::TVector< Size, Element >::operator< ( const TVector< Size, Element > & vector) const

Definition at line 415 of file TVector.h.

References imath::TVector< Size, Element >::m_elements.

◆ operator<=()

template<int Size, class Element >
bool imath::TVector< Size, Element >::operator<= ( const TVector< Size, Element > & vector) const

Definition at line 447 of file TVector.h.

References imath::TVector< Size, Element >::m_elements.

◆ operator=() [1/2]

template<int Size, class Element >
TVector< Size, Element > & imath::TVector< Size, Element >::operator= ( const TVector< Size, Element > & vector)
inline

Definition at line 479 of file TVector.h.

References imath::TVector< Size, Element >::m_elements.

◆ operator=() [2/2]

template<int Size, class Element >
TVector< Size, Element > & imath::TVector< Size, Element >::operator= ( TVector< Size, Element > && vector)
inline

Definition at line 488 of file TVector.h.

◆ operator==()

template<int Size, class Element >
bool imath::TVector< Size, Element >::operator== ( const TVector< Size, Element > & vector) const
inline

Definition at line 396 of file TVector.h.

References imath::TVector< Size, Element >::m_elements.

◆ operator>()

template<int Size, class Element >
bool imath::TVector< Size, Element >::operator> ( const TVector< Size, Element > & vector) const

Definition at line 431 of file TVector.h.

References imath::TVector< Size, Element >::m_elements.

◆ operator>=()

template<int Size, class Element >
bool imath::TVector< Size, Element >::operator>= ( const TVector< Size, Element > & vector) const

Definition at line 463 of file TVector.h.

References imath::TVector< Size, Element >::m_elements.

◆ operator[]() [1/2]

template<int Size, class Element >
Element & imath::TVector< Size, Element >::operator[] ( int i)

Definition at line 616 of file TVector.h.

◆ operator[]() [2/2]

template<int Size, class Element >
const Element & imath::TVector< Size, Element >::operator[] ( int i) const

Definition at line 606 of file TVector.h.

◆ Reset()

template<int Size, class Element >
void imath::TVector< Size, Element >::Reset ( )
inline

Set all coordinates to zero.

It makes the same as Clear() and is used for compatibility with other vector implementations.

Definition at line 282 of file TVector.h.

◆ ScaledCumulate()

template<int Size, class Element >
void imath::TVector< Size, Element >::ScaledCumulate ( const TVector< Size, Element > & vector,
Element scale )
inline

Add second vector scaled by specified factor.

It is equal of Translate(vector * scale) but can be faster implemented.

Definition at line 337 of file TVector.h.

References imath::TVector< Size, Element >::m_elements.

◆ Serialize()

template<int Size, class Element >
bool imath::TVector< Size, Element >::Serialize ( iser::IArchive & archive)

Serialize this vector to specified archive.

Definition at line 722 of file TVector.h.

References iser::IArchive::Process().

◆ SetAllElements()

template<int Size, class Element >
void imath::TVector< Size, Element >::SetAllElements ( const Element & value)
inline

Set some value to all elements.

Definition at line 273 of file TVector.h.

◆ SetElement()

◆ SetElementsCount()

template<int Size, class Element >
bool imath::TVector< Size, Element >::SetElementsCount ( int count)
inlinestatic

Set number of elements.

This method is provided for template implementations.

Parameters
countnumber of elements.
Returns
true, if the number of set elements equals template parameter.

Definition at line 635 of file TVector.h.

◆ Translate()

template<int Size, class Element >
void imath::TVector< Size, Element >::Translate ( const TVector< Size, Element > & vector)
inline

Translate the point.

Definition at line 314 of file TVector.h.

References imath::TVector< Size, Element >::m_elements.

Member Data Documentation

◆ m_elements


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

© Witold Gantzke and Kirill Lepskiy