ACF $AcfVersion:0$
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>

Inheritance diagram for imath::TVector< Size, Element >:
icmm::TComposedColor< 3 > icmm::TComposedColor< 4 > icmm::TComposedColor< Size > icmm::CCmy icmm::CHsv icmm::CLab icmm::CRgb icmm::CCmyk

Public Types

typedef Element ElementType
 
typedef Element Elements[Size]
 

Public Member Functions

 TVector ()
 Creates an uninitialized vector.
 
 TVector (const TVector< Size, Element > &vector)
 Creates a copy of another vector.
 
 TVector (std::initializer_list< Element > values)
 Creates a vector from an initializer list.
 
const Element & GetElement (int i) const
 Gets the element at the specified index (read-only).
 
Element & GetElementRef (int i)
 Gets a reference to the element at the specified index (read-write).
 
void SetElement (int i, const Element &value)
 Sets the element at the specified index.
 
void SetAllElements (const Element &value)
 Sets all elements to the same value.
 
void Reset ()
 Sets all coordinates to zero.
 
void Clear ()
 Sets all coordinates to zero.
 
const TVector< Size, Element >::ElementsGetElements () const
 Get read-only access to internal element container.
 
TVector< Size, Element >::ElementsGetElementsRef ()
 Get access to internal element container.
 
void Translate (const TVector< Size, Element > &vector)
 Translates (adds) another vector to this vector.
 
TVector< Size, Element > GetTranslated (const TVector< Size, Element > &vector)
 Returns a new vector that is the translation of this vector.
 
void GetTranslated (const TVector< Size, Element > &vector, TVector< Size, Element > &result)
 Computes the translated vector and stores it in the result parameter.
 
void ScaledCumulate (const TVector< Size, Element > &vector, Element scale)
 Adds a scaled vector to this vector.
 
bool IsNull (Element tolerance=I_BIG_EPSILON) const
 Checks if this vector is null (all elements approximately zero).
 
Element GetDotProduct (const TVector< Size, Element > &vector) const
 Calculates the dot product with another vector.
 
Element GetLength2 () const
 Calculates the squared Euclidean length of the vector.
 
Element GetLength () const
 Calculates the Euclidean length (magnitude) of the vector.
 
Element GetDistance2 (const TVector< Size, Element > &vector) const
 Calculates the squared distance to another vector.
 
Element GetDistance (const TVector< Size, Element > &vector) const
 Calculates the Euclidean distance to another vector.
 
Element GetElementsSum () const
 Calculates the sum of all vector elements.
 
bool Normalize (Element length=1.0)
 Normalizes the vector to a specified length.
 
bool GetNormalized (TVector< Size, Element > &result, Element length=1.0) const
 Returns a normalized copy of this vector with specified length.
 
void GetMinimal (const TVector< Size, Element > &vector, TVector< Size, Element > &result) const
 Get vector with minimal elements values.
 
void GetMaximal (const TVector< Size, Element > &vector, TVector< Size, Element > &result) const
 Get vector with maximal elements values.
 
bool Serialize (iser::IArchive &archive)
 Serialize this vector to specified archive.
 
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 > &vector)=default
 
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.
 
static bool SetElementsCount (int count)
 Set number of elements.
 
static const TVector< Size, Element > & GetZero ()
 Get vector with all coordinates set to 0.
 

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.

Purpose

TVector is a template class that provides a generic implementation of fixed-size mathematical vectors. It supports common vector operations like addition, scaling, dot product, normalization, and distance calculations. The vector size is determined at compile-time, enabling efficient memory layout and operations.

Template Parameters

Usage Examples

