ICF 3.1.1.10
Technical documentation of ICF Libraries
imath::TFastVector< MaxSize, Element > Class Template Reference

Simple implementation of fixed-size vector. More...

#include <TFastVector.h>

Collaboration diagram for imath::TFastVector< MaxSize, Element >:

Public Types

enum  { MAX_ELEMENTS_COUNT = MaxSize }
 
typedef Element ElementType
 

Public Member Functions

 TFastVector ()
 Create an uninitialized point.
 
 TFastVector (int componentsCount, const Element &value=Element())
 Create vector and initialize number of components.
 
 TFastVector (const TFastVector< MaxSize, Element > &vector)
 Copy constructor.
 
template<int Size>
 TFastVector (const imath::TVector< Size, Element > &vector)
 
int GetElementsCount () const
 Get number of elements.
 
bool SetElementsCount (int count, const Element &value=Element())
 Set number of elements.
 
bool EnsureElementsCount (int count, const Element &value=Element())
 Ensure, that number of elements vector cannot be smaller that some value.
 
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 Clear ()
 Set all coordinates to zero.
 
void SetElementsFrom (const TFastVector &vector, const Element &expansionValue=Element())
 Set elemenents from other vector without resizing.
 
void Translate (const TFastVector< MaxSize, Element > &vector)
 Translate the point.
 
TFastVector< MaxSize, Element > GetTranslated (const TFastVector< MaxSize, Element > &vector)
 Get translated point.
 
void GetTranslated (const TFastVector< MaxSize, Element > &vector, TFastVector< MaxSize, Element > &result)
 /overloaded
 
void ScaledCumulate (const TFastVector< MaxSize, 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 TFastVector< MaxSize, 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 TFastVector< MaxSize, Element > &vector) const
 Return distance square between two vectors.
 
