Go to the documentation of this file.
10 #ifndef vtk_m_VectorAnalysis_h
11 #define vtk_m_VectorAnalysis_h
31 template <
typename ValueType,
typename WeightType>
33 const ValueType& value1,
34 const WeightType& weight)
36 using ScalarType =
typename detail::FloatingPointReturnType<ValueType>::Type;
37 return static_cast<ValueType
>((WeightType(1) - weight) *
static_cast<ScalarType
>(value0) +
38 weight *
static_cast<ScalarType
>(value1));
40 template <
typename ValueType, vtkm::IdComponent N,
typename WeightType>
43 const WeightType& weight)
45 return (WeightType(1) - weight) * value0 + weight * value1;
47 template <
typename ValueType, vtkm::IdComponent N>
53 return (One - weight) * value0 + weight * value1;
66 using U =
typename detail::FloatingPointReturnType<T>::Type;
67 return static_cast<U
>(vtkm::Dot(x, x));
74 VTKM_EXEC_CONT typename detail::FloatingPointReturnType<T>::Type MagnitudeTemplate(
78 return static_cast<typename detail::FloatingPointReturnType<T>::Type
>(vtkm::Abs(x));
82 VTKM_EXEC_CONT typename detail::FloatingPointReturnType<T>::Type MagnitudeTemplate(
108 template <
typename T>
109 VTKM_EXEC_CONT typename detail::FloatingPointReturnType<T>::Type RMagnitudeTemplate(
113 return T(1) / vtkm::Abs(x);
116 template <
typename T>
117 VTKM_EXEC_CONT typename detail::FloatingPointReturnType<T>::Type RMagnitudeTemplate(
131 template <
typename T>
140 template <
typename T>
143 return vtkm::CopySign(T(1), x);
146 template <
typename T>
157 template <
typename T>
168 template <
typename T>
179 template <
typename T>
201 template <
typename T>
216 template <
typename T,
int N>
219 T uu = vtkm::Dot(u, u);
220 T uv = vtkm::Dot(u, v);
233 template <
typename T,
int N>
236 T uu = vtkm::Dot(u, u);
237 T uv = vtkm::Dot(u, v);
258 template <
typename T,
int N>
261 T tol =
static_cast<T
>(1e-6))
263 T tolsqr = tol * tol;
266 for (
int i = 0; i < N; ++i)
269 for (
int k = 0; k < j; ++k)
274 if (magsqr <= tolsqr)
279 outputs[j] = vtkm::RSqrt(magsqr) * u[j];
282 for (
int i = j; i < N; ++i)
291 #endif //vtk_m_VectorAnalysis_h
Groups connected points that have the same field value.
Definition: Atomic.h:19
vtkm::Float32 Sqrt(vtkm::Float32 x)
Definition: Math.h:943
#define VTKM_EXEC_CONT
Definition: ExportMacros.h:52
vtkm::Vec< T, N > Project(const vtkm::Vec< T, N > &v, const vtkm::Vec< T, N > &u)
Project a vector onto another vector.
Definition: VectorAnalysis.h:217
vtkm::Vec< typename detail::FloatingPointReturnType< T >::Type, 3 > TriangleNormal(const vtkm::Vec< T, 3 > &a, const vtkm::Vec< T, 3 > &b, const vtkm::Vec< T, 3 > &c)
Find the normal of a triangle.
Definition: VectorAnalysis.h:203
ValueType Lerp(const ValueType &value0, const ValueType &value1, const WeightType &weight)
Returns the linear interpolation of two values based on weight.
Definition: VectorAnalysis.h:32
T Normal(const T &x)
Returns a normalized version of the given vector.
Definition: VectorAnalysis.h:158
vtkm::Vec< typename detail::FloatingPointReturnType< T >::Type, 3 > Cross(const vtkm::Vec< T, 3 > &x, const vtkm::Vec< T, 3 > &y)
Find the cross product of two vectors.
Definition: VectorAnalysis.h:180
T DifferenceOfProducts(T a, T b, T c, T d)
Definition: Math.h:2778
detail::FloatingPointReturnType< T >::Type MagnitudeSquared(const T &x)
Returns the square of the magnitude of a vector.
Definition: VectorAnalysis.h:64
T ProjectedDistance(const vtkm::Vec< T, N > &v, const vtkm::Vec< T, N > &u)
Project a vector onto another vector, returning only the projected distance.
Definition: VectorAnalysis.h:234
void Normalize(T &x)
Changes a vector to be normal.
Definition: VectorAnalysis.h:169
detail::FloatingPointReturnType< T >::Type RMagnitude(const T &x)
Returns the reciprocal magnitude of a vector.
Definition: VectorAnalysis.h:132
Tag used to identify types that aren't Real, Integer, Scalar or Vector.
Definition: TypeTraits.h:20
Tag used to identify 0 dimensional types (scalars).
Definition: TypeTraits.h:44
Tag used to identify 1 dimensional types (vectors).
Definition: TypeTraits.h:51
A short fixed-length array.
Definition: Types.h:357
detail::FloatingPointReturnType< T >::Type Magnitude(const T &x)
Returns the magnitude of a vector.
Definition: VectorAnalysis.h:100
int Orthonormalize(const vtkm::Vec< vtkm::Vec< T, N >, N > &inputs, vtkm::Vec< vtkm::Vec< T, N >, N > &outputs, T tol=static_cast< T >(1e-6))
Convert a set of vectors to an orthonormal basis.
Definition: VectorAnalysis.h:259