// Create a 3D vector with double precision
vec3d.SetElement(0, 1.0);
vec3d.SetElement(1, 2.0);
vec3d.SetElement(2, 3.0);
// Create a 2D vector with float precision using initializer list
imath::TVector<2, float> vec2f = {3.0f, 4.0f};
// Calculate vector length
double length = vec3d.GetLength(); // sqrt(1^2 + 2^2 + 3^2) = sqrt(14)
// Normalize vector to unit length
imath::TVector<3, double> unitVec = vec3d;
if (unitVec.Normalize()) {
// Now unitVec has length 1.0
}
// Dot product of two vectors
imath::TVector<3, double> other = {1.0, 0.0, 0.0};
double dotProduct = vec3d.GetDotProduct(other); // 1.0 * 1.0 = 1.0
// Calculate distance between two points
imath::TVector<2, float> point1 = {0.0f, 0.0f};
imath::TVector<2, float> point2 = {3.0f, 4.0f};
float distance = point1.GetDistance(point2); // 5.0
// Vector addition
imath::TVector<2, float> result = point1;
result.Translate(point2); // result is now {3.0f, 4.0f}
// Check if vector is null (all zeros)
zero.Clear();
if (zero.IsNull()) {
// Vector is all zeros
}
Implementation of fixed-size mathematical vector with specified type of elements.
Definition TVector.h:95
Element GetLength() const
Calculates the Euclidean length (magnitude) of the vector.
Definition TVector.h:667
Element GetDotProduct(const TVector< Size, Element > &vector) const
Calculates the dot product with another vector.
Definition TVector.h:647
void Translate(const TVector< Size, Element > &vector)
Translates (adds) another vector to this vector.
Definition TVector.h:608
bool Normalize(Element length=1.0)
Normalizes the vector to a specified length.
Definition TVector.h:940
void Clear()
Sets all coordinates to zero.
Definition TVector.h:585
bool IsNull(Element tolerance=I_BIG_EPSILON) const
Checks if this vector is null (all elements approximately zero).
Definition TVector.h:640
Element GetDistance(const TVector< Size, Element > &vector) const
Calculates the Euclidean distance to another vector.
Definition TVector.h:681
void SetElement(int i, const Element &value)
Sets the element at the specified index.
Definition TVector.h:560

Common Operations

See also
imath::TFastVector, imath::CVarVector, i3d::CVector3d

Definition at line 94 of file TVector.h.

Member Typedef Documentation

◆ Elements

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

Definition at line 98 of file TVector.h.

◆ ElementType

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

Definition at line 97 of file TVector.h.

Constructor & Destructor Documentation

◆ TVector() [1/3]

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

Creates an uninitialized vector.

This constructor creates a vector with the specified size but does not initialize the element values. The element values will contain undefined data until explicitly set using SetElement(), SetAllElements(), or other initialization methods.

Note
For better performance, use this constructor when you plan to immediately initialize all elements anyway.
If you need a zero-initialized vector, call Clear() or SetAllElements(0) after construction.
See also
Clear(), SetAllElements()

Definition at line 513 of file TVector.h.

◆ TVector() [2/3]

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

Creates a copy of another vector.

Parameters
vectorThe source vector to copy from. All elements will be copied to this new vector.

Definition at line 519 of file TVector.h.

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

◆ TVector() [3/3]

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

Creates a vector from an initializer list.

Allows convenient initialization using brace syntax. If the initializer list contains fewer elements than Size, remaining elements are default-initialized (typically to zero for numeric types). If the list contains more elements than Size, only the first Size elements are used.

Parameters
valuesInitializer list of element values
// Create a 3D vector
TVector<3, double> v = {1.0, 2.0, 3.0};
// Partial initialization (remaining elements are 0)
TVector<5, int> v2 = {1, 2}; // v2 = {1, 2, 0, 0, 0}

Definition at line 528 of file TVector.h.

Member Function Documentation

◆ Clear()

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

Sets all coordinates to zero.

Equivalent to SetAllElements(0) and Reset().

See also
Reset(), SetAllElements()

Definition at line 585 of file TVector.h.

◆ GetDistance()

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

Calculates the Euclidean distance to another vector.

Parameters
vectorThe other vector (point)
Returns
The Euclidean distance between this vector and the given vector
TVector<2, double> p1 = {0.0, 0.0};
TVector<2, double> p2 = {3.0, 4.0};
double dist = p1.GetDistance(p2); // 5.0
See also
GetDistance2(), GetLength()

Definition at line 681 of file TVector.h.

◆ GetDistance2()

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

Calculates the squared distance to another vector.

More efficient than GetDistance() when only relative distances need to be compared, as it avoids the square root operation.

Parameters
vectorThe other vector (point)
Returns
The squared Euclidean distance
See also
GetDistance(), GetLength2()

Definition at line 674 of file TVector.h.

◆ GetDotProduct()

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

Calculates the dot product with another vector.

The dot product is defined as: sum(this[i] * vector[i]) for all i. It measures the similarity of direction between two vectors.

Parameters
vectorThe other vector for dot product calculation
Returns
The scalar dot product value
TVector<3, double> v1 = {1.0, 0.0, 0.0};
TVector<3, double> v2 = {0.0, 1.0, 0.0};
double dot = v1.GetDotProduct(v2); // 0.0 (perpendicular vectors)
TVector<3, double> v3 = {2.0, 0.0, 0.0};
double dot2 = v1.GetDotProduct(v3); // 2.0 (parallel vectors)
See also
GetLength(), Normalize()

