Debian Codegraph @

src/python/PyImath/PyImathVecOperators.h

raw
1 //
2 // SPDX-License-Identifier: BSD-3-Clause
3 // Copyright Contributors to the OpenEXR Project.
4 //
5
6 // clang-format off
7
8 #ifndef _PyImathVecOperators_h_
9 #define _PyImathVecOperators_h_
10
11 namespace PyImath {
12
13 template <class T>
14 struct op_vecDot {
15 static inline typename T::BaseType apply(const T &a, const T &b) { return a.dot(b); }
16 };
17
18 template <class T,
19 IMATH_ENABLE_IF(!std::is_integral<typename T::BaseType>::value)>
20 struct op_vecLength {
21 static inline typename T::BaseType apply(const T &v) { return v.length(); }
22 };
23
24 template <class T>
25 struct op_vecLength2 {
26 static inline typename T::BaseType apply(const T &v) { return v.length2(); }
27 };
28
29 template <class T,
30 IMATH_ENABLE_IF(!std::is_integral<typename T::BaseType>::value)>
31 struct op_vecNormalize {
32 static inline void apply(T &v) { v.normalize(); }
33 };
34
35 template <class T,
36 IMATH_ENABLE_IF(!std::is_integral<typename T::BaseType>::value)>
37 struct op_vecNormalized {
38 static inline T apply(const T &v) { return v.normalized(); }
39 };
40
41 template <class T,
42 IMATH_ENABLE_IF(!std::is_integral<typename T::BaseType>::value)>
43 struct op_vecNormalizeExc {
44 static inline void apply(T &v) { v.normalizeExc(); }
45 };
46
47 template <class T,
48 IMATH_ENABLE_IF(!std::is_integral<typename T::BaseType>::value)>
49 struct op_vecNormalizedExc {
50 static inline T apply(const T &v) { return v.normalizedExc(); }
51 };
52
53 template <class T>
54 struct op_vec3Cross {
55 static inline IMATH_NAMESPACE::Vec3<T> apply(const IMATH_NAMESPACE::Vec3<T> &a, const IMATH_NAMESPACE::Vec3<T> &b) { return a.cross(b); }
56 };
57
58 template <class T>
59 struct op_vec2Cross {
60 static inline T apply(const IMATH_NAMESPACE::Vec2<T> &a, const IMATH_NAMESPACE::Vec2<T> &b) { return a.cross(b); }
61 };
62
63 } // namespace PyImath
64
65 #endif // _PyImathVecOperators_h_