Element GetDistance (const TFastVector< MaxSize, 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 (TFastVector< MaxSize, Element > &result, Element length=1.0) const
 Return normalized vector with the same direction and specified length.
 
void GetMinimal (const TFastVector< MaxSize, Element > &vector, TFastVector< MaxSize, Element > &result) const
 Get vector with minimal elements values.
 
void GetMaximal (const TFastVector< MaxSize, Element > &vector, TFastVector< MaxSize, Element > &result) const
 Get vector with maximal elements values.
 
bool Serialize (iser::IArchive &archive)
 Serialize this vector to specified archive.
 
bool operator== (const TFastVector< MaxSize, Element > &vector) const
 
bool operator!= (const TFastVector< MaxSize, Element > &vector) const
 
bool operator< (const TFastVector< MaxSize, Element > &vector) const
 
bool operator> (const TFastVector< MaxSize, Element > &vector) const
 
bool operator<= (const TFastVector< MaxSize, Element > &vector) const
 
bool operator>= (const TFastVector< MaxSize, Element > &vector) const
 
TFastVector< MaxSize, Element > operator- () const
 
TFastVector< MaxSize, Element > operator+ (const TFastVector< MaxSize, Element > &vector) const
 
TFastVector< MaxSize, Element > operator- (const TFastVector< MaxSize, Element > &vector) const
 
TFastVector< MaxSize, Element > operator* (Element scalar) const
 
TFastVector< MaxSize, Element > operator/ (Element scalar) const
 
TFastVector< MaxSize, Element > & operator= (const TFastVector< MaxSize, Element > &vector)
 
TFastVector< MaxSize, Element > & operator+= (const TFastVector< MaxSize, Element > &vector)
 
TFastVector< MaxSize, Element > & operator-= (const TFastVector< MaxSize, Element > &vector)
 
TFastVector< MaxSize, Element > & operator*= (Element scalar)
 
TFastVector< MaxSize, Element > & operator/= (Element scalar)
 
const Element & operator[] (int i) const
 
Element & operator[] (int i)
 

Protected Attributes

Element m_elements [MaxSize]
 
int m_elementsCount
 

Detailed Description

template<int MaxSize, class Element = double>
class imath::TFastVector< MaxSize, Element >

Simple implementation of fixed-size vector.

Definition at line 28 of file TFastVector.h.

Member Typedef Documentation

◆ ElementType

template<int MaxSize, class Element = double>
Element imath::TFastVector< MaxSize, Element >::ElementType

Definition at line 31 of file TFastVector.h.

Member Enumeration Documentation

◆ anonymous enum

template<int MaxSize, class Element = double>
anonymous enum
Enumerator
MAX_ELEMENTS_COUNT 

Definition at line 33 of file TFastVector.h.

Constructor & Destructor Documentation

◆ TFastVector() [1/4]

template<int MaxSize, class Element >
imath::TFastVector< MaxSize, Element >::TFastVector ( )
inline

Create an uninitialized point.

Definition at line 226 of file TFastVector.h.

◆ TFastVector() [2/4]

template<int MaxSize, class Element >
imath::TFastVector< MaxSize, Element >::TFastVector ( int componentsCount,
const Element & value = Element() )
inlineexplicit

Create vector and initialize number of components.

Definition at line 233 of file TFastVector.h.

References imath::TFastVector< MaxSize, Element >::m_elements, and imath::TFastVector< MaxSize, Element >::m_elementsCount.

◆ TFastVector() [3/4]

template<int MaxSize, class Element >
imath::TFastVector< MaxSize, Element >::TFastVector ( const TFastVector< MaxSize, Element > & vector)
inline

◆ TFastVector() [4/4]

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

Definition at line 53 of file TFastVector.h.

References imath::TFastVector< MaxSize, Element >::m_elements.

Member Function Documentation

◆ Clear()

template<int MaxSize, class Element >
void imath::TFastVector< MaxSize, Element >::Clear ( )
inline

Set all coordinates to zero.

Definition at line 328 of file TFastVector.h.

◆ EnsureElementsCount()

template<int MaxSize, class Element >
bool imath::TFastVector< MaxSize, Element >::EnsureElementsCount ( int count,
const Element & value = Element() )
inline

Ensure, that number of elements vector cannot be smaller that some value.

If number of elements was bigger or equal to specified value, it does nothing. In other case, number of elements will be set.

Parameters
countnumber of elements.
Returns
true, if the number of set is not greater than template parameter MaxSize.

Definition at line 278 of file TFastVector.h.

◆ GetDistance()

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

Return distance between two vectors.

Definition at line 443 of file TFastVector.h.

◆ GetDistance2()

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

Return distance square between two vectors.

Definition at line 436 of file TFastVector.h.

◆ GetDotProduct()

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

Return dot product of two vectors.

Definition at line 408 of file TFastVector.h.

References imath::TFastVector< MaxSize, Element >::m_elements, and imath::TFastVector< MaxSize, Element >::m_elementsCount.

◆ GetElement()

template<int MaxSize, class Element >
const Element & imath::TFastVector< MaxSize, Element >::GetElement ( int i) const
inline

Get element at specified i.

Definition at line 298 of file TFastVector.h.

Referenced by imath::TFastVector< MaxSize, Element >::GetMaximal(), and imath::TFastVector< MaxSize, Element >::GetMinimal().

◆ GetElementRef()

template<int MaxSize, class Element >
Element & imath::TFastVector< MaxSize, Element >::GetElementRef ( int i)
inline

Get reference to element at specified i.

Definition at line 308 of file TFastVector.h.

◆ GetElementsCount()

◆ GetElementsSum()

template<int MaxSize, class Element >
Element imath::TFastVector< MaxSize, Element >::GetElementsSum ( ) const

Get simple sum of all elements.

Definition at line 709 of file TFastVector.h.

◆ GetLength()

template<int MaxSize, class Element >
Element imath::TFastVector< MaxSize, Element >::GetLength ( ) const
inline

Return euclidian length.

Definition at line 429 of file TFastVector.h.

◆ GetLength2()

template<int MaxSize, class Element >
Element imath::TFastVector< MaxSize, Element >::GetLength2 ( ) const
inline

Return euclidian length square.

Definition at line 422 of file TFastVector.h.

◆ GetMaximal()

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

◆ GetMinimal()

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

◆ GetNormalized()

template<int MaxSize, class Element >
bool imath::TFastVector< MaxSize, Element >::GetNormalized ( TFastVector< MaxSize, 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 742 of file TFastVector.h.

References imath::TFastVector< MaxSize, Element >::Normalize().

◆ GetTranslated() [1/2]

template<int MaxSize, class Element >
TFastVector< MaxSize, Element > imath::TFastVector< MaxSize, Element >::GetTranslated ( const TFastVector< MaxSize, Element > & vector)
inline

Get translated point.

Definition at line 385 of file TFastVector.h.

◆ GetTranslated() [2/2]

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

/overloaded

Definition at line 392 of file TFastVector.h.

References imath::TFastVector< MaxSize, Element >::Translate().

◆ IsNull()

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

Check if this vector is null.

Definition at line 401 of file TFastVector.h.

◆ Normalize()

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

Normalize vector to specified length.

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

Definition at line 722 of file TFastVector.h.

Referenced by imath::TFastVector< MaxSize, Element >::GetNormalized().

◆ operator!=()

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

Definition at line 469 of file TFastVector.h.

◆ operator*()

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

Definition at line 665 of file TFastVector.h.

◆ operator*=()

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

Definition at line 608 of file TFastVector.h.

◆ operator+()

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

Definition at line 643 of file TFastVector.h.

◆ operator+=()

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

◆ operator-() [1/2]

template<int MaxSize, class Element >
TFastVector< MaxSize, Element > imath::TFastVector< MaxSize, Element >::operator- ( ) const
inline

Definition at line 630 of file TFastVector.h.

References imath::TFastVector< MaxSize, Element >::m_elements.

◆ operator-() [2/2]

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

Definition at line 654 of file TFastVector.h.

◆ operator-=()

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

◆ operator/()

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

Definition at line 676 of file TFastVector.h.

◆ operator/=()

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

Definition at line 619 of file TFastVector.h.

◆ operator<()

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

◆ operator<=()

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

◆ operator=()

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

◆ operator==()

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

◆ operator>()

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

◆ operator>=()

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

◆ operator[]() [1/2]

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

Definition at line 697 of file TFastVector.h.

◆ operator[]() [2/2]

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

Definition at line 687 of file TFastVector.h.

◆ ScaledCumulate()

template<int MaxSize, class Element >
void imath::TFastVector< MaxSize, Element >::ScaledCumulate ( const TFastVector< MaxSize, 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 347 of file TFastVector.h.

References imath::TFastVector< MaxSize, Element >::m_elements, and imath::TFastVector< MaxSize, Element >::m_elementsCount.

◆ Serialize()

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

Serialize this vector to specified archive.

Definition at line 777 of file TFastVector.h.

References iser::CArchiveTag::Leaf, iser::CArchiveTag::Multiple, iser::IArchive::ProcessAnyList(), and iser::IArchive::ProcessLeaf().

◆ SetElement()

template<int MaxSize, class Element >
void imath::TFastVector< MaxSize, Element >::SetElement ( int i,
const Element & value )
inline

Set element at specified i.

Definition at line 318 of file TFastVector.h.

Referenced by imath::TFastVector< MaxSize, Element >::GetMaximal(), and imath::TFastVector< MaxSize, Element >::GetMinimal().

◆ SetElementsCount()

template<int MaxSize, class Element >
bool imath::TFastVector< MaxSize, Element >::SetElementsCount ( int count,
const Element & value = Element() )
inline

Set number of elements.

Parameters
countnumber of elements.
Returns
true, if the number of set is not greater than template parameter MaxSize.

Definition at line 260 of file TFastVector.h.

Referenced by imath::TFastVector< MaxSize, Element >::GetMaximal(), and imath::TFastVector< MaxSize, Element >::GetMinimal().

◆ SetElementsFrom()

template<int MaxSize, class Element >
void imath::TFastVector< MaxSize, Element >::SetElementsFrom ( const TFastVector< MaxSize, Element > & vector,
const Element & expansionValue = Element() )

Set elemenents from other vector without resizing.

Parameters
vectorsource of element values will be copied.
expansionValueif actual vector has more elements than vector, rest will be replaced with this value.

Definition at line 370 of file TFastVector.h.

References imath::TFastVector< MaxSize, Element >::m_elementsCount.

◆ Translate()

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

Member Data Documentation

◆ m_elements

◆ m_elementsCount


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

© Witold Gantzke and Kirill Lepskiy