Definition at line 647 of file TVector.h.

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

Referenced by i3d::Geometry::GetAngleBetweenVectors(), i3d::Geometry::GetSignedAngleBetweenVectors(), i3d::CPlane3d::GetSignedDistance(), and i3d::Geometry::ProjectVectorOntoVector().

◆ GetElement()

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

◆ GetElementRef()

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

Gets a reference to the element at the specified index (read-write).

Returns a non-const reference allowing direct modification of the element.

Parameters
iZero-based index of the element (0 <= i < Size)
Returns
Reference to the element at index i
v.GetElementRef(0) = 1.0; // Direct assignment
v.GetElementRef(1) += 2.0; // Direct modification
Element & GetElementRef(int i)
Gets a reference to the element at the specified index (read-write).
Definition TVector.h:553
See also
GetElement(), SetElement()

Definition at line 553 of file TVector.h.

◆ GetElements()

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

◆ GetElementsCount()

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

Get number of elements.

Definition at line 904 of file TVector.h.

Referenced by icmm::qHash().

◆ GetElementsRef()

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

Get access to internal element container.

Definition at line 601 of file TVector.h.

◆ GetElementsSum()

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

Calculates the sum of all vector elements.

Returns
Sum of all element values
TVector<4, int> v = {1, 2, 3, 4};
int sum = v.GetElementsSum(); // 10
Element GetElementsSum() const
Calculates the sum of all vector elements.
Definition TVector.h:927

Definition at line 927 of file TVector.h.

◆ GetLength()

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

Calculates the Euclidean length (magnitude) of the vector.

Returns sqrt(sum(element[i]^2)) for all i.

Returns
The length of the vector
TVector<2, double> v = {3.0, 4.0};
double length = v.GetLength(); // 5.0
See also
GetLength2(), Normalize()

Definition at line 667 of file TVector.h.

Referenced by i3d::Geometry::GetDistance(), i3d::CLine3d::GetLength(), and i3d::Geometry::GetTriangleArea().

◆ GetLength2()

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

Calculates the squared Euclidean length of the vector.

Returns sum(element[i]^2) for all i. This is more efficient than GetLength() when only relative lengths need to be compared, as it avoids the square root operation.

Returns
The squared length of the vector
See also
GetLength(), GetDistance2()

Definition at line 660 of file TVector.h.

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

◆ GetMaximal()

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

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

◆ GetMinimal()

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

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

◆ GetNormalized()

template<int Size, class Element >
bool imath::TVector< Size, Element >::GetNormalized ( TVector< Size, Element > &  result,
Element  length = 1.0 
) const

Returns a normalized copy of this vector with specified length.

Creates a new vector with the same direction as this vector but with the specified length. The original vector is not modified.

Parameters
resultOutput parameter that receives the normalized vector
lengthThe desired length for the normalized vector (default: 1.0)
Returns
true if normalization succeeded, false if this vector's length was zero
TVector<2, double> v = {3.0, 4.0};
if (v.GetNormalized(unit)) {
// unit is {0.6, 0.8}, v is unchanged
}
bool GetNormalized(TVector< Size, Element > &result, Element length=1.0) const
Returns a normalized copy of this vector with specified length.
Definition TVector.h:960
See also
Normalize()

Definition at line 960 of file TVector.h.

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

◆ GetTranslated() [1/2]

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

Returns a new vector that is the translation of this vector.

Parameters
vectorThe vector to add
Returns
A new vector containing the sum of this vector and the given vector
See also
Translate(), GetTranslated(const TVector<Size, Element>&, TVector<Size, Element>&)

Definition at line 617 of file TVector.h.

◆ GetTranslated() [2/2]

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

Computes the translated vector and stores it in the result parameter.

Parameters
vectorThe vector to add to this vector
resultOutput parameter that receives the translated vector
See also
Translate(), GetTranslated(const TVector<Size, Element>&)

Definition at line 624 of file TVector.h.

◆ GetZero()

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

◆ IsNull()

template<int Size, class Element >
bool imath::TVector< Size, Element >::IsNull ( Element  tolerance = I_BIG_EPSILON) const
inline

Checks if this vector is null (all elements approximately zero).

