VTK  9.4.20241014
Public Member Functions | List of all members
vtkVector< T, Size > Class Template Reference

templated base type for storage of vectors. More...

#include <vtkVector.h>

Inheritance diagram for vtkVector< T, Size >:
[legend]
Collaboration diagram for vtkVector< T, Size >:
[legend]

Public Member Functions

 vtkVector ()=default
 
 vtkVector (const T &scalar)
 Initialize all of the vector's elements with the supplied scalar.
 
 vtkVector (const T *init)
 Initialize the vector's elements with the elements of the supplied array.
 
double Norm () const
 Get the norm of the vector, i.e.
 
SquaredNorm () const
 Get the squared norm of the vector.
 
double Normalize ()
 Normalize the vector in place.
 
vtkVector< T, Size > Normalized () const
 Return the normalized form of this vector.
 
Dot (const vtkVector< T, Size > &other) const
 The dot product of this and the supplied vector.
 
template<typename TR >
vtkVector< TR, Size > Cast () const
 Cast the vector to the specified type, returning the result.
 
- Public Member Functions inherited from vtkTuple< T, Size >
 vtkTuple ()=default
 The default constructor does not initialize values.
 
 vtkTuple (const T &scalar)
 Initialize all of the tuple's elements with the supplied scalar.
 
 vtkTuple (const T *init)
 Initialize the tuple's elements with the elements of the supplied array.
 
 vtkTuple (const std::array< T, Size > &values)
 Initialize the tuple's elements using a std::array for matching type and size.
 
int GetSize () const
 Get the size of the tuple.
 
T * GetData ()
 Get a pointer to the underlying data of the tuple.
 
const T * GetData () const
 
T & operator[] (int i)
 Get a reference to the underlying data element of the tuple.
 
const T & operator[] (int i) const
 
operator() (int i) const
 Get the value of the tuple at the index specified.
 
bool Compare (const vtkTuple< T, Size > &other, const T &tol) const
 Equality operator with a tolerance to allow fuzzy comparisons.
 
template<typename TR >
vtkTuple< TR, Size > Cast () const
 Cast the tuple to the specified type, returning the result.
 

Additional Inherited Members

- Protected Attributes inherited from vtkTuple< T, Size >
Data [Size]
 The only thing stored in memory!
 

Detailed Description

template<typename T, int Size>
class vtkVector< T, Size >

templated base type for storage of vectors.

This class is a templated data type for storing and manipulating fixed size vectors, which can be used to represent two and three dimensional points. The memory layout is a contiguous array of the specified type, such that a float[2] can be cast to a vtkVector2f and manipulated. Also a float[6] could be cast and used as a vtkVector2f[3].

Online Examples:

Tests:
vtkVector (Tests)

Definition at line 58 of file vtkVector.h.

Constructor & Destructor Documentation

◆ vtkVector() [1/3]

template<typename T , int Size>
vtkVector< T, Size >::vtkVector ( )
default

◆ vtkVector() [2/3]

template<typename T , int Size>
vtkVector< T, Size >::vtkVector ( const T &  scalar)
inlineexplicit

Initialize all of the vector's elements with the supplied scalar.

Definition at line 66 of file vtkVector.h.

◆ vtkVector() [3/3]

template<typename T , int Size>
vtkVector< T, Size >::vtkVector ( const T *  init)
inlineexplicit

Initialize the vector's elements with the elements of the supplied array.

Note that the supplied pointer must contain at least as many elements as the vector, or it will result in access to out of bounds memory.

Definition at line 76 of file vtkVector.h.

Member Function Documentation

◆ SquaredNorm()

template<typename T , int Size>
T vtkVector< T, Size >::SquaredNorm ( ) const
inline

Get the squared norm of the vector.

Definition at line 85 of file vtkVector.h.

◆ Norm()

template<typename T , int Size>
double vtkVector< T, Size >::Norm ( ) const
inline

Get the norm of the vector, i.e.

its length.

Definition at line 99 of file vtkVector.h.

◆ Normalize()

template<typename T , int Size>
double vtkVector< T, Size >::Normalize ( )
inline

Normalize the vector in place.

Returns
The length of the vector.

Definition at line 106 of file vtkVector.h.

◆ Normalized()

template<typename T , int Size>
vtkVector< T, Size > vtkVector< T, Size >::Normalized ( ) const
inline

Return the normalized form of this vector.

Returns
The normalized form of this vector.

Definition at line 127 of file vtkVector.h.

◆ Dot()

template<typename T , int Size>
T vtkVector< T, Size >::Dot ( const vtkVector< T, Size > &  other) const
inline

The dot product of this and the supplied vector.

Definition at line 139 of file vtkVector.h.

◆ Cast()

template<typename T , int Size>
template<typename TR >
vtkVector< TR, Size > vtkVector< T, Size >::Cast ( ) const
inline

Cast the vector to the specified type, returning the result.

Definition at line 155 of file vtkVector.h.


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