VTK  9.4.20241121
Classes | Macros | Functions
vtkVector.h File Reference
#include "vtkObject.h"
#include "vtkTuple.h"
#include <cmath>
Include dependency graph for vtkVector.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  vtkVector< T, Size >
 templated base type for storage of vectors. More...
 
class  vtkVector2< T >
 
class  vtkVector3< T >
 
class  vtkVector4< T >
 
class  vtkVector2i
 Some derived classes for the different vectors commonly used. More...
 
class  vtkVector2f
 
class  vtkVector2d
 
class  vtkVector3i
 
class  vtkVector3f
 
class  vtkVector3d
 
class  vtkVector4i
 
class  vtkVector4d
 

Macros

#define vtkVectorNormalized(vectorType, type, size)
 Some inline functions for the derived types.
 
#define vtkVectorDerivedMacro(vectorType, type, size)
 
#define vtkVector3Cross(vectorType, type)
 
#define vtkVectorOperatorNegate(vectorType, type, size)
 Several macros to define the various operator overloads for the vectors.
 
#define vtkVectorOperatorPlus(vectorType, type, size)
 
#define vtkVectorOperatorMinus(vectorType, type, size)
 
#define vtkVectorOperatorMultiply(vectorType, type, size)
 
#define vtkVectorOperatorMultiplyScalar(vectorType, type, size)
 
#define vtkVectorOperatorMultiplyScalarPre(vectorType, type, size)
 
#define vtkVectorOperatorDivide(vectorType, type, size)
 
#define vtkVectorOperatorMacro(vectorType, type, size)
 

Functions

template<typename A , int Size>
vtkVector< A, Size > operator- (const vtkVector< A, Size > &v)
 This following operators enhance the vtkVector classes, allowing various operator overloads one might expect.
 
template<typename A , int Size>
vtkVector< A, Size > operator+ (const vtkVector< A, Size > &v1, const vtkVector< A, Size > &v2)
 Performs addition of vectors of the same basic type.
 
template<typename T , int Size>
vtkVector< T, Size > & operator+= (vtkVector< T, Size > &a, const vtkVector< T, Size > &b)
 Add the vector b to the vector a of the same basic type.
 
template<typename A , int Size>
vtkVector< A, Size > operator- (const vtkVector< A, Size > &v1, const vtkVector< A, Size > &v2)
 Performs subtraction of vectors of the same basic type.
 
template<typename T , int Size>
vtkVector< T, Size > & operator-= (vtkVector< T, Size > &a, const vtkVector< T, Size > &b)
 Subtract the vector b to the vector a of the same basic type.
 
template<typename A , int Size>
vtkVector< A, Size > operator* (const vtkVector< A, Size > &v1, const vtkVector< A, Size > &v2)
 Performs multiplication of vectors of the same basic type.
 
template<typename A , typename B , int Size>
vtkVector< A, Size > operator* (const vtkVector< A, Size > &v1, const B &scalar)
 Performs multiplication of vectors by a scalar value.
 
template<typename A , int Size>
vtkVector< A, Size > operator/ (const vtkVector< A, Size > &v1, const vtkVector< A, Size > &v2)
 Performs division of vectors of the same type.
 
 vtkVectorOperatorMacro (vtkVector2i, int, 2)
 Overload the operators for the common types.
 
 vtkVectorOperatorMacro (vtkVector2f, float, 2)
 
 vtkVectorOperatorMacro (vtkVector2d, double, 2)
 
 vtkVectorOperatorMacro (vtkVector3i, int, 3)
 
 vtkVectorOperatorMacro (vtkVector3f, float, 3)
 
 vtkVectorOperatorMacro (vtkVector3d, double, 3)
 

Macro Definition Documentation

◆ vtkVectorNormalized

#define vtkVectorNormalized (   vectorType,
  type,
  size 
)
Value:
vectorType Normalized() const \
{ \
return vectorType(vtkVector<type, size>::Normalized().GetData()); \
}
templated base type for storage of vectors.
Definition vtkVector.h:59

Some inline functions for the derived types.

Definition at line 410 of file vtkVector.h.

◆ vtkVectorDerivedMacro

