ICF 3.1.1.10
Technical documentation of ICF Libraries
imath::CVarVector Class Reference

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

#include <CVarVector.h>

Inheritance diagram for imath::CVarVector:
Collaboration diagram for imath::CVarVector:

Public Types

typedef std::vector< double > Elements
 

Public Member Functions

 CVarVector ()
 Create the vector without components.
 
 CVarVector (int componentsCount, double value=0)
 Create vector and initialize number of components.
 
template<typename iterator >
 CVarVector (iterator beginIter, iterator endIter)
 Constructor with iterators.
 
 CVarVector (const CVarVector &vector)
 Copy constructor.
 
template<int Size>
 CVarVector (const TVector< Size, double > &vector)
 
bool IsEmpty () const
 Get true, if the element ist is empty.
 
int GetElementsCount () const
 Get number of elements.
 
bool SetElementsCount (int count, double value=0)
 Set number of elements.
 
double GetElement (int index) const
 Get element at specified index.
 
double & GetElementRef (int index)
 Get reference to element at specified index.
 
void SetElement (int index, double value)
 Set element at specified index.
 
void SetAllElements (double value)
 Set some value to all elements.
 
void Reset ()
 Set size to zero.
 
void Reset (int elementsCount, double value)
 Set number of elements and set all elements to specified value.
 
void Clear ()
 Set all coordinates to zero.
 
void SetElementsFrom (const CVarVector &vector, double expansionValue=0)
 Set elements from other vector without resizing.
 
const Elements & GetElements () const
 Get read-only access to internal element container.
 
Elements & GetElementsRef ()
 Get access to internal element container.
 
bool EnsureElementsCount (int count, double value=0)
 Ensure, that number of elements is at least the specified value.
 
void Translate (const CVarVector &vector)
 Translate the point.
 
CVarVector GetTranslated (const CVarVector &vector)
 Get translated point.
 
void GetTranslated (const CVarVector &vector, CVarVector &result)
 /overloaded
 
void ScaledCumulate (const CVarVector &vector, double scale)
 Add second vector scaled by specified factor.
 
bool IsNull (double tolerance=I_BIG_EPSILON) const
 Check if this vector is null.
 
double GetDotProduct (const CVarVector &vector) const
 Return dot product of two vectors.
 
double GetLength2 () const
 Return euclidean length square.
 
double GetLength () const
 Return euclidian length.
 
double GetDistance2 (const CVarVector &vector) const
 Return distance square between two vectors.
 
double GetDistance (const CVarVector &vector) const
 Return distance between two vectors.
 
double GetElementsSum () const
 Get simple sum of all elements.
 
bool Normalize (double length=1.0)
 Normalize vector to specified length.
 
bool GetNormalized (CVarVector &result, double length=1.0) const
 Return normalized vector with the same direction and specified length.
 
void GetMinimal (const CVarVector &vector, CVarVector &result) const
 Get vector with minimal elements values.
 
void GetMaximal (const CVarVector &vector, CVarVector &result) const
 Get vector with maximal elements values.
 
bool Serialize (iser::IArchive &archive)
 Serialize this vector to specified archive.
 
bool operator== (const CVarVector &vector) const
 
bool operator!= (const CVarVector &vector) const
 
bool operator< (const CVarVector &vector) const
 
bool operator> (const CVarVector &vector) const
 
bool operator<= (const CVarVector &vector) const
 
bool operator>= (const CVarVector &vector) const
 
CVarVector operator- () const
 
CVarVector operator+ (const CVarVector &vector) const
 
CVarVector operator- (const CVarVector &vector) const
 
CVarVector operator* (double scalar) const
 
CVarVector operator/ (double scalar) const
 
CVarVector & operator+= (const CVarVector &vector)
 
CVarVector & operator-= (const CVarVector &vector)
 
CVarVector & operator*= (double scalar)
 
CVarVector & operator/= (double scalar)
 
CVarVector & operator= (const CVarVector &vector)
 
double operator[] (int i) const
 
double & operator[] (int i)
 

Detailed Description

Simple implementation of variable-size vector.

Definition at line 35 of file CVarVector.h.

Member Typedef Documentation

◆ Elements

std::vector<double> imath::CVarVector::Elements

Definition at line 38 of file CVarVector.h.

Constructor & Destructor Documentation

◆ CVarVector() [1/5]

imath::CVarVector::CVarVector ( )
inline

Create the vector without components.

Definition at line 252 of file CVarVector.h.

◆ CVarVector() [2/5]

imath::CVarVector::CVarVector ( int componentsCount,
double value = 0 )
inlineexplicit

Create vector and initialize number of components.

Definition at line 257 of file CVarVector.h.

◆ CVarVector() [3/5]

template<typename iterator >
imath::CVarVector::CVarVector ( iterator beginIter,
iterator endIter )
inline

