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

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

#include <TVector.h>

Public Types

typedef Element ElementType
 
typedef Element Elements [Size]
 

Public Member Functions

 TVector ()
 Create an uninitialized point. More...
 
 TVector (const TVector< Size, Element > &vector)
 Copy constructor. 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 SetAllElements (const Element &value)
 Set some value to all elements. More...
 
void Reset ()
 Set all coordinates to zero. More...
 
void Clear ()
 Set all coordinates to zero. More...
 
const TVector< Size, Element >
::Elements
GetElements () const
 Get read-only access to internal element container. More...
 
TVector< Size, Element >
::Elements
GetElementsRef ()
 Get access to internal element container. More...
 
void Translate (const TVector< Size, Element > &vector)
 Translate the point. More...
 
TVector< Size, Element > GetTranslated (const TVector< Size, Element > &vector)
 Get translated point. More...
 
void GetTranslated (const TVector< Size, Element > &vector, TVector< Size, Element > &result)
 /overloaded More...
 
void ScaledCumulate (const TVector< Size, 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 TVector< Size, 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 TVector< Size, Element > &vector) const
 Return distance square between two vectors. More...
 
Element GetDistance (const TVector< Size, 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 (TVector< Size, Element > &result, Element length=1.0) const
 Return normalized vector with the same direction and specified length. More...
 
void GetMinimal (const TVector< Size, Element > &vector, TVector< Size, Element > &result) const
 Get vector with minimal elements values. More...
 
void GetMaximal (const TVector< Size, Element > &vector, TVector< Size, 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 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-= (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. More...
 
static bool SetElementsCount (int count)
 Set number of elements. More...
 
static const TVector< Size,
Element > & 
GetZero ()
 Get vector with all coordinates set to 0. More...
 

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 27 of file TVector.h.

Member Typedef Documentation

template<int Size, class Element = double>
typedef Element imath::TVector< Size, Element >::Elements[Size]

Definition at line 31 of file TVector.h.

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

Definition at line 30 of file TVector.h.

Constructor & Destructor Documentation

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

Create an uninitialized point.

Definition at line 220 of file TVector.h.

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

Copy constructor.

Definition at line 226 of file TVector.h.

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

Member Function Documentation

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 276 of file TVector.h.

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 372 of file TVector.h.

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

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 338 of file TVector.h.

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

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

Get reference to element at specified i.

Definition at line 244 of file TVector.h.

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 285 of file TVector.h.

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

Get number of elements.

Definition at line 595 of file TVector.h.

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

Get access to internal element container.

Definition at line 292 of file TVector.h.

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

Get simple sum of all elements.

Definition at line 618 of file TVector.h.

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

Return euclidian length.

Definition at line 358 of file TVector.h.

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

Return euclidian length square.

Definition at line 351 of file TVector.h.

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

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 680 of file TVector.h.

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

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 671 of file TVector.h.

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

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 651 of file TVector.h.

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

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

Get translated point.

Definition at line 308 of file TVector.h.

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

/overloaded

Definition at line 315 of file TVector.h.

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 609 of file TVector.h.

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 331 of file TVector.h.

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 631 of file TVector.h.

References I_BIG_EPSILON.

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

Definition at line 393 of file TVector.h.

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

Definition at line 547 of file TVector.h.

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

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

Definition at line 486 of file TVector.h.

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

Definition at line 521 of file TVector.h.

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

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

Definition at line 464 of file TVector.h.

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

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

Definition at line 508 of file TVector.h.

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

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

Definition at line 534 of file TVector.h.

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

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

Definition at line 475 of file TVector.h.

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

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

Definition at line 560 of file TVector.h.

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

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

Definition at line 497 of file TVector.h.

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

Definition at line 400 of file TVector.h.

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

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

Definition at line 432 of file TVector.h.

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

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

Definition at line 381 of file TVector.h.

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

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

Definition at line 416 of file TVector.h.

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

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

Definition at line 448 of file TVector.h.

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

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

Definition at line 573 of file TVector.h.

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

Definition at line 583 of file TVector.h.

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 267 of file TVector.h.

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 322 of file TVector.h.

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

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

Serialize this vector to specified archive.

Definition at line 689 of file TVector.h.

References iser::IArchive::Process().

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

Set some value to all elements.

Definition at line 258 of file TVector.h.

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

Set element at specified i.

Definition at line 251 of file TVector.h.

Referenced by imath::TVector< Size, Element >::GetMaximal(), and imath::TVector< Size, Element >::GetMinimal().

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 602 of file TVector.h.

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

Translate the point.

Definition at line 299 of file TVector.h.

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

Member Data Documentation

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

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

© 2007-2017 Witold Gantzke and Kirill Lepskiy