Public Types | Public Member Functions | List of all members
imath::CVarVector Class Reference

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

#include <CVarVector.h>

Inheritance diagram for imath::CVarVector:
icmm::CVarColor

Public Types

typedef std::vector< double > Elements
 

Public Member Functions

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

Detailed Description

Simple implementation of variable-size vector.

Definition at line 34 of file CVarVector.h.

Member Typedef Documentation

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

Definition at line 37 of file CVarVector.h.

Constructor & Destructor Documentation

imath::CVarVector::CVarVector ( )
inline

Create the vector without components.

Definition at line 251 of file CVarVector.h.

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

Create vector and initialize number of components.

Definition at line 256 of file CVarVector.h.

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

Constructor with iterators.

Definition at line 269 of file CVarVector.h.

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

Copy constructor.

Definition at line 262 of file CVarVector.h.

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

Definition at line 673 of file CVarVector.h.

Member Function Documentation

void imath::CVarVector::Clear ( )
inline

Set all coordinates to zero.

Definition at line 338 of file CVarVector.h.

References GetElementsCount().

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.
double imath::CVarVector::GetDistance ( const CVarVector vector) const
inline

Return distance between two vectors.

Definition at line 442 of file CVarVector.h.

References GetDistance2().

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

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

Return distance square between two vectors.

Definition at line 436 of file CVarVector.h.

Referenced by GetDistance().

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

Return dot product of two vectors.

Definition at line 409 of file CVarVector.h.

References GetElementsCount().

Referenced by GetLength2().

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

Get element at specified index.

Definition at line 305 of file CVarVector.h.

References operator[]().

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

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

Get reference to element at specified index.

Definition at line 311 of file CVarVector.h.

References operator[]().

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

Get read-only access to internal element container.

Definition at line 357 of file CVarVector.h.

int imath::CVarVector::GetElementsCount ( ) const
inline
CVarVector::Elements & imath::CVarVector::GetElementsRef ( )
inline

Get access to internal element container.

Definition at line 363 of file CVarVector.h.

double imath::CVarVector::GetElementsSum ( ) const

Get simple sum of all elements.

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

Return euclidian length.

Definition at line 430 of file CVarVector.h.

References GetLength2().

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

Return euclidean length square.

Definition at line 424 of file CVarVector.h.

References GetDotProduct().

Referenced by GetLength(), and IsNull().

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

Get vector with maximal elements values.

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

Get vector with minimal elements values.

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.
CVarVector imath::CVarVector::GetTranslated ( const CVarVector vector)
inline

Get translated point.

Definition at line 380 of file CVarVector.h.

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

/overloaded

Definition at line 386 of file CVarVector.h.

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

Get true, if the element ist is empty.

Definition at line 277 of file CVarVector.h.

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

Check if this vector is null.

Definition at line 403 of file CVarVector.h.

References GetLength2().

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

Normalize vector to specified length.

Parameters
lengthnew vector length.
Returns
true, if normalization successed.
bool imath::CVarVector::operator!= ( const CVarVector vector) const
inline

Definition at line 467 of file CVarVector.h.

References operator==().

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

Definition at line 632 of file CVarVector.h.

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

Definition at line 567 of file CVarVector.h.

References GetElementsCount().

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

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

Definition at line 612 of file CVarVector.h.

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

Definition at line 541 of file CVarVector.h.

References GetElementsCount().

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

Definition at line 598 of file CVarVector.h.

References GetElementsCount().

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

Definition at line 622 of file CVarVector.h.

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

Definition at line 554 of file CVarVector.h.

References GetElementsCount().

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

Definition at line 642 of file CVarVector.h.

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

Definition at line 578 of file CVarVector.h.

References GetElementsCount().

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

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

Definition at line 473 of file CVarVector.h.

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

Definition at line 507 of file CVarVector.h.

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

Definition at line 589 of file CVarVector.h.

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

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

Definition at line 450 of file CVarVector.h.

Referenced by operator!=().

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

Definition at line 490 of file CVarVector.h.

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

Definition at line 524 of file CVarVector.h.

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

Definition at line 652 of file CVarVector.h.

References GetElementsCount().

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

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

Definition at line 661 of file CVarVector.h.

References GetElementsCount().

void imath::CVarVector::Reset ( )
inline

Set size to zero.

Definition at line 332 of file CVarVector.h.

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

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

Definition at line 347 of file CVarVector.h.

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 392 of file CVarVector.h.

References GetElementsCount().

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

Serialize this vector to specified archive.

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

Set some value to all elements.

Definition at line 323 of file CVarVector.h.

References GetElementsCount().

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

Set element at specified index.

Definition at line 317 of file CVarVector.h.

References operator[]().

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

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 289 of file CVarVector.h.

Referenced by operator=().

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=().

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

Translate the point.

Definition at line 369 of file CVarVector.h.

References GetElementsCount().


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

© 2007-2017 Witold Gantzke and Kirill Lepskiy