|  | VTK
    9.0.1
    | 
 
 
 
Go to the documentation of this file.
   16 #ifndef vtkVectorOperators_h 
   17 #define vtkVectorOperators_h 
   25 template <
typename A, 
int Size>
 
   29   for (
int i = 0; i < Size; ++i)
 
   38 template <
typename A, 
int Size>
 
   42   for (
int i = 0; i < Size; ++i)
 
   44     ret[i] = v1[i] + v2[i];
 
   51 template <
typename A, 
int Size>
 
   55   for (
int i = 0; i < Size; ++i)
 
   57     ret[i] = v1[i] - v2[i];
 
   64 template <
typename A, 
int Size>
 
   68   for (
int i = 0; i < Size; ++i)
 
   70     ret[i] = v1[i] * v2[i];
 
   77 template <
typename A, 
typename B, 
int Size>
 
   81   for (
int i = 0; i < Size; ++i)
 
   83     ret[i] = v1[i] * scalar;
 
   90 template <
typename A, 
int Size>
 
   94   for (
int i = 0; i < Size; ++i)
 
   96     ret[i] = v1[i] / v2[i];
 
  103 #define vtkVectorOperatorNegate(vectorType, type, size)                                            \ 
  104   inline vectorType operator-(const vectorType& v)                                                 \ 
  106     return vectorType((-static_cast<vtkVector<type, size> >(v)).GetData());                        \ 
  108 #define vtkVectorOperatorPlus(vectorType, type, size)                                              \ 
  109   inline vectorType operator+(const vectorType& v1, const vectorType& v2)                          \ 
  112       (static_cast<vtkVector<type, size> >(v1) + static_cast<vtkVector<type, size> >(v2))          \ 
  115 #define vtkVectorOperatorMinus(vectorType, type, size)                                             \ 
  116   inline vectorType operator-(const vectorType& v1, const vectorType& v2)                          \ 
  119       (static_cast<vtkVector<type, size> >(v1) - static_cast<vtkVector<type, size> >(v2))          \ 
  122 #define vtkVectorOperatorMultiply(vectorType, type, size)                                          \ 
  123   inline vectorType operator*(const vectorType& v1, const vectorType& v2)                          \ 
  126       (static_cast<vtkVector<type, size> >(v1) * static_cast<vtkVector<type, size> >(v2))          \ 
  129 #define vtkVectorOperatorMultiplyScalar(vectorType, type, size)                                    \ 
  130   template <typename B>                                                                            \ 
  131   inline vectorType operator*(const vectorType& v1, const B& scalar)                               \ 
  133     return vectorType((static_cast<vtkVector<type, size> >(v1) * scalar).GetData());               \ 
  135 #define vtkVectorOperatorMultiplyScalarPre(vectorType, type, size)                                 \ 
  136   template <typename B>                                                                            \ 
  137   inline vectorType operator*(const B& scalar, const vectorType& v1)                               \ 
  139     return vectorType((static_cast<vtkVector<type, size> >(v1) * scalar).GetData());               \ 
  141 #define vtkVectorOperatorDivide(vectorType, type, size)                                            \ 
  142   inline vectorType operator/(const vectorType& v1, const vectorType& v2)                          \ 
  145       (static_cast<vtkVector<type, size> >(v1) / static_cast<vtkVector<type, size> >(v2))          \ 
  149 #define vtkVectorOperatorMacro(vectorType, type, size)                                             \ 
  150   vtkVectorOperatorNegate(vectorType, type, size);                                                 \ 
  151   vtkVectorOperatorPlus(vectorType, type, size);                                                   \ 
  152   vtkVectorOperatorMinus(vectorType, type, size);                                                  \ 
  153   vtkVectorOperatorMultiply(vectorType, type, size);                                               \ 
  154   vtkVectorOperatorMultiplyScalar(vectorType, type, size);                                         \ 
  155   vtkVectorOperatorMultiplyScalarPre(vectorType, type, size);                                      \ 
  156   vtkVectorOperatorDivide(vectorType, type, size) 
  
templated base type for storage of vectors.
vtkVector< A, Size > operator*(const vtkVector< A, Size > &v1, const vtkVector< A, Size > &v2)
vtkVector< A, Size > operator/(const vtkVector< A, Size > &v1, const vtkVector< A, Size > &v2)
vtkVector< A, Size > operator-(const vtkVector< A, Size > &v)
Some derived classes for the different vectors commonly used.
#define vtkVectorOperatorMacro(vectorType, type, size)
vtkVector< A, Size > operator+(const vtkVector< A, Size > &v1, const vtkVector< A, Size > &v2)