Constructor with iterators.

Definition at line 270 of file CVarVector.h.

◆ CVarVector() [4/5]

imath::CVarVector::CVarVector ( const CVarVector & vector)
inline

Copy constructor.

Definition at line 263 of file CVarVector.h.

◆ CVarVector() [5/5]

template<int Size>
imath::CVarVector::CVarVector ( const TVector< Size, double > & vector)

Definition at line 674 of file CVarVector.h.

Member Function Documentation

◆ Clear()

void imath::CVarVector::Clear ( )
inline

Set all coordinates to zero.

Definition at line 339 of file CVarVector.h.

References GetElementsCount().

◆ EnsureElementsCount()

bool imath::CVarVector::EnsureElementsCount ( int count,
double value = 0 )

Ensure, that number of elements is at least the specified value.

It resize the vector if the new size is bigger than the current one.

Returns
always true, this value is provided for template implementations.

◆ GetDistance()

double imath::CVarVector::GetDistance ( const CVarVector & vector) const
inline

Return distance between two vectors.

Definition at line 443 of file CVarVector.h.

References GetDistance2().

Referenced by icmm::CVarColor::IsSimilar().

◆ GetDistance2()

double imath::CVarVector::GetDistance2 ( const CVarVector & vector) const
inline

Return distance square between two vectors.

Definition at line 437 of file CVarVector.h.

Referenced by GetDistance().

◆ GetDotProduct()

double imath::CVarVector::GetDotProduct ( const CVarVector & vector) const
inline

Return dot product of two vectors.

Definition at line 410 of file CVarVector.h.

References GetElementsCount().

Referenced by GetLength2().

◆ GetElement()

double imath::CVarVector::GetElement ( int index) const
inline

Get element at specified index.

Definition at line 306 of file CVarVector.h.

References operator[]().

Referenced by icmm::CVarColor::IsNormalized(), icmm::CVarColor::operator*(), and icmm::CVarColor::operator/().

◆ GetElementRef()

double & imath::CVarVector::GetElementRef ( int index)
inline

Get reference to element at specified index.

Definition at line 312 of file CVarVector.h.

References operator[]().

◆ GetElements()

const CVarVector::Elements & imath::CVarVector::GetElements ( ) const
inline

Get read-only access to internal element container.

Definition at line 358 of file CVarVector.h.

◆ GetElementsCount()

◆ GetElementsRef()

CVarVector::Elements & imath::CVarVector::GetElementsRef ( )
inline

Get access to internal element container.

Definition at line 364 of file CVarVector.h.

◆ GetElementsSum()

double imath::CVarVector::GetElementsSum ( ) const

Get simple sum of all elements.

◆ GetLength()

double imath::CVarVector::GetLength ( ) const
inline

Return euclidian length.

Definition at line 431 of file CVarVector.h.

References GetLength2().

◆ GetLength2()

double imath::CVarVector::GetLength2 ( ) const
inline

Return euclidean length square.

Definition at line 425 of file CVarVector.h.

References GetDotProduct().

Referenced by GetLength(), and IsNull().

◆ GetMaximal()

void imath::CVarVector::GetMaximal ( const CVarVector & vector,
CVarVector & result ) const

Get vector with maximal elements values.

◆ GetMinimal()

void imath::CVarVector::GetMinimal ( const CVarVector & vector,
CVarVector & result ) const

Get vector with minimal elements values.

◆ GetNormalized()

bool imath::CVarVector::GetNormalized ( CVarVector & result,
double length = 1.0 ) const

Return normalized vector with the same direction and specified length.

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

◆ GetTranslated() [1/2]

CVarVector imath::CVarVector::GetTranslated ( const CVarVector & vector)
inline

Get translated point.

Definition at line 381 of file CVarVector.h.

◆ GetTranslated() [2/2]

void imath::CVarVector::GetTranslated ( const CVarVector & vector,
CVarVector & result )
inline

/overloaded

Definition at line 387 of file CVarVector.h.

◆ IsEmpty()

bool imath::CVarVector::IsEmpty ( ) const
inline

Get true, if the element ist is empty.

Definition at line 278 of file CVarVector.h.

◆ IsNull()

bool imath::CVarVector::IsNull ( double tolerance = I_BIG_EPSILON) const
inline

Check if this vector is null.

Definition at line 404 of file CVarVector.h.

References GetLength2().

◆ Normalize()

bool imath::CVarVector::Normalize ( double length = 1.0)

Normalize vector to specified length.

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

◆ operator!=()

bool imath::CVarVector::operator!= ( const CVarVector & vector) const
inline

Definition at line 468 of file CVarVector.h.

References operator==().

◆ operator*()

CVarVector imath::CVarVector::operator* ( double scalar) const
inline

