8 #ifndef _PyImathVec2Impl_h_
9 #define _PyImathVec2Impl_h_
18 #define HBOOST_BIND_GLOBAL_PLACEHOLDERS
19 #include <hboost/python.hpp>
20 #include <hboost/python/make_constructor.hpp>
21 #include <hboost/format.hpp>
22 #include <hboost/cast.hpp>
34 using namespace hboost::python;
41 static Vec2<T> * Vec2_construct_default()
46 template <
class T,
class BoostPyType>
47 static Vec2<T> * Vec2_tuple_constructor(
const BoostPyType &
t)
49 if(t.attr(
"__len__")() == 1)
50 return new Vec2<T>(extract<T>(t[0]), extract<T>(t[0]));
51 else if(t.attr(
"__len__")() == 2)
52 return new Vec2<T>(extract<T>(t[0]), extract<T>(t[1]));
54 throw std::invalid_argument (
"Vec2 constructor expects tuple of length 1 or 2");
58 static Vec2<T> * Vec2_object_constructor1(
const object &obj)
61 extract<Vec2<int> >
e1(obj);
62 extract<Vec2<float> >
e2(obj);
63 extract<Vec2<double> > e3(obj);
64 extract<tuple>
e4(obj);
65 extract<double> e5(obj);
66 extract<list> e6(obj);
68 if(
e1.check()){ w =
e1(); }
69 else if(
e2.check()) { w =
e2(); }
70 else if(e3.check()) { w = e3(); }
74 if(t.attr(
"__len__")() == 2)
76 w.
x = extract<T>(t[0]);
77 w.
y = extract<T>(t[1]);
80 throw std::invalid_argument (
"tuple must have length of 2");
82 else if(e5.check()) {
T a = e5(); w.
setValue(a, a); }
86 if(l.attr(
"__len__")() == 2)
88 w.
x = extract<T>(l[0]);
89 w.
y = extract<T>(l[1]);
92 throw std::invalid_argument (
"list must have length of 2");
95 throw std::invalid_argument (
"invalid parameters passed to Vec2 constructor");
105 static Vec2<T> * Vec2_object_constructor2(
const object &obj1,
const object &obj2)
107 extract<double>
e1(obj1);
108 extract<double>
e2(obj2);
112 if(
e1.check()) { v->
x = hboost::numeric_cast<
T>(
e1());}
113 else {
throw std::invalid_argument (
"invalid parameters passed to Vec2 constructor"); }
115 if(
e2.check()) { v->
y = hboost::numeric_cast<
T>(
e2());}
116 else {
throw std::invalid_argument (
"invalid parameters passed to Vec2 constructor"); }
124 static std::string Vec2_str(
const Vec2<T> &v)
131 static std::string Vec2_repr(
const Vec2<T> &v)
140 Vec2_cross(
const IMATH_NAMESPACE::Vec2<T> &v,
const IMATH_NAMESPACE::Vec2<T> &other)
143 return v.cross(other);
148 Vec2_cross_Vec2Array(
const IMATH_NAMESPACE::Vec2<T> &va,
const FixedArray<IMATH_NAMESPACE::Vec2<T> > &vb)
151 size_t len = vb.len();
152 FixedArray<T>
f(len);
153 for (
size_t i = 0; i < len; ++i)
154 f[i] = va.cross(vb[i]);
160 Vec2_dot(
const IMATH_NAMESPACE::Vec2<T> &v,
const IMATH_NAMESPACE::Vec2<T> &other)
168 Vec2_dot_Vec2Array(
const IMATH_NAMESPACE::Vec2<T> &va,
const FixedArray<IMATH_NAMESPACE::Vec2<T> > &vb)
171 size_t len = vb.len();
172 FixedArray<T>
f(len);
173 for (
size_t i = 0; i < len; ++i)
174 f[i] = va.dot(vb[i]);
180 Vec2_length(
const IMATH_NAMESPACE::Vec2<T> &v)
188 Vec2_length2(
const IMATH_NAMESPACE::Vec2<T> &v)
196 Vec2_normalize(IMATH_NAMESPACE::Vec2<T> &v)
199 return v.normalize();
204 Vec2_normalizeExc(IMATH_NAMESPACE::Vec2<T> &v)
207 return v.normalizeExc();
212 Vec2_normalizeNonNull(IMATH_NAMESPACE::Vec2<T> &v)
215 return v.normalizeNonNull();
220 Vec2_normalized(
const IMATH_NAMESPACE::Vec2<T> &v)
223 return v.normalized();
228 Vec2_normalizedExc(
const IMATH_NAMESPACE::Vec2<T> &v)
231 return v.normalizedExc();
236 Vec2_normalizedNonNull(
const IMATH_NAMESPACE::Vec2<T> &v)
239 return v.normalizedNonNull();
247 return IMATH_NAMESPACE::closestVertex(v0, v1, v2, p);
252 Vec2_negate(IMATH_NAMESPACE::Vec2<T> &v)
263 return IMATH_NAMESPACE::orthogonal(v, v0);
271 return IMATH_NAMESPACE::project(v0, v);
279 return IMATH_NAMESPACE::reflect(v, v0);
314 template <
class T,
class U>
325 Vec2_mulT (
const Vec2<T> &v, T t)
332 static FixedArray<IMATH_NAMESPACE::Vec2<T> >
333 Vec2_mulTArray (
const Vec2<T> &v,
const FixedArray<T> &t)
336 size_t len = t.len();
337 FixedArray<IMATH_NAMESPACE::Vec2<T> > retval(len);
338 for (
size_t i=0; i<len; ++i) retval[i] = v*t[i];
343 static FixedArray<IMATH_NAMESPACE::Vec2<T> >
344 Vec2_rmulTArray (
const Vec2<T> &v,
const FixedArray<T> &t)
346 return Vec2_mulTArray(v,t);
349 template <
class T,
class S>
365 template <
class T,
class U>
375 Vec2_imulT(IMATH_NAMESPACE::Vec2<T> &v, T t)
381 template <
class T,
class U>
389 template <
class T,
class U>
399 Vec2_idivObj(IMATH_NAMESPACE::Vec2<T> &v,
const object &o)
409 extract<double> e(o);
413 throw std::invalid_argument (
"V2 division expects an argument"
414 "convertible to a V2");
420 Vec2_subT(
const Vec2<T> &v, T a)
428 template <
class T,
class BoostPyType>
430 Vec2_subTuple(
const Vec2<T> &v,
const BoostPyType &t)
435 if(t.attr(
"__len__")() == 2)
437 w.
x = v.
x - extract<T>(t[0]);
438 w.
y = v.
y - extract<T>(t[1]);
441 throw std::invalid_argument (
"tuple must have length of 2");
448 Vec2_rsubT(
const Vec2<T> &v, T a)
456 template <
class T,
class BoostPyType>
458 Vec2_rsubTuple(
const Vec2<T> &v,
const BoostPyType &t)
463 if(t.attr(
"__len__")() == 2)
465 w.
x = extract<T>(t[0]) - v.
x;
466 w.
y = extract<T>(t[1]) - v.
y;
469 throw std::invalid_argument (
"tuple must have length of 2");
474 template <
class T,
class BoostPyType>
476 Vec2_addTuple(
const Vec2<T> &v,
const BoostPyType &t)
481 if(t.attr(
"__len__")() == 2)
483 w.
x = v.
x + extract<T>(t[0]);
484 w.
y = v.
y + extract<T>(t[1]);
487 throw std::invalid_argument (
"tuple must have length of 2");
494 Vec2_addT(
const Vec2<T> &v, T a)
502 template <
class T,
class U>
510 template <
class T,
class U>
518 template <
class T,
class U>
526 template <
class T,
class U>
534 template <
class T,
class BoostPyType>
536 Vec2_mulTuple(
const Vec2<T> &v, BoostPyType t)
541 if(t.attr(
"__len__")() == 1){
542 w.
x = v.
x*extract<T>(t[0]);
543 w.
y = v.
y*extract<T>(t[0]);
545 else if(t.attr(
"__len__")() == 2){
546 w.
x = v.
x*extract<T>(t[0]);
547 w.
y = v.
y*extract<T>(t[1]);
550 throw std::invalid_argument (
"tuple must have length of 1 or 2");
555 template <
class T,
class U>
563 template <
class T,
class U>
571 template <
class T,
class BoostPyType>
573 Vec2_divTuple(
const Vec2<T> &v,
const BoostPyType &t)
575 if(t.attr(
"__len__")() == 2)
577 T x = extract<T>(t[0]);
578 T y = extract<T>(t[1]);
579 if(x !=
T(0) && y !=
T(0))
582 throw std::domain_error (
"Division by zero");
585 throw std::invalid_argument (
"Vec2 expects tuple of length 2");
588 template <
class T,
class BoostPyType>
590 Vec2_rdivTuple(
const Vec2<T> &v,
const BoostPyType &t)
594 if(t.attr(
"__len__")() == 2)
596 T x = extract<T>(t[0]);
597 T y = extract<T>(t[1]);
599 if(v.
x !=
T(0) && v.
y !=
T(0)){
603 throw std::domain_error (
"Division by zero");
606 throw std::invalid_argument (
"tuple must have length of 2");
613 Vec2_divT(
const Vec2<T> &v, T a)
621 throw std::domain_error (
"Division by zero");
628 Vec2_rdivT(
const Vec2<T> &v, T a)
632 if(v.
x !=
T(0) && v.
y !=
T(0)){
636 throw std::domain_error (
"Division by zero");
643 lessThan(
const Vec2<T> &v,
const object &obj)
645 extract<Vec2<T> >
e1(obj);
646 extract<tuple>
e2(obj);
656 if(t.attr(
"__len__")() == 2){
657 T x = extract<T>(t[0]);
658 T y = extract<T>(t[1]);
662 throw std::invalid_argument (
"Vec2 expects tuple of length 2");
665 throw std::invalid_argument (
"invalid parameters passed to operator <");
667 bool isLessThan = (v.
x <= w.
x && v.
y <= w.
y)
675 greaterThan(
const Vec2<T> &v,
const object &obj)
677 extract<Vec2<T> >
e1(obj);
678 extract<tuple>
e2(obj);
688 if(t.attr(
"__len__")() == 2){
689 T x = extract<T>(t[0]);
690 T y = extract<T>(t[1]);
694 throw std::invalid_argument (
"Vec2 expects tuple of length 2");
697 throw std::invalid_argument (
"invalid parameters passed to operator >");
699 bool isGreaterThan = (v.
x >= w.
x && v.
y >= w.
y)
702 return isGreaterThan;
707 lessThanEqual(
const Vec2<T> &v,
const object &obj)
709 extract<Vec2<T> >
e1(obj);
710 extract<tuple>
e2(obj);
720 if(t.attr(
"__len__")() == 2){
721 T x = extract<T>(t[0]);
722 T y = extract<T>(t[1]);
726 throw std::invalid_argument (
"Vec2 expects tuple of length 2");
729 throw std::invalid_argument (
"invalid parameters passed to operator <=");
731 bool isLessThanEqual = (v.
x <= w.
x && v.
y <= w.
y);
733 return isLessThanEqual;
738 greaterThanEqual(
const Vec2<T> &v,
const object &obj)
740 extract<Vec2<T> >
e1(obj);
741 extract<tuple>
e2(obj);
751 if(t.attr(
"__len__")() == 2){
752 T x = extract<T>(t[0]);
753 T y = extract<T>(t[1]);
757 throw std::invalid_argument (
"Vec2 expects tuple of length 2");
760 throw std::invalid_argument (
"invalid parameters passed to operator >=");
762 bool isGreaterThanEqual = (v.
x >= w.
x && v.
y >= w.
y);
764 return isGreaterThanEqual;
767 template <
class T,
class BoostPyType>
769 setItemTuple(FixedArray<IMATH_NAMESPACE::Vec2<T> > &va, Py_ssize_t
index,
const BoostPyType &t)
771 if(t.attr(
"__len__")() == 2)
774 v.
x = extract<T>(t[0]);
775 v.
y = extract<T>(t[1]);
776 va[va.canonical_index(index)] =
v;
779 throw std::invalid_argument (
"tuple of length 2 expected");
784 equalWithAbsErrorObj(
const Vec2<T> &v,
const object &obj1,
const object &obj2)
786 extract<Vec2<int> >
e1(obj1);
787 extract<Vec2<float> >
e2(obj1);
788 extract<Vec2<double> > e3(obj1);
790 extract<tuple>
e4(obj1);
791 extract<double> e5(obj2);
794 if(
e1.check()) { w =
e1(); }
795 else if(
e2.check()) { w =
e2(); }
796 else if(e3.check()) { w = e3(); }
800 if(t.attr(
"__len__")() == 2)
802 w.
x = extract<T>(t[0]);
803 w.
y = extract<T>(t[1]);
806 throw std::invalid_argument (
"tuple of length 2 expected");
809 throw std::invalid_argument (
"invalid parameters passed to equalWithAbsError");
813 throw std::invalid_argument (
"invalid parameters passed to equalWithAbsError");
818 equalWithRelErrorObj(
const Vec2<T> &v,
const object &obj1,
const object &obj2)
820 extract<Vec2<int> >
e1(obj1);
821 extract<Vec2<float> >
e2(obj1);
822 extract<Vec2<double> > e3(obj1);
824 extract<tuple>
e4(obj1);
825 extract<double> e5(obj2);
828 if(
e1.check()) { w =
e1(); }
829 else if(
e2.check()) { w =
e2(); }
830 else if(e3.check()) { w = e3(); }
834 if(t.attr(
"__len__")() == 2)
836 w.
x = extract<T>(t[0]);
837 w.
y = extract<T>(t[1]);
840 throw std::invalid_argument (
"tuple of length 2 expected");
843 throw std::invalid_argument (
"invalid parameters passed to equalWithRelError");
847 throw std::invalid_argument (
"invalid parameters passed to equalWithRelError");
885 template <
class T,
class BoostPyType>
890 if(t.attr(
"__len__")() == 2)
892 w.
x = extract<T>(t[0]);
893 w.
y = extract<T>(t[1]);
898 throw std::invalid_argument (
"tuple of length 2 expected");
901 template <
class T,
class BoostPyType>
903 notequal(
const Vec2<T> &v,
const BoostPyType &t)
906 if(t.attr(
"__len__")() == 2)
908 w.
x = extract<T>(t[0]);
909 w.
y = extract<T>(t[1]);
914 throw std::invalid_argument (
"tuple of length 2 expected");
924 .def(
"length", &Vec2_length<T>,
"length() magnitude of the vector")
925 .def(
"normalize", &Vec2_normalize<T>,return_internal_reference<>(),
926 "v.normalize() destructively normalizes v and returns a reference to it")
927 .def(
"normalizeExc", &Vec2_normalizeExc<T>,return_internal_reference<>(),
928 "v.normalizeExc() destructively normalizes V and returns a reference to it, throwing an exception if length() == 0")
929 .def(
"normalizeNonNull", &Vec2_normalizeNonNull<T>,return_internal_reference<>(),
930 "v.normalizeNonNull() destructively normalizes V and returns a reference to it, faster if lngth() != 0")
931 .def(
"normalized", &Vec2_normalized<T>,
"v.normalized() returns a normalized copy of v")
932 .def(
"normalizedExc", &Vec2_normalizedExc<T>,
"v.normalizedExc() returns a normalized copy of v, throwing an exception if length() == 0")
933 .def(
"normalizedNonNull", &Vec2_normalizedNonNull<T>,
"v.normalizedNonNull() returns a normalized copy of v, faster if lngth() != 0")
934 .def(
"orthogonal", &orthogonal<T>)
935 .def(
"project", &project<T>)
936 .def(
"reflect", &reflect<T>)
955 .def(
"__init__",make_constructor(Vec2_construct_default<T>),
"initialize to (0,0)")
956 .def(
"__init__",make_constructor(Vec2_object_constructor1<T>))
957 .def(
"__init__",make_constructor(Vec2_object_constructor2<T>))
961 .staticmethod(
"baseTypeEpsilon")
962 .def(
"baseTypeMax", &
Vec2<T>::baseTypeMax,
"baseTypeMax() max value of the base type of the vector")
963 .staticmethod(
"baseTypeMax")
964 .def(
"baseTypeLowest", &
Vec2<T>::baseTypeLowest,
"baseTypeLowest() largest negative value of the base type of the vector")
965 .staticmethod(
"baseTypeLowest")
967 .staticmethod(
"baseTypeSmallest")
968 .def(
"cross", &Vec2_cross<T>,
"v1.cross(v2) right handed cross product")
969 .def(
"cross", &Vec2_cross_Vec2Array<T>,
"v1.cross(v2) right handed array cross product")
971 .staticmethod(
"dimensions")
972 .def(
"dot", &Vec2_dot<T>,
"v1.dot(v2) inner product of the two vectors")
973 .def(
"dot", &Vec2_dot_Vec2Array<T>,
"v1.dot(v2) array inner product")
975 "v1.equalWithAbsError(v2) true if the elements "
976 "of v1 and v2 are the same with an absolute error of no more than e, "
977 "i.e., abs(v1[i] - v2[i]) <= e")
978 .def(
"equalWithAbsError", &equalWithAbsErrorObj<T>)
981 "v1.equalWithAbsError(v2) true if the elements "
982 "of v1 and v2 are the same with an absolute error of no more than e, "
983 "i.e., abs(v1[i] - v2[i]) <= e * abs(v1[i])")
984 .def(
"equalWithRelError", &equalWithRelErrorObj<T>)
986 .def(
"length2", &Vec2_length2<T>,
"length2() square magnitude of the vector")
987 .def(
"__len__", Vec2_helper::len)
988 .def(
"__getitem__", Vec2_helper::getitem,return_value_policy<copy_non_const_reference>())
989 .def(
"__setitem__", Vec2_helper::setitem)
990 .def(
"closestVertex", &closestVertex<T>)
991 .def(
"negate", &Vec2_negate<T>, return_internal_reference<>())
992 .def(
"setValue", &setValue<T>)
993 .def(
"__neg__", &Vec2_neg<T>)
994 .def(
"__mul__", &Vec2_mul<T, int>)
995 .def(
"__mul__", &Vec2_mul<T, float>)
996 .def(
"__mul__", &Vec2_mul<T, double>)
997 .def(
"__mul__", &Vec2_mulT<T>)
998 .def(
"__mul__", &Vec2_mulTArray<T>)
999 .def(
"__mul__", &Vec2_mulTuple<T,tuple>)
1000 .def(
"__mul__", &Vec2_mulTuple<T,list>)
1001 .def(
"__rmul__", &Vec2_rmulT<T>)
1002 .def(
"__rmul__", &Vec2_rmulTArray<T>)
1003 .def(
"__rmul__", &Vec2_mulTuple<T,tuple>)
1004 .def(
"__rmul__", &Vec2_mulTuple<T,list>)
1005 .def(
"__imul__", &Vec2_imulV<T, int>,return_internal_reference<>())
1006 .def(
"__imul__", &Vec2_imulV<T, float>,return_internal_reference<>())
1007 .def(
"__imul__", &Vec2_imulV<T, double>,return_internal_reference<>())
1008 .def(
"__imul__", &Vec2_imulT<T>,return_internal_reference<>())
1010 .def(
"__mul__", &Vec2_mulM22<T, float>)
1011 .def(
"__mul__", &Vec2_mulM22<T, double>)
1012 .def(
"__mul__", &Vec2_mulM33<T, float>)
1013 .def(
"__mul__", &Vec2_mulM33<T, double>)
1014 .def(
"__imul__", &Vec2_imulM22<T, float>, return_internal_reference<>())
1015 .def(
"__imul__", &Vec2_imulM22<T, double>, return_internal_reference<>())
1016 .def(
"__imul__", &Vec2_imulM33<T, float>, return_internal_reference<>())
1017 .def(
"__imul__", &Vec2_imulM33<T, double>, return_internal_reference<>())
1019 .def(
"__div__", &Vec2_div<T,int>)
1020 .def(
"__div__", &Vec2_div<T,float>)
1021 .def(
"__div__", &Vec2_div<T,double>)
1022 .def(
"__div__", &Vec2_divTuple<T,tuple>)
1023 .def(
"__div__", &Vec2_divTuple<T,list>)
1024 .def(
"__div__", &Vec2_divT<T>)
1025 .def(
"__truediv__", &Vec2_div<T,int>)
1026 .def(
"__truediv__", &Vec2_div<T,float>)
1027 .def(
"__truediv__", &Vec2_div<T,double>)
1028 .def(
"__truediv__", &Vec2_divTuple<T,tuple>)
1029 .def(
"__truediv__", &Vec2_divTuple<T,list>)
1030 .def(
"__truediv__", &Vec2_divT<T>)
1031 .def(
"__rdiv__", &Vec2_rdivTuple<T,tuple>)
1032 .def(
"__rdiv__", &Vec2_rdivTuple<T,list>)
1033 .def(
"__rdiv__", &Vec2_rdivT<T>)
1034 .def(
"__rtruediv__", &Vec2_rdivTuple<T,tuple>)
1035 .def(
"__rtruediv__", &Vec2_rdivTuple<T,list>)
1036 .def(
"__rtruediv__", &Vec2_rdivT<T>)
1037 .def(
"__idiv__", &Vec2_idivObj<T>,return_internal_reference<>())
1038 .def(
"__itruediv__", &Vec2_idivObj<T>,return_internal_reference<>())
1039 .def(
"__xor__", &Vec2_dot<T>)
1040 .def(
"__mod__", &Vec2_cross<T>)
1043 .def(
"__eq__", &equal<T,tuple>)
1044 .def(
"__ne__", ¬equal<T,tuple>)
1045 .def(
"__add__", &Vec2_add<T>)
1046 .def(
"__add__", &Vec2_addV<T, int>)
1047 .def(
"__add__", &Vec2_addV<T, float>)
1048 .def(
"__add__", &Vec2_addV<T, double>)
1049 .def(
"__add__", &Vec2_addT<T>)
1050 .def(
"__add__", &Vec2_addTuple<T,tuple>)
1051 .def(
"__add__", &Vec2_addTuple<T,list>)
1052 .def(
"__radd__", &Vec2_add<T>)
1053 .def(
"__radd__", &Vec2_addT<T>)
1054 .def(
"__radd__", &Vec2_addTuple<T,tuple>)
1055 .def(
"__radd__", &Vec2_addTuple<T,list>)
1056 .def(
"__iadd__", &Vec2_iaddV<T, int>, return_internal_reference<>())
1057 .def(
"__iadd__", &Vec2_iaddV<T, float>, return_internal_reference<>())
1058 .def(
"__iadd__", &Vec2_iaddV<T, double>, return_internal_reference<>())
1059 .def(
"__sub__", &Vec2_sub<T>)
1060 .def(
"__sub__", &Vec2_subV<T, int>)
1061 .def(
"__sub__", &Vec2_subV<T, float>)
1062 .def(
"__sub__", &Vec2_subV<T, double>)
1063 .def(
"__sub__", &Vec2_subT<T>)
1064 .def(
"__sub__", &Vec2_subTuple<T,tuple>)
1065 .def(
"__sub__", &Vec2_subTuple<T,list>)
1066 .def(
"__rsub__", &Vec2_rsubT<T>)
1067 .def(
"__rsub__", &Vec2_rsubTuple<T,tuple>)
1068 .def(
"__rsub__", &Vec2_rsubTuple<T,list>)
1069 .def(
"__isub__", &Vec2_isubV<T, int>, return_internal_reference<>())
1070 .def(
"__isub__", &Vec2_isubV<T, float>, return_internal_reference<>())
1071 .def(
"__isub__", &Vec2_isubV<T, double>, return_internal_reference<>())
1072 .def(
"__lt__", &lessThan<T>)
1073 .def(
"__gt__", &greaterThan<T>)
1074 .def(
"__le__", &lessThanEqual<T>)
1075 .def(
"__ge__", &greaterThanEqual<T>)
1077 .def(
"__str__",&Vec2_str<T>)
1078 .def(
"__repr__",&Vec2_repr<T>)
1081 register_Vec2_floatonly<T>(vec2_class);
1092 template <
class T,
int index>
1093 static FixedArray<T>
1094 Vec2Array_get(FixedArray<IMATH_NAMESPACE::Vec2<T> > &va)
1096 return FixedArray<T>(va.unchecked_index(0).getValue () + index,
1097 va.len(), 2*va.stride(), va.handle(), va.writable());
1101 static IMATH_NAMESPACE::Vec2<T>
1102 Vec2Array_min(
const FixedArray<IMATH_NAMESPACE::Vec2<T> > &a)
1105 size_t len = a.len();
1108 for (
size_t i=1; i < len; ++i)
1119 static IMATH_NAMESPACE::Vec2<T>
1120 Vec2Array_max(
const FixedArray<IMATH_NAMESPACE::Vec2<T> > &a)
1123 size_t len = a.len();
1126 for (
size_t i=1; i < len; ++i)
1137 static IMATH_NAMESPACE::Box<IMATH_NAMESPACE::Vec2<T> >
1138 Vec2Array_bounds(
const FixedArray<IMATH_NAMESPACE::Vec2<T> > &a)
1141 size_t len = a.len();
1142 for (
size_t i=0; i < len; ++i)
1152 generate_member_bindings<op_vecLength<IMATH_NAMESPACE::Vec2<T> > >(vec2Array_class,
"length",
"");
1153 generate_member_bindings<op_vecNormalize<IMATH_NAMESPACE::Vec2<T> > >(vec2Array_class,
"normalize",
"");
1154 generate_member_bindings<op_vecNormalized<IMATH_NAMESPACE::Vec2<T> > >(vec2Array_class,
"normalized",
"");
1155 generate_member_bindings<op_vecNormalizeExc<IMATH_NAMESPACE::Vec2<T> > >(vec2Array_class,
"normalizeExc",
"");
1156 generate_member_bindings<op_vecNormalizedExc<IMATH_NAMESPACE::Vec2<T> > >(vec2Array_class,
"normalizedExc",
"");
1167 class_<FixedArray<IMATH_NAMESPACE::Vec2<T> > >
1170 using hboost::mpl::true_;
1171 using hboost::mpl::false_;
1175 .add_property(
"x",&Vec2Array_get<T,0>)
1176 .add_property(
"y",&Vec2Array_get<T,1>)
1177 .def(
"__setitem__", &setItemTuple<T,tuple>)
1178 .def(
"__setitem__", &setItemTuple<T,list>)
1179 .def(
"min", &Vec2Array_min<T>)
1180 .def(
"max", &Vec2Array_max<T>)
1181 .def(
"bounds", &Vec2Array_bounds<T>)
1184 add_arithmetic_math_functions(vec2Array_class);
1185 add_comparison_functions(vec2Array_class);
1188 generate_member_bindings<op_vecLength2<IMATH_NAMESPACE::Vec2<T> > >(vec2Array_class,
"length2",
"");
1189 generate_member_bindings<op_vec2Cross<T>, true_>(vec2Array_class,
"cross",
"return the cross product of (self,x)",
hboost::python::args(
"x"));
1190 generate_member_bindings<op_vecDot<IMATH_NAMESPACE::Vec2<T> >,true_>(vec2Array_class,
"dot",
"return the inner product of (self,x)",
hboost::python::args(
"x"));
1192 generate_member_bindings<op_mul<IMATH_NAMESPACE::Vec2<T>,
T>, true_>(vec2Array_class,
"__mul__" ,
"self*x",
hboost::python::args(
"x"));
1193 generate_member_bindings<op_mul<IMATH_NAMESPACE::Vec2<T>,T>, true_>(vec2Array_class,
"__rmul__",
"x*self",
hboost::python::args(
"x"));
1194 generate_member_bindings<op_imul<IMATH_NAMESPACE::Vec2<T>,T>, true_>(vec2Array_class,
"__imul__",
"self*=x",
hboost::python::args(
"x"));
1195 generate_member_bindings<op_div<IMATH_NAMESPACE::Vec2<T>,T>, true_>(vec2Array_class,
"__div__" ,
"self/x",
hboost::python::args(
"x"));
1196 generate_member_bindings<op_div<IMATH_NAMESPACE::Vec2<T>,T>, true_>(vec2Array_class,
"__truediv__" ,
"self/x",
hboost::python::args(
"x"));
1197 generate_member_bindings<op_idiv<IMATH_NAMESPACE::Vec2<T>,T>, true_>(vec2Array_class,
"__idiv__",
"self/=x",
hboost::python::args(
"x"));
1198 generate_member_bindings<op_idiv<IMATH_NAMESPACE::Vec2<T>,T>, true_>(vec2Array_class,
"__itruediv__",
"self/=x",
hboost::python::args(
"x"));
1202 return vec2Array_class;
void register_Vec2Array_floatonly(class_< FixedArray< Vec2< T >>> &vec2Array_class)
void register_Vec2_floatonly(class_< Vec2< T >> &vec2_class)
GLsizei const GLfloat * value
IMATH_CONSTEXPR14 Vec3< T > closestVertex(const Vec3< T > &v0, const Vec3< T > &v1, const Vec3< T > &v2, const Line3< T > &l) IMATH_NOEXCEPT
IMATH_HOSTDEVICE void extendBy(const V &point) IMATH_NOEXCEPT
Extend the box to include the given point.
GLboolean GLboolean GLboolean GLboolean a
IMATH_HOSTDEVICE constexpr bool equal(T1 a, T2 b, T3 t) IMATH_NOEXCEPT
hboost::python::class_< IMATH_NAMESPACE::Vec2< T > > register_Vec2()
GLfloat GLfloat GLfloat v2
hboost::python::class_< FixedArray< IMATH_NAMESPACE::Vec2< T > > > register_Vec2Array()
static const char * value
GLboolean GLboolean GLboolean b
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 bool equalWithRelError(const Vec2< T > &v, T e) const IMATH_NOEXCEPT
#define PY_IMATH_LEAVE_PYTHON
**If you just want to fire and args
GLubyte GLubyte GLubyte GLubyte w
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 bool equalWithAbsError(const Vec2< T > &v, T e) const IMATH_NOEXCEPT
hboost::python::class_< T, X1, X2, X3 > & decoratecopy(hboost::python::class_< T, X1, X2, X3 > &cls)
IMATH_HOSTDEVICE void setValue(S a, S b) IMATH_NOEXCEPT
Set the value.