Go to the documentation of this file.
18 #ifndef viskores_VectorAnalysis_h
19 #define viskores_VectorAnalysis_h
39 template <
typename ValueType,
typename WeightType>
41 const ValueType& value1,
42 const WeightType& weight)
44 using ScalarType =
typename detail::FloatingPointReturnType<ValueType>::Type;
45 return static_cast<ValueType
>((WeightType(1) - weight) *
static_cast<ScalarType
>(value0) +
46 weight *
static_cast<ScalarType
>(value1));
48 template <
typename ValueType, viskores::IdComponent N,
typename WeightType>
51 const WeightType& weight)
53 return (WeightType(1) - weight) * value0 + weight * value1;
55 template <
typename ValueType, viskores::IdComponent N>
61 return (One - weight) * value0 + weight * value1;
74 using U =
typename detail::FloatingPointReturnType<T>::Type;
75 return static_cast<U
>(viskores::Dot(x, x));
82 VISKORES_EXEC_CONT typename detail::FloatingPointReturnType<T>::Type MagnitudeTemplate(
86 return static_cast<typename detail::FloatingPointReturnType<T>::Type
>(viskores::Abs(x));
90 VISKORES_EXEC_CONT typename detail::FloatingPointReturnType<T>::Type MagnitudeTemplate(
107 template <
typename T>
116 template <
typename T>
117 VISKORES_EXEC_CONT typename detail::FloatingPointReturnType<T>::Type RMagnitudeTemplate(
121 return T(1) / viskores::Abs(x);
124 template <
typename T>
125 VISKORES_EXEC_CONT typename detail::FloatingPointReturnType<T>::Type RMagnitudeTemplate(
139 template <
typename T>
148 template <
typename T>
151 return viskores::CopySign(T(1), x);
154 template <
typename T>
165 template <
typename T>
176 template <
typename T>
187 template <
typename T>
209 template <
typename T>
226 template <
typename T,
int N>
230 T uu = viskores::Dot(u, u);
231 T uv = viskores::Dot(u, v);
244 template <
typename T,
int N>
247 T uu = viskores::Dot(u, u);
248 T uv = viskores::Dot(u, v);
269 template <
typename T,
int N>
272 T tol =
static_cast<T
>(1e-6))
274 T tolsqr = tol * tol;
277 for (
int i = 0; i < N; ++i)
280 for (
int k = 0; k < j; ++k)
285 if (magsqr <= tolsqr)
290 outputs[j] = viskores::RSqrt(magsqr) * u[j];
293 for (
int i = j; i < N; ++i)
302 #endif //viskores_VectorAnalysis_h
int Orthonormalize(const viskores::Vec< viskores::Vec< T, N >, N > &inputs, viskores::Vec< viskores::Vec< T, N >, N > &outputs, T tol=static_cast< T >(1e-6))
Convert a set of vectors to an orthonormal basis.
Definition: VectorAnalysis.h:270
T Normal(const T &x)
Returns a normalized version of the given vector.
Definition: VectorAnalysis.h:166
void Normalize(T &x)
Changes a vector to be normal.
Definition: VectorAnalysis.h:177
T ProjectedDistance(const viskores::Vec< T, N > &v, const viskores::Vec< T, N > &u)
Project a vector onto another vector, returning only the projected distance.
Definition: VectorAnalysis.h:245
#define VISKORES_EXEC_CONT
Definition: ExportMacros.h:60
viskores::Float32 Sqrt(viskores::Float32 x)
Definition: Math.h:951
viskores::Vec< typename detail::FloatingPointReturnType< T >::Type, 3 > Cross(const viskores::Vec< T, 3 > &x, const viskores::Vec< T, 3 > &y)
Find the cross product of two vectors.
Definition: VectorAnalysis.h:188
Tag used to identify 0 dimensional types (scalars).
Definition: TypeTraits.h:52
Groups connected points that have the same field value.
Definition: Atomic.h:27
Tag used to identify types that aren't Real, Integer, Scalar or Vector.
Definition: TypeTraits.h:28
detail::FloatingPointReturnType< T >::Type RMagnitude(const T &x)
Returns the reciprocal magnitude of a vector.
Definition: VectorAnalysis.h:140
T DifferenceOfProducts(T a, T b, T c, T d)
Definition: Math.h:2786
viskores::Vec< T, N > Project(const viskores::Vec< T, N > &v, const viskores::Vec< T, N > &u)
Project a vector onto another vector.
Definition: VectorAnalysis.h:227
ValueType Lerp(const ValueType &value0, const ValueType &value1, const WeightType &weight)
Returns the linear interpolation of two values based on weight.
Definition: VectorAnalysis.h:40
detail::FloatingPointReturnType< T >::Type Magnitude(const T &x)
Returns the magnitude of a vector.
Definition: VectorAnalysis.h:108
detail::FloatingPointReturnType< T >::Type MagnitudeSquared(const T &x)
Returns the square of the magnitude of a vector.
Definition: VectorAnalysis.h:72
viskores::Vec< typename detail::FloatingPointReturnType< T >::Type, 3 > TriangleNormal(const viskores::Vec< T, 3 > &a, const viskores::Vec< T, 3 > &b, const viskores::Vec< T, 3 > &c)
Find the normal of a triangle.
Definition: VectorAnalysis.h:211
Tag used to identify 1 dimensional types (vectors).
Definition: TypeTraits.h:59
A short fixed-length array.
Definition: Types.h:365