Definition at line 633 of file CVarVector.h.

◆ operator*=()

CVarVector & imath::CVarVector::operator*= ( double scalar)
inline

Definition at line 568 of file CVarVector.h.

References GetElementsCount().

Referenced by icmm::CVarColor::operator*=().

◆ operator+()

CVarVector imath::CVarVector::operator+ ( const CVarVector & vector) const
inline

Definition at line 613 of file CVarVector.h.

◆ operator+=()

CVarVector & imath::CVarVector::operator+= ( const CVarVector & vector)
inline

Definition at line 542 of file CVarVector.h.

References GetElementsCount().

◆ operator-() [1/2]

CVarVector imath::CVarVector::operator- ( ) const
inline

Definition at line 599 of file CVarVector.h.

References GetElementsCount().

◆ operator-() [2/2]

CVarVector imath::CVarVector::operator- ( const CVarVector & vector) const
inline

Definition at line 623 of file CVarVector.h.

◆ operator-=()

CVarVector & imath::CVarVector::operator-= ( const CVarVector & vector)
inline

Definition at line 555 of file CVarVector.h.

References GetElementsCount().

◆ operator/()

CVarVector imath::CVarVector::operator/ ( double scalar) const
inline

Definition at line 643 of file CVarVector.h.

◆ operator/=()

CVarVector & imath::CVarVector::operator/= ( double scalar)
inline

Definition at line 579 of file CVarVector.h.

References GetElementsCount().

Referenced by icmm::CVarColor::operator/=().

◆ operator<()

bool imath::CVarVector::operator< ( const CVarVector & vector) const
inline

Definition at line 474 of file CVarVector.h.

◆ operator<=()

bool imath::CVarVector::operator<= ( const CVarVector & vector) const
inline

Definition at line 508 of file CVarVector.h.

◆ operator=()

CVarVector & imath::CVarVector::operator= ( const CVarVector & vector)
inline

Definition at line 590 of file CVarVector.h.

References GetElementsCount(), SetElementsCount(), and SetElementsFrom().

◆ operator==()

bool imath::CVarVector::operator== ( const CVarVector & vector) const
inline

Definition at line 451 of file CVarVector.h.

Referenced by operator!=().

◆ operator>()

bool imath::CVarVector::operator> ( const CVarVector & vector) const
inline

Definition at line 491 of file CVarVector.h.

◆ operator>=()

bool imath::CVarVector::operator>= ( const CVarVector & vector) const
inline

Definition at line 525 of file CVarVector.h.

◆ operator[]() [1/2]

double & imath::CVarVector::operator[] ( int i)
inline

Definition at line 662 of file CVarVector.h.

References GetElementsCount().

◆ operator[]() [2/2]

double imath::CVarVector::operator[] ( int i) const
inline

Definition at line 653 of file CVarVector.h.

References GetElementsCount().

Referenced by GetElement(), GetElementRef(), and SetElement().

◆ Reset() [1/2]

void imath::CVarVector::Reset ( )
inline

Set size to zero.

Definition at line 333 of file CVarVector.h.

◆ Reset() [2/2]

void imath::CVarVector::Reset ( int elementsCount,
double value )
inline

Set number of elements and set all elements to specified value.

Definition at line 348 of file CVarVector.h.

◆ ScaledCumulate()

void imath::CVarVector::ScaledCumulate ( const CVarVector & vector,
double scale )
inline

Add second vector scaled by specified factor.

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

Definition at line 393 of file CVarVector.h.

References GetElementsCount().

◆ Serialize()

bool imath::CVarVector::Serialize ( iser::IArchive & archive)

Serialize this vector to specified archive.

◆ SetAllElements()

void imath::CVarVector::SetAllElements ( double value)
inline

Set some value to all elements.

Definition at line 324 of file CVarVector.h.

References GetElementsCount().

◆ SetElement()

void imath::CVarVector::SetElement ( int index,
double value )
inline

Set element at specified index.

Definition at line 318 of file CVarVector.h.

References operator[]().

Referenced by icmm::CVarColor::operator*(), and icmm::CVarColor::operator/().

◆ SetElementsCount()

bool imath::CVarVector::SetElementsCount ( int count,
double value = 0 )
inline

Set number of elements.

Returns
always true, this value is provided for template implementations.

Definition at line 290 of file CVarVector.h.

Referenced by operator=().

◆ SetElementsFrom()

void imath::CVarVector::SetElementsFrom ( const CVarVector & vector,
double expansionValue = 0 )

Set elements 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.

Referenced by operator=().

◆ Translate()

void imath::CVarVector::Translate ( const CVarVector & vector)
inline

Translate the point.

Definition at line 370 of file CVarVector.h.

References GetElementsCount().


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

© Witold Gantzke and Kirill Lepskiy