Public Types | Public Member Functions | Protected Attributes | List of all members
imath::TFastVector< MaxSize, Element > Class Template Reference

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

#include <TFastVector.h>

Public Types

enum  { MAX_ELEMENTS_COUNT = MaxSize }
 
typedef Element ElementType
 

Public Member Functions

 TFastVector ()
 Create an uninitialized point. More...
 
 TFastVector (int componentsCount, const Element &value=Element())
 Create vector and initialize number of components. More...
 
 TFastVector (const TFastVector< MaxSize, Element > &vector)
 Copy constructor. More...
 
template<int Size>
 TFastVector (const imath::TVector< Size, Element > &vector)
 
int GetElementsCount () const
 Get number of elements. More...
 
bool SetElementsCount (int count, const Element &value=Element())
 Set number of elements. More...
 
bool EnsureElementsCount (int count, const Element &value=Element())
 Ensure, that number of elements vector cannot be smaller that some value. More...
 
const Element & GetElement (int i) const
 Get element at specified i. More...
 
Element & GetElementRef (int i)
 Get reference to element at specified i. More...
 
void SetElement (int i, const Element &value)
 Set element at specified i. More...
 
void Clear ()
 Set all coordinates to zero. More...
 
void SetElementsFrom (const TFastVector &vector, const Element &expansionValue=Element())
 Set elemenents from other vector without resizing. More...
 
void Translate (const TFastVector< MaxSize, Element > &vector)
 Translate the point. More...
 
TFastVector< MaxSize, Element > GetTranslated (const TFastVector< MaxSize, Element > &vector)
 Get translated point. More...
 
void GetTranslated (const TFastVector< MaxSize, Element > &vector, TFastVector< MaxSize, Element > &result)
 /overloaded More...
 
void ScaledCumulate (const TFastVector< MaxSize, Element > &vector, Element scale)
 Add second vector scaled by specified factor. More...
 
bool IsNull (Element tolerance=I_BIG_EPSILON) const
 Check if this vector is null. More...
 
Element GetDotProduct (const TFastVector< MaxSize, Element > &vector) const
 Return dot product of two vectors. More...
 
Element GetLength2 () const
 Return euclidian length square. More...
 
Element GetLength () const
 Return euclidian length. More...
 
Element GetDistance2 (const TFastVector< MaxSize, Element > &vector) const
 Return distance square between two vectors. More...
 
Element GetDistance (const TFastVector< MaxSize, Element > &vector) const
 Return distance between two vectors. More...
 
Element GetElementsSum () const
 Get simple sum of all elements. More...
 
bool Normalize (Element length=1.0)
 Normalize vector to specified length. More...
 
bool GetNormalized (TFastVector< MaxSize, Element > &result, Element length=1.0) const
 Return normalized vector with the same direction and specified length. More...
 
void GetMinimal (const TFastVector< MaxSize, Element > &vector, TFastVector< MaxSize, Element > &result) const
 Get vector with minimal elements values. More...
 
void GetMaximal (const TFastVector< MaxSize, Element > &vector, TFastVector< MaxSize, Element > &result) const
 Get vector with maximal elements values. More...
 
bool Serialize (iser::IArchive &archive)
 Serialize this vector to specified archive. More...
 
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 23 of file TFastVector.h.

Member Typedef Documentation

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

Definition at line 26 of file TFastVector.h.

Member Enumeration Documentation

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

Definition at line 28 of file TFastVector.h.

Constructor & Destructor Documentation

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

Create an uninitialized point.

Definition at line 221 of file TFastVector.h.

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 228 of file TFastVector.h.

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

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

Definition at line 48 of file TFastVector.h.

Member Function Documentation

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

Set all coordinates to zero.

Definition at line 323 of file TFastVector.h.

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 273 of file TFastVector.h.

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 438 of file TFastVector.h.

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 431 of file TFastVector.h.

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 403 of file TFastVector.h.

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

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

Get element at specified i.

Definition at line 293 of file TFastVector.h.

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

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

Get reference to element at specified i.

Definition at line 303 of file TFastVector.h.

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

Get simple sum of all elements.

Definition at line 704 of file TFastVector.h.

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

Return euclidian length.

Definition at line 424 of file TFastVector.h.

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

Return euclidian length square.

Definition at line 417 of file TFastVector.h.

template<int MaxSize, class Element>
void imath::TFastVector< MaxSize, Element >::GetMaximal ( const TFastVector< MaxSize, Element > &  vector,
TFastVector< MaxSize, Element > &  result 
) const
template<int MaxSize, class Element>
void imath::TFastVector< MaxSize, Element >::GetMinimal ( const TFastVector< MaxSize, Element > &  vector,
TFastVector< MaxSize, Element > &  result 
) const
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 737 of file TFastVector.h.

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

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 380 of file TFastVector.h.

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

/overloaded

Definition at line 387 of file TFastVector.h.

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

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 396 of file TFastVector.h.

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 717 of file TFastVector.h.

References I_BIG_EPSILON.

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

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

Definition at line 464 of file TFastVector.h.

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

Definition at line 660 of file TFastVector.h.

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

Definition at line 603 of file TFastVector.h.

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

Definition at line 638 of file TFastVector.h.

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

Definition at line 625 of file TFastVector.h.

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

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

Definition at line 649 of file TFastVector.h.

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

Definition at line 671 of file TFastVector.h.

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

Definition at line 614 of file TFastVector.h.

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

Definition at line 682 of file TFastVector.h.

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

Definition at line 692 of file TFastVector.h.

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 342 of file TFastVector.h.

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

template<int MaxSize, class Element >
bool imath::TFastVector< MaxSize, Element >::Serialize ( iser::IArchive archive)
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 313 of file TFastVector.h.

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

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 255 of file TFastVector.h.

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

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 365 of file TFastVector.h.

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

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

Member Data Documentation

template<int MaxSize, class Element = double>
Element imath::TFastVector< MaxSize, Element >::m_elements[MaxSize]
protected
template<int MaxSize, class Element = double>
int imath::TFastVector< MaxSize, Element >::m_elementsCount
protected

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

© 2007-2017 Witold Gantzke and Kirill Lepskiy