| 17 | namespace py = pybind11; |
| 18 | |
| 19 | void cstrUV(py::module_&m) |
| 20 | { |
| 21 | py::class_<LNLib::UV>(m, "UV") |
| 22 | .def(py::init<>()) |
| 23 | .def(py::init<double, double>()) |
| 24 | .def("SetU", &LNLib::UV::SetU) |
| 25 | .def("GetU", &LNLib::UV::GetU) |
| 26 | .def("SetV", &LNLib::UV::SetV) |
| 27 | .def("GetV", &LNLib::UV::GetV) |
| 28 | .def_property("U", |
| 29 | [](const LNLib::UV& self) { return self.U(); }, |
| 30 | [](LNLib::UV& self, double val) { self.U() = val; }) |
| 31 | .def_property("V", |
| 32 | [](const LNLib::UV& self) { return self.V(); }, |
| 33 | [](LNLib::UV& self, double val) { self.V() = val; }) |
| 34 | .def("IsZero", &LNLib::UV::IsZero, py::arg("epsilon") = LNLib::Constants::DoubleEpsilon) |
| 35 | .def("IsUnit", &LNLib::UV::IsUnit, py::arg("epsilon") = LNLib::Constants::DoubleEpsilon) |
| 36 | .def("IsAlmostEqualTo", &LNLib::UV::IsAlmostEqualTo) |
| 37 | .def("Length", &LNLib::UV::Length) |
| 38 | .def("SqrLength", &LNLib::UV::SqrLength) |
| 39 | .def("Normalize", &LNLib::UV::Normalize) |
| 40 | .def("Add", &LNLib::UV::Add) |
| 41 | .def("Substract", &LNLib::UV::Substract) |
| 42 | .def("Negative", &LNLib::UV::Negative) |
| 43 | .def("DotProduct", &LNLib::UV::DotProduct) |
| 44 | .def("CrossProduct", &LNLib::UV::CrossProduct) |
| 45 | .def("Distance", &LNLib::UV::Distance) |
| 46 | .def("__getitem__", [](const LNLib::UV& self, int index) { return self[index]; }) |
| 47 | .def("__setitem__", [](LNLib::UV& self, int index, double val) { self[index] = val; }) |
| 48 | .def(py::self + py::self) |
| 49 | .def(py::self - py::self) |
| 50 | .def(py::self * double()) |
| 51 | .def(double() * py::self) |
| 52 | .def(py::self / double()) |
| 53 | .def("__xor__", [](const LNLib::UV& a, const LNLib::UV& b) { return a ^ b; }) |
| 54 | .def(-py::self); |
| 55 | } |
| 56 | |
| 57 | |
| 58 | |