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>
43 for (
int i = 0; i < Size; ++i)
45 ret[i] = v1[i] + v2[i];
52 template<
typename A,
int Size>
57 for (
int i = 0; i < Size; ++i)
59 ret[i] = v1[i] - v2[i];
66 template<
typename A,
int Size>
71 for (
int i = 0; i < Size; ++i)
73 ret[i] = v1[i] * v2[i];
80 template<
typename A,
typename B,
int Size>
85 for (
int i = 0; i < Size; ++i)
87 ret[i] = v1[i] * scalar;
94 template<
typename A,
int Size>
99 for (
int i = 0; i < Size; ++i)
101 ret[i] = v1[i] / v2[i];
108 #define vtkVectorOperatorNegate(vectorType, type, size) \
109 inline vectorType operator-(const vectorType& v) \
111 return vectorType((-static_cast<vtkVector<type, size> >(v)).GetData()); \
113 #define vtkVectorOperatorPlus(vectorType, type, size) \
114 inline vectorType operator+(const vectorType& v1, const vectorType& v2) \
116 return vectorType((static_cast<vtkVector<type, size> >(v1) + \
117 static_cast<vtkVector<type, size> >(v2)).GetData()); \
119 #define vtkVectorOperatorMinus(vectorType, type, size) \
120 inline vectorType operator-(const vectorType& v1, const vectorType& v2) \
122 return vectorType((static_cast<vtkVector<type, size> >(v1) - \
123 static_cast<vtkVector<type, size> >(v2)).GetData()); \
125 #define vtkVectorOperatorMultiply(vectorType, type, size) \
126 inline vectorType operator*(const vectorType& v1, const vectorType& v2) \
128 return vectorType((static_cast<vtkVector<type, size> >(v1) * \
129 static_cast<vtkVector<type, size> >(v2)).GetData()); \
131 #define vtkVectorOperatorMultiplyScalar(vectorType, type, size) \
132 template<typename B> \
133 inline vectorType operator*(const vectorType& v1, const B& scalar) \
135 return vectorType((static_cast<vtkVector<type, size> >(v1) * scalar).GetData()); \
137 #define vtkVectorOperatorMultiplyScalarPre(vectorType, type, size) \
138 template<typename B> \
139 inline vectorType operator*(const B& scalar, const vectorType& v1) \
141 return vectorType((static_cast<vtkVector<type, size> >(v1) * scalar).GetData()); \
143 #define vtkVectorOperatorDivide(vectorType, type, size) \
144 inline vectorType operator/(const vectorType& v1, const vectorType& v2) \
146 return vectorType((static_cast<vtkVector<type, size> >(v1) / \
147 static_cast<vtkVector<type, size> >(v2)).GetData()); \
150 #define vtkVectorOperatorMacro(vectorType, type, size) \
151 vtkVectorOperatorNegate(vectorType, type, size) \
152 vtkVectorOperatorPlus(vectorType, type, size) \
153 vtkVectorOperatorMinus(vectorType, type, size) \
154 vtkVectorOperatorMultiply(vectorType, type, size) \
155 vtkVectorOperatorMultiplyScalar(vectorType, type, size) \
156 vtkVectorOperatorMultiplyScalarPre(vectorType, type, size) \
157 vtkVectorOperatorDivide(vectorType, type, size)
templated base type for storage of vectors.
#define vtkVectorOperatorMacro(vectorType, type, size)
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)
Some derived classes for the different vectors commonly used.
vtkVector< A, Size > operator-(const vtkVector< A, Size > &v)
vtkVector< A, Size > operator*(const vtkVector< A, Size > &v1, const vtkVector< A, Size > &v2)