Parameters
toleranceThe maximum absolute value for each element to be considered zero. Default is I_BIG_EPSILON (typically 1e-6 for double precision).
Returns
true if all elements have absolute value less than or equal to tolerance
TVector<3, double> v = {0.0, 0.0000001, 0.0};
bool isNull = v.IsNull(); // true with default tolerance
bool isExactNull = v.IsNull(0.0); // false, middle element is not exactly zero
See also
Clear(), Reset()

Definition at line 640 of file TVector.h.

◆ Normalize()

template<int Size, class Element >
bool imath::TVector< Size, Element >::Normalize ( Element  length = 1.0)

Normalizes the vector to a specified length.

Scales the vector so that its length becomes the specified value. If the current length is zero (or very close to zero), the operation fails.

Parameters
lengthThe desired length after normalization (default: 1.0 for unit vector)
Returns
true if normalization succeeded, false if the vector length was zero
TVector<2, double> v = {3.0, 4.0}; // length = 5.0
if (v.Normalize()) {
// v is now {0.6, 0.8} with length 1.0
}
TVector<3, double> v2 = {1.0, 2.0, 3.0};
if (v2.Normalize(10.0)) {
// v2 now has length 10.0 but same direction
}
See also
GetNormalized(), GetLength()

Definition at line 940 of file TVector.h.

References I_BIG_EPSILON.

◆ operator!=()

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

Definition at line 702 of file TVector.h.

◆ operator*()

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

Definition at line 856 of file TVector.h.

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

◆ operator*=()

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

Definition at line 795 of file TVector.h.

◆ operator+()

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

Definition at line 830 of file TVector.h.

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

◆ operator+=()

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

Definition at line 773 of file TVector.h.

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

◆ operator-() [1/2]

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

Definition at line 817 of file TVector.h.

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

◆ operator-() [2/2]

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

Definition at line 843 of file TVector.h.

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

◆ operator-=()

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

Definition at line 784 of file TVector.h.

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

◆ operator/()

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

Definition at line 869 of file TVector.h.

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

◆ operator/=()

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

Definition at line 806 of file TVector.h.

◆ operator<()

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

Definition at line 709 of file TVector.h.

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

◆ operator<=()

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

Definition at line 741 of file TVector.h.

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

◆ operator=()

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

◆ operator==()

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

Definition at line 690 of file TVector.h.

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

◆ operator>()

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

Definition at line 725 of file TVector.h.

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

◆ operator>=()

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

Definition at line 757 of file TVector.h.

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

◆ operator[]() [1/2]

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

Definition at line 892 of file TVector.h.

◆ operator[]() [2/2]

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

Definition at line 882 of file TVector.h.

◆ Reset()

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

Sets all coordinates to zero.

Equivalent to SetAllElements(0). This method is provided for compatibility with other vector implementations.

See also
Clear(), SetAllElements()

Definition at line 576 of file TVector.h.

◆ ScaledCumulate()

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

Adds a scaled vector to this vector.

Performs the operation: this[i] += vector[i] * scale for all i. This is equivalent to Translate(vector * scale) but may be more efficiently implemented.

Parameters
vectorThe vector to add (scaled)
scaleThe scaling factor to apply to the vector before addition
TVector<2, double> v1 = {1.0, 2.0};
TVector<2, double> v2 = {3.0, 4.0};
v1.ScaledCumulate(v2, 2.0); // v1 is now {7.0, 10.0} = {1+3*2, 2+4*2}
void ScaledCumulate(const TVector< Size, Element > &vector, Element scale)
Adds a scaled vector to this vector.
Definition TVector.h:631
See also
Translate()

Definition at line 631 of file TVector.h.

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

◆ Serialize()

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

Serialize this vector to specified archive.

Definition at line 998 of file TVector.h.

References iser::IArchive::Process().

◆ SetAllElements()

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

Sets all elements to the same value.

Parameters
valueThe value to assign to all vector elements
v.SetAllElements(7); // All elements are now 7
void SetAllElements(const Element &value)
Sets all elements to the same value.
Definition TVector.h:567
See also
Clear(), Reset()

Definition at line 567 of file TVector.h.

◆ SetElement()

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

◆ SetElementsCount()

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

◆ Translate()

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

Translates (adds) another vector to this vector.

Performs element-wise addition: this[i] += vector[i] for all i.

Parameters
vectorThe vector to add to this vector
TVector<2, double> v1 = {1.0, 2.0};
TVector<2, double> v2 = {3.0, 4.0};
v1.Translate(v2); // v1 is now {4.0, 6.0}
See also
GetTranslated(), ScaledCumulate()

Definition at line 608 of file TVector.h.

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

Member Data Documentation

◆ m_elements

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: