| 17 | namespace py = pybind11; |
| 18 | |
| 19 | void cstrXYZ(py::module_&m) |
| 20 | { |
| 21 | py::class_<LNLib::XYZ>(m, "XYZ") |
| 22 | .def(py::init<>()) |
| 23 | .def(py::init<double, double, double>()) |
| 24 | .def("SetX", &LNLib::XYZ::SetX) |
| 25 | .def("GetX", &LNLib::XYZ::GetX) |
| 26 | .def("SetY", &LNLib::XYZ::SetY) |
| 27 | .def("GetY", &LNLib::XYZ::GetY) |
| 28 | .def("SetZ", &LNLib::XYZ::SetZ) |
| 29 | .def("GetZ", &LNLib::XYZ::GetZ) |
| 30 | .def_property("X", |
| 31 | [](const LNLib::XYZ& self) { return self.X(); }, |
| 32 | [](LNLib::XYZ& self, double val) { self.X() = val; }) |
| 33 | .def_property("Y", |
| 34 | [](const LNLib::XYZ& self) { return self.Y(); }, |
| 35 | [](LNLib::XYZ& self, double val) { self.Y() = val; }) |
| 36 | .def_property("Z", |
| 37 | [](const LNLib::XYZ& self) { return self.Z(); }, |
| 38 | [](LNLib::XYZ& self, double val) { self.Z() = val; }) |
| 39 | .def("IsZero", &LNLib::XYZ::IsZero, py::arg("epsilon") = LNLib::Constants::DoubleEpsilon) |
| 40 | .def("IsUnit", &LNLib::XYZ::IsUnit, py::arg("epsilon") = LNLib::Constants::DoubleEpsilon) |
| 41 | .def("IsAlmostEqualTo", &LNLib::XYZ::IsAlmostEqualTo) |
| 42 | .def("Length", &LNLib::XYZ::Length) |
| 43 | .def("SqrLength", &LNLib::XYZ::SqrLength) |
| 44 | .def("AngleTo", &LNLib::XYZ::AngleTo) |
| 45 | .def("Normalize", &LNLib::XYZ::Normalize) |
| 46 | .def("Add", &LNLib::XYZ::Add) |
| 47 | .def("Substract", &LNLib::XYZ::Substract) |
| 48 | .def("Negative", &LNLib::XYZ::Negative) |
| 49 | .def("DotProduct", &LNLib::XYZ::DotProduct) |
| 50 | .def("CrossProduct", &LNLib::XYZ::CrossProduct) |
| 51 | .def("Distance", &LNLib::XYZ::Distance) |
| 52 | .def_static("CreateRandomOrthogonal", &LNLib::XYZ::CreateRandomOrthogonal) |
| 53 | .def("__getitem__", [](const LNLib::XYZ& self, int index) { return self[index]; }) |
| 54 | .def("__setitem__", [](LNLib::XYZ& self, int index, double val) { self[index] = val; }) |
| 55 | .def(py::self + py::self) |
| 56 | .def(py::self - py::self) |
| 57 | .def(py::self * double()) |
| 58 | .def(double() * py::self) |
| 59 | .def(py::self / double()) |
| 60 | .def("__xor__", [](const LNLib::XYZ& a, const LNLib::XYZ& b) { return a ^ b; }) |
| 61 | .def(-py::self); |
| 62 | } |