|
ACF $AcfVersion:0$
|
Optimized implementation of a variable-size vector with compile-time maximum capacity. More...
#include <TFastVector.h>
Public Types | |
| enum | { MAX_ELEMENTS_COUNT = MaxSize } |
| typedef Element | ElementType |
Public Member Functions | |
| TFastVector () | |
| Create an uninitialized point. | |
| TFastVector (int componentsCount, const Element &value=Element()) | |
| Create vector and initialize number of components. | |
| TFastVector (const TFastVector< MaxSize, Element > &vector) | |
| Copy constructor. | |
| TFastVector (std::initializer_list< Element > values) | |
| Initializer list constructor. | |
| template<int Size> | |
| TFastVector (const imath::TVector< Size, Element > &vector) | |
| int | GetElementsCount () const |
| Get number of elements. | |
| bool | SetElementsCount (int count, const Element &value=Element()) |
| Set number of elements. | |
| bool | EnsureElementsCount (int count, const Element &value=Element()) |
| Ensure, that number of elements vector cannot be smaller that some value. | |
| const Element & | GetElement (int i) const |
| Get element at specified i. | |
| Element & | GetElementRef (int i) |
| Get reference to element at specified i. | |
| void | SetElement (int i, const Element &value) |
| Set element at specified i. | |
| void | Clear () |
| Set all coordinates to zero. | |
| void | SetElementsFrom (const TFastVector &vector, const Element &expansionValue=Element()) |
| Set elemenents from other vector without resizing. | |
| void | Translate (const TFastVector< MaxSize, Element > &vector) |
| Translate the point. | |
| TFastVector< MaxSize, Element > | GetTranslated (const TFastVector< MaxSize, Element > &vector) |
| Get translated point. | |
| void | GetTranslated (const TFastVector< MaxSize, Element > &vector, TFastVector< MaxSize, Element > &result) |
| /overloaded | |
| void | ScaledCumulate (const TFastVector< MaxSize, Element > &vector, Element scale) |
| Add second vector scaled by specified factor. | |
| bool | IsNull (Element tolerance=I_BIG_EPSILON) const |
| Check if this vector is null. | |
| Element | GetDotProduct (const TFastVector< MaxSize, Element > &vector) const |
| Return dot product of two vectors. | |
| Element | GetLength2 () const |
| Return euclidian length square. | |
| Element | GetLength () const |
| Return euclidian length. | |
| Element | GetDistance2 (const TFastVector< MaxSize, Element > &vector) const |
| Return distance square between two vectors. | |
| Element | GetDistance (const TFastVector< MaxSize, Element > &vector) const |
| Return distance between two vectors. | |
| Element | GetElementsSum () const |
| Get simple sum of all elements. | |
| bool | Normalize (Element length=1.0) |
| Normalize vector to specified length. | |
| bool | GetNormalized (TFastVector< MaxSize, Element > &result, Element length=1.0) const |
| Return normalized vector with the same direction and specified length. | |
| void | GetMinimal (const TFastVector< MaxSize, Element > &vector, TFastVector< MaxSize, Element > &result) const |
| Get vector with minimal elements values. | |
| void | GetMaximal (const TFastVector< MaxSize, Element > &vector, TFastVector< MaxSize, Element > &result) const |
| Get vector with maximal elements values. | |
| bool | Serialize (iser::IArchive &archive) |
| Serialize this vector to specified archive. | |
| 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 |
Optimized implementation of a variable-size vector with compile-time maximum capacity.
TFastVector is a hybrid between fixed-size and dynamic vectors. It allocates space for MaxSize elements on the stack (or inline within the containing object), but allows the actual number of active elements to vary at runtime. This provides the performance benefits of stack allocation while maintaining some runtime flexibility.
Definition at line 122 of file TFastVector.h.
| typedef Element imath::TFastVector< MaxSize, Element >::ElementType |
Definition at line 125 of file TFastVector.h.
| anonymous enum |
| Enumerator | |
|---|---|
| MAX_ELEMENTS_COUNT | |
Definition at line 127 of file TFastVector.h.
|
inline |
Create an uninitialized point.
Definition at line 325 of file TFastVector.h.
|
inlineexplicit |
Create vector and initialize number of components.
Definition at line 332 of file TFastVector.h.
References imath::TFastVector< MaxSize, Element >::m_elements, and imath::TFastVector< MaxSize, Element >::m_elementsCount.
|
inline |
Copy constructor.
Definition at line 342 of file TFastVector.h.
References imath::TFastVector< MaxSize, Element >::m_elements, and imath::TFastVector< MaxSize, Element >::m_elementsCount.
|
inline |
Initializer list constructor.
Definition at line 352 of file TFastVector.h.
References imath::TFastVector< MaxSize, Element >::m_elements, and imath::TFastVector< MaxSize, Element >::m_elementsCount.
|
inline |
Definition at line 152 of file TFastVector.h.
References imath::TFastVector< MaxSize, Element >::m_elements.
|
inline |
Set all coordinates to zero.
Definition at line 439 of file TFastVector.h.
|
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.
| count | number of elements. |
Definition at line 389 of file TFastVector.h.
|
inline |
Return distance between two vectors.
Definition at line 554 of file TFastVector.h.
|
inline |
Return distance square between two vectors.
Definition at line 547 of file TFastVector.h.
|
inline |
Return dot product of two vectors.
Definition at line 519 of file TFastVector.h.
References imath::TFastVector< MaxSize, Element >::m_elements, and imath::TFastVector< MaxSize, Element >::m_elementsCount.
|
inline |
Get element at specified i.
Definition at line 409 of file TFastVector.h.
Referenced by imath::TFastVector< MaxSize, Element >::GetMaximal(), and imath::TFastVector< MaxSize, Element >::GetMinimal().
|
inline |
Get reference to element at specified i.
Definition at line 419 of file TFastVector.h.
|
inline |
Get number of elements.
Definition at line 364 of file TFastVector.h.
Referenced by imath::TFastVector< MaxSize, Element >::GetMaximal(), imath::TFastVector< MaxSize, Element >::GetMinimal(), icmm::CFastColor::operator*=(), icmm::CFastColor::operator/=(), icmm::CFastColor::operator<(), icmm::CFastColor::operator<=(), icmm::CFastColor::operator==(), icmm::CFastColor::operator>(), icmm::CFastColor::operator>=(), and imath::qHash().
| Element imath::TFastVector< MaxSize, Element >::GetElementsSum | ( | ) | const |
Get simple sum of all elements.
Definition at line 820 of file TFastVector.h.
|
inline |
Return euclidian length.
Definition at line 540 of file TFastVector.h.
|
inline |
Return euclidian length square.
Definition at line 533 of file TFastVector.h.
| void imath::TFastVector< MaxSize, Element >::GetMaximal | ( | const TFastVector< MaxSize, Element > & | vector, |
| TFastVector< MaxSize, Element > & | result | ||
| ) | const |
Get vector with maximal elements values.
Definition at line 875 of file TFastVector.h.
References imath::TFastVector< MaxSize, Element >::GetElement(), imath::TFastVector< MaxSize, Element >::GetElementsCount(), imath::TFastVector< MaxSize, Element >::SetElement(), and imath::TFastVector< MaxSize, Element >::SetElementsCount().
| void imath::TFastVector< MaxSize, Element >::GetMinimal | ( | const TFastVector< MaxSize, Element > & | vector, |
| TFastVector< MaxSize, Element > & | result | ||
| ) | const |
Get vector with minimal elements values.
Definition at line 862 of file TFastVector.h.
References imath::TFastVector< MaxSize, Element >::GetElement(), imath::TFastVector< MaxSize, Element >::GetElementsCount(), imath::TFastVector< MaxSize, Element >::SetElement(), and imath::TFastVector< MaxSize, Element >::SetElementsCount().
| 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.
| length | new vector length. |
Definition at line 853 of file TFastVector.h.
References imath::TFastVector< MaxSize, Element >::Normalize().
|
inline |
Get translated point.
Definition at line 496 of file TFastVector.h.
| void imath::TFastVector< MaxSize, Element >::GetTranslated | ( | const TFastVector< MaxSize, Element > & | vector, |
| TFastVector< MaxSize, Element > & | result | ||
| ) |
/overloaded
Definition at line 503 of file TFastVector.h.
References imath::TFastVector< MaxSize, Element >::Translate().
|
inline |
Check if this vector is null.
Definition at line 512 of file TFastVector.h.
| bool imath::TFastVector< MaxSize, Element >::Normalize | ( | Element | length = 1.0 | ) |
Normalize vector to specified length.
| length | new vector length. |
Definition at line 833 of file TFastVector.h.
References I_BIG_EPSILON.
Referenced by imath::TFastVector< MaxSize, Element >::GetNormalized().
|
inline |
Definition at line 580 of file TFastVector.h.
|
inline |
Definition at line 776 of file TFastVector.h.
|
inline |
Definition at line 719 of file TFastVector.h.
|
inline |
Definition at line 754 of file TFastVector.h.
|
inline |
Definition at line 669 of file TFastVector.h.
References imath::TFastVector< MaxSize, Element >::m_elements, and imath::TFastVector< MaxSize, Element >::m_elementsCount.
|
inline |
Definition at line 741 of file TFastVector.h.
References imath::TFastVector< MaxSize, Element >::m_elements.
|
inline |
Definition at line 765 of file TFastVector.h.
|
inline |
Definition at line 694 of file TFastVector.h.
References imath::TFastVector< MaxSize, Element >::m_elements, and imath::TFastVector< MaxSize, Element >::m_elementsCount.
|
inline |
Definition at line 787 of file TFastVector.h.
|
inline |
Definition at line 730 of file TFastVector.h.
| bool imath::TFastVector< MaxSize, Element >::operator< | ( | const TFastVector< MaxSize, Element > & | vector | ) | const |
Definition at line 587 of file TFastVector.h.
References imath::TFastVector< MaxSize, Element >::m_elements, and imath::TFastVector< MaxSize, Element >::m_elementsCount.
| bool imath::TFastVector< MaxSize, Element >::operator<= | ( | const TFastVector< MaxSize, Element > & | vector | ) | const |
Definition at line 621 of file TFastVector.h.
References imath::TFastVector< MaxSize, Element >::m_elements, and imath::TFastVector< MaxSize, Element >::m_elementsCount.
|
inline |
Definition at line 655 of file TFastVector.h.
References imath::TFastVector< MaxSize, Element >::m_elements, and imath::TFastVector< MaxSize, Element >::m_elementsCount.
|
inline |
Definition at line 563 of file TFastVector.h.
References imath::TFastVector< MaxSize, Element >::m_elements, and imath::TFastVector< MaxSize, Element >::m_elementsCount.
| bool imath::TFastVector< MaxSize, Element >::operator> | ( | const TFastVector< MaxSize, Element > & | vector | ) | const |
Definition at line 604 of file TFastVector.h.
References imath::TFastVector< MaxSize, Element >::m_elements, and imath::TFastVector< MaxSize, Element >::m_elementsCount.
| bool imath::TFastVector< MaxSize, Element >::operator>= | ( | const TFastVector< MaxSize, Element > & | vector | ) | const |
Definition at line 638 of file TFastVector.h.
References imath::TFastVector< MaxSize, Element >::m_elements, and imath::TFastVector< MaxSize, Element >::m_elementsCount.
| Element & imath::TFastVector< MaxSize, Element >::operator[] | ( | int | i | ) |
Definition at line 808 of file TFastVector.h.
| const Element & imath::TFastVector< MaxSize, Element >::operator[] | ( | int | i | ) | const |
Definition at line 798 of file TFastVector.h.
|
inline |
Add second vector scaled by specified factor.
It is equal of Translate(vector * scale) but can be faster implemented.
Definition at line 458 of file TFastVector.h.
References imath::TFastVector< MaxSize, Element >::m_elements, and imath::TFastVector< MaxSize, Element >::m_elementsCount.
| bool imath::TFastVector< MaxSize, Element >::Serialize | ( | iser::IArchive & | archive | ) |
Serialize this vector to specified archive.
Definition at line 888 of file TFastVector.h.
References iser::IArchive::BeginMultiTag(), iser::IArchive::BeginTag(), iser::IArchive::EndTag(), iser::IArchive::IsStoring(), iser::IArchive::Process(), iser::CArchiveTag::TT_LEAF, and iser::CArchiveTag::TT_MULTIPLE.
|
inline |
Set element at specified i.
Definition at line 429 of file TFastVector.h.
Referenced by imath::TFastVector< MaxSize, Element >::GetMaximal(), and imath::TFastVector< MaxSize, Element >::GetMinimal().
|
inline |
Set number of elements.
| count | number of elements. |
Definition at line 371 of file TFastVector.h.
Referenced by imath::TFastVector< MaxSize, Element >::GetMaximal(), and imath::TFastVector< MaxSize, Element >::GetMinimal().
| void imath::TFastVector< MaxSize, Element >::SetElementsFrom | ( | const TFastVector< MaxSize, Element > & | vector, |
| const Element & | expansionValue = Element() |
||
| ) |
Set elemenents 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. |
Definition at line 481 of file TFastVector.h.
References imath::TFastVector< MaxSize, Element >::m_elementsCount.
|
inline |
Translate the point.
Definition at line 448 of file TFastVector.h.
References imath::TFastVector< MaxSize, Element >::m_elements, and imath::TFastVector< MaxSize, Element >::m_elementsCount.
Referenced by imath::TFastVector< MaxSize, Element >::GetTranslated().
|
protected |
Definition at line 317 of file TFastVector.h.
Referenced by icmm::CFastColor::CFastColor(), imath::TFastVector< MaxSize, Element >::GetDotProduct(), icmm::CFastColor::operator*(), icmm::CFastColor::operator*=(), icmm::CFastColor::operator+=(), imath::TFastVector< MaxSize, Element >::operator+=(), imath::TFastVector< MaxSize, Element >::operator-(), icmm::CFastColor::operator-=(), imath::TFastVector< MaxSize, Element >::operator-=(), icmm::CFastColor::operator/(), icmm::CFastColor::operator/=(), imath::TFastVector< MaxSize, Element >::operator<(), imath::TFastVector< MaxSize, Element >::operator<=(), icmm::CFastColor::operator=(), imath::TFastVector< MaxSize, Element >::operator=(), imath::TFastVector< MaxSize, Element >::operator==(), imath::TFastVector< MaxSize, Element >::operator>(), imath::TFastVector< MaxSize, Element >::operator>=(), imath::TFastVector< MaxSize, Element >::ScaledCumulate(), imath::TFastVector< MaxSize, Element >::TFastVector(), imath::TFastVector< MaxSize, Element >::TFastVector(), imath::TFastVector< MaxSize, Element >::TFastVector(), imath::TFastVector< MaxSize, Element >::TFastVector(), and imath::TFastVector< MaxSize, Element >::Translate().
|
protected |
Definition at line 318 of file TFastVector.h.
Referenced by icmm::CFastColor::CFastColor(), imath::TFastVector< MaxSize, Element >::GetDotProduct(), icmm::CFastColor::operator+=(), imath::TFastVector< MaxSize, Element >::operator+=(), icmm::CFastColor::operator-=(), imath::TFastVector< MaxSize, Element >::operator-=(), imath::TFastVector< MaxSize, Element >::operator<(), imath::TFastVector< MaxSize, Element >::operator<=(), icmm::CFastColor::operator=(), imath::TFastVector< MaxSize, Element >::operator=(), imath::TFastVector< MaxSize, Element >::operator==(), imath::TFastVector< MaxSize, Element >::operator>(), imath::TFastVector< MaxSize, Element >::operator>=(), imath::TFastVector< MaxSize, Element >::ScaledCumulate(), imath::TFastVector< MaxSize, Element >::SetElementsFrom(), imath::TFastVector< MaxSize, Element >::TFastVector(), imath::TFastVector< MaxSize, Element >::TFastVector(), imath::TFastVector< MaxSize, Element >::TFastVector(), and imath::TFastVector< MaxSize, Element >::Translate().