#define vtkVectorDerivedMacro (   vectorType,
  type,
  size 
)
Value:
vtkVectorNormalized(vectorType, type, size); \
explicit vectorType(type s) \
: Superclass(s) \
{ \
} \
explicit vectorType(const type* i) \
: Superclass(i) \
{ \
} \
explicit vectorType(const vtkTuple<type, size>& o) \
: Superclass(o.GetData()) \
{ \
} \
vectorType(const vtkVector<type, size>& o) \
: Superclass(o.GetData()) \
{ \
}
templated base type for containers of constant size.
Definition vtkTuple.h:27
#define vtkVectorNormalized(vectorType, type, size)
Some inline functions for the derived types.
Definition vtkVector.h:410

Definition at line 416 of file vtkVector.h.

◆ vtkVector3Cross

#define vtkVector3Cross (   vectorType,
  type 
)
Value:
vectorType Cross(const vectorType& other) const \
{ \
return vectorType(vtkVector3<type>::Cross(other).GetData()); \
}

Definition at line 476 of file vtkVector.h.

◆ vtkVectorOperatorNegate

#define vtkVectorOperatorNegate (   vectorType,
  type,
  size 
)
Value:
inline vectorType operator-(const vectorType& v) \
{ \
return vectorType((-static_cast<vtkVector<type, size>>(v)).GetData()); \
}
vtkVector< A, Size > operator-(const vtkVector< A, Size > &v)
This following operators enhance the vtkVector classes, allowing various operator overloads one might...
Definition vtkVector.h:554

Several macros to define the various operator overloads for the vectors.

These macros are necessary to define operator overloads for common vector types (e.g vtkVector3d...), without them, there could be ambiguous overloads. XXX(c++20): might use constraints instead

Definition at line 669 of file vtkVector.h.

◆ vtkVectorOperatorPlus

#define vtkVectorOperatorPlus (   vectorType,
  type,
  size 
)
Value:
inline vectorType operator+(const vectorType& v1, const vectorType& v2) \
{ \
return vectorType( \
(static_cast<vtkVector<type, size>>(v1) + static_cast<vtkVector<type, size>>(v2)) \
.GetData()); \
}
vtkVector< A, Size > operator+(const vtkVector< A, Size > &v1, const vtkVector< A, Size > &v2)
Performs addition of vectors of the same basic type.
Definition vtkVector.h:568

Definition at line 674 of file vtkVector.h.

◆ vtkVectorOperatorMinus

#define vtkVectorOperatorMinus (   vectorType,
  type,
  size 
)
Value:
inline vectorType operator-(const vectorType& v1, const vectorType& v2) \
{ \
return vectorType( \
(static_cast<vtkVector<type, size>>(v1) - static_cast<vtkVector<type, size>>(v2)) \
.GetData()); \
}

Definition at line 681 of file vtkVector.h.

◆ vtkVectorOperatorMultiply

#define vtkVectorOperatorMultiply (   vectorType,
  type,
  size 
)
Value:
inline vectorType operator*(const vectorType& v1, const vectorType& v2) \
{ \
return vectorType( \
(static_cast<vtkVector<type, size>>(v1) * static_cast<vtkVector<type, size>>(v2)) \
.GetData()); \
}
vtkVector< A, Size > operator*(const vtkVector< A, Size > &v1, const vtkVector< A, Size > &v2)
Performs multiplication of vectors of the same basic type.
Definition vtkVector.h:624

Definition at line 688 of file vtkVector.h.

◆ vtkVectorOperatorMultiplyScalar

#define vtkVectorOperatorMultiplyScalar (   vectorType,
  type,
  size 
)
Value:
template <typename B> \
inline vectorType operator*(const vectorType& v1, const B& scalar) \
{ \
return vectorType((static_cast<vtkVector<type, size>>(v1) * scalar).GetData()); \
}

Definition at line 695 of file vtkVector.h.

◆ vtkVectorOperatorMultiplyScalarPre

#define vtkVectorOperatorMultiplyScalarPre (   vectorType,
  type,
  size 
)
Value:
template <typename B> \
inline vectorType operator*(const B& scalar, const vectorType& v1) \
{ \
return vectorType((static_cast<vtkVector<type, size>>(v1) * scalar).GetData()); \
}

Definition at line 701 of file vtkVector.h.

◆ vtkVectorOperatorDivide

#define vtkVectorOperatorDivide (   vectorType,
  type,
  size 
)
Value:
inline vectorType operator/(const vectorType& v1, const vectorType& v2) \
{ \
return vectorType( \
(static_cast<vtkVector<type, size>>(v1) / static_cast<vtkVector<type, size>>(v2)) \
.GetData()); \
}
vtkVector< A, Size > operator/(const vtkVector< A, Size > &v1, const vtkVector< A, Size > &v2)
Performs division of vectors of the same type.
Definition vtkVector.h:652

Definition at line 707 of file vtkVector.h.

◆ vtkVectorOperatorMacro

#define vtkVectorOperatorMacro (   vectorType,
  type,
  size 
)
Value:
vtkVectorOperatorNegate(vectorType, type, size); \
vtkVectorOperatorPlus(vectorType, type, size); \
vtkVectorOperatorMinus(vectorType, type, size); \
vtkVectorOperatorMultiply(vectorType, type, size); \
vtkVectorOperatorMultiplyScalar(vectorType, type, size); \
vtkVectorOperatorMultiplyScalarPre(vectorType, type, size); \
vtkVectorOperatorDivide(vectorType, type, size)
#define vtkVectorOperatorNegate(vectorType, type, size)
Several macros to define the various operator overloads for the vectors.
Definition vtkVector.h:669

Definition at line 715 of file vtkVector.h.

Function Documentation

◆ operator-() [1/2]

template<typename A , int Size>
vtkVector< A, Size > operator- ( const vtkVector< A, Size > &  v)

This following operators enhance the vtkVector classes, allowing various operator overloads one might expect.

Unary minus / negation of vector.

Definition at line 554 of file vtkVector.h.

◆ operator+()

template<typename A , int Size>
vtkVector< A, Size > operator+ ( const vtkVector< A, Size > &  v1,
const vtkVector< A, Size > &  v2 
)

Performs addition of vectors of the same basic type.

Definition at line 568 of file vtkVector.h.

◆ operator+=()

template<typename T , int Size>
vtkVector< T, Size > & operator+= ( vtkVector< T, Size > &  a,
const vtkVector< T, Size > &  b 
)

Add the vector b to the vector a of the same basic type.

Definition at line 582 of file vtkVector.h.

◆ operator-() [2/2]

template<typename A , int Size>
vtkVector< A, Size > operator- ( const vtkVector< A, Size > &  v1,
const vtkVector< A, Size > &  v2 
)

Performs subtraction of vectors of the same basic type.

Definition at line 596 of file vtkVector.h.

◆ operator-=()

template<typename T , int Size>
vtkVector< T, Size > & operator-= ( vtkVector< T, Size > &  a,
const vtkVector< T, Size > &  b 
)

Subtract the vector b to the vector a of the same basic type.

Definition at line 610 of file vtkVector.h.

◆ operator*() [1/2]

template<typename A , int Size>
vtkVector< A, Size > operator* ( const vtkVector< A, Size > &  v1,
const vtkVector< A, Size > &  v2 
)

Performs multiplication of vectors of the same basic type.

Definition at line 624 of file vtkVector.h.

◆ operator*() [2/2]

template<typename A , typename B , int Size>
vtkVector< A, Size > operator* ( const vtkVector< A, Size > &  v1,
const B &  scalar 
)

Performs multiplication of vectors by a scalar value.

Definition at line 638 of file vtkVector.h.

◆ operator/()

template<typename A , int Size>
vtkVector< A, Size > operator/ ( const vtkVector< A, Size > &  v1,
const vtkVector< A, Size > &  v2 
)

Performs division of vectors of the same type.

Definition at line 652 of file vtkVector.h.

◆ vtkVectorOperatorMacro() [1/6]

vtkVectorOperatorMacro ( vtkVector2i  ,
int  ,
 
)

Overload the operators for the common types.

◆ vtkVectorOperatorMacro() [2/6]

vtkVectorOperatorMacro ( vtkVector2f  ,
float  ,
 
)

◆ vtkVectorOperatorMacro() [3/6]

vtkVectorOperatorMacro ( vtkVector2d  ,
double  ,
 
)

◆ vtkVectorOperatorMacro() [4/6]

vtkVectorOperatorMacro ( vtkVector3i  ,
int  ,
 
)

◆ vtkVectorOperatorMacro() [5/6]

vtkVectorOperatorMacro ( vtkVector3f  ,
float  ,
 
)

◆ vtkVectorOperatorMacro() [6/6]

vtkVectorOperatorMacro ( vtkVector3d  ,
double  ,
 
)