|
ACF $AcfVersion:0$
|
Implementation of variable-size mathematical vector with double precision elements. More...
#include <CVarVector.h>
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) | |
| Creates a vector from a range of values using iterators. | |
| CVarVector (const CVarVector &vector) | |
| Copy constructor. | |
| template<int Size> | |
| CVarVector (const TVector< Size, double > &vector) | |
| Creates a variable-size vector from a fixed-size TVector. | |
| 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) |
Implementation of variable-size mathematical vector with double precision elements.
CVarVector is a dynamic-size vector class that provides mathematical vector operations similar to TVector but with runtime-determined size. It's ideal for scenarios where the vector dimension is not known at compile time or needs to change during execution. The vector stores double precision floating-point values and supports common operations like addition, scaling, dot product, normalization, and distance calculations.
Use CVarVector when:
Use TVector when:
Definition at line 109 of file CVarVector.h.
| typedef std::vector<double> imath::CVarVector::Elements |
Definition at line 112 of file CVarVector.h.
|
inline |
Create the vector without components.
Definition at line 355 of file CVarVector.h.
|
inlineexplicit |
Create vector and initialize number of components.
Definition at line 360 of file CVarVector.h.
|
inline |
Creates a vector from a range of values using iterators.
This constructor enables creation from any container or sequence that provides iterators (e.g., std::vector, std::list, arrays).
| beginIter | Iterator to the first element |
| endIter | Iterator past the last element |
Definition at line 373 of file CVarVector.h.
|
inline |
Copy constructor.
Definition at line 366 of file CVarVector.h.
| imath::CVarVector::CVarVector | ( | const TVector< Size, double > & | vector | ) |
Creates a variable-size vector from a fixed-size TVector.
Allows conversion from compile-time sized vectors to runtime-sized vectors. Useful when interfacing between subsystems using different vector types.
| vector | The fixed-size TVector to convert from |
Definition at line 777 of file CVarVector.h.
|
inline |
Set all coordinates to zero.
Definition at line 442 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.
|
inline |
Return distance between two vectors.
Definition at line 546 of file CVarVector.h.
References GetDistance2().
Referenced by icmm::CVarColor::IsSimilar().
|
inline |
Return distance square between two vectors.
Definition at line 540 of file CVarVector.h.
Referenced by GetDistance().
|
inline |
Return dot product of two vectors.
Definition at line 513 of file CVarVector.h.
References GetElementsCount().
Referenced by GetLength2().
|
inline |
Get element at specified index.
Definition at line 409 of file CVarVector.h.
References operator[]().
Referenced by icmm::CVarColor::IsNormalized(), icmm::CVarColor::operator*(), and icmm::CVarColor::operator/().
|
inline |
Get reference to element at specified index.
Definition at line 415 of file CVarVector.h.
References operator[]().
|
inline |
Get read-only access to internal element container.
Definition at line 461 of file CVarVector.h.
|
inline |
Get number of elements.
Definition at line 387 of file CVarVector.h.
Referenced by Clear(), GetDotProduct(), icmm::CVarColor::IsNormalized(), icmm::CVarColor::operator*(), operator*=(), operator+=(), operator-(), operator-=(), icmm::CVarColor::operator/(), operator/=(), operator=(), operator[](), operator[](), ScaledCumulate(), SetAllElements(), icmm::TComposedColor< Size >::TComposedColor(), and Translate().
|
inline |
Get access to internal element container.
Definition at line 467 of file CVarVector.h.
| double imath::CVarVector::GetElementsSum | ( | ) | const |
Get simple sum of all elements.
|
inline |
|
inline |
Return euclidean length square.
Definition at line 528 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.
| length | new vector length. |
|
inline |
Get translated point.
Definition at line 484 of file CVarVector.h.
|
inline |
/overloaded
Definition at line 490 of file CVarVector.h.
|
inline |
Get true, if the element ist is empty.
Definition at line 381 of file CVarVector.h.
|
inline |
| bool imath::CVarVector::Normalize | ( | double | length = 1.0 | ) |
Normalize vector to specified length.
| length | new vector length. |
|
inline |
Definition at line 571 of file CVarVector.h.
References operator==().
|
inline |
Definition at line 736 of file CVarVector.h.
|
inline |
Definition at line 671 of file CVarVector.h.
References GetElementsCount().
Referenced by icmm::CVarColor::operator*=().
|
inline |
Definition at line 716 of file CVarVector.h.
|
inline |
Definition at line 645 of file CVarVector.h.
References GetElementsCount().
|
inline |
Definition at line 702 of file CVarVector.h.
References GetElementsCount().
|
inline |
Definition at line 726 of file CVarVector.h.
|
inline |
Definition at line 658 of file CVarVector.h.
References GetElementsCount().
|
inline |
Definition at line 746 of file CVarVector.h.
|
inline |
Definition at line 682 of file CVarVector.h.
References GetElementsCount().
Referenced by icmm::CVarColor::operator/=().
|
inline |
Definition at line 577 of file CVarVector.h.
|
inline |
Definition at line 611 of file CVarVector.h.
|
inline |
Definition at line 693 of file CVarVector.h.
References GetElementsCount(), SetElementsCount(), and SetElementsFrom().
|
inline |
Definition at line 554 of file CVarVector.h.
Referenced by operator!=().
|
inline |
Definition at line 594 of file CVarVector.h.
|
inline |
Definition at line 628 of file CVarVector.h.
|
inline |
Definition at line 765 of file CVarVector.h.
References GetElementsCount().
|
inline |
Definition at line 756 of file CVarVector.h.
References GetElementsCount().
Referenced by GetElement(), GetElementRef(), and SetElement().
|
inline |
Set size to zero.
Definition at line 436 of file CVarVector.h.
|
inline |
Set number of elements and set all elements to specified value.
Definition at line 451 of file CVarVector.h.
|
inline |
Add second vector scaled by specified factor.
It is equal of Translate(vector * scale) but can be faster implemented.
Definition at line 496 of file CVarVector.h.
References GetElementsCount().
| bool imath::CVarVector::Serialize | ( | iser::IArchive & | archive | ) |
Serialize this vector to specified archive.
|
inline |
Set some value to all elements.
Definition at line 427 of file CVarVector.h.
References GetElementsCount().
|
inline |
Set element at specified index.
Definition at line 421 of file CVarVector.h.
References operator[]().
Referenced by icmm::CVarColor::operator*(), and icmm::CVarColor::operator/().
|
inline |
Set number of elements.
Definition at line 393 of file CVarVector.h.
Referenced by operator=().
| void imath::CVarVector::SetElementsFrom | ( | const CVarVector & | vector, |
| double | expansionValue = 0 |
||
| ) |
Set elements from other vector without resizing.
| vector | source of element values will be copied. |
| expansionValue | if actual vector has more elements than vector, rest will be replaced with this value. |
Referenced by operator=().
|
inline |