22 #include "pybind11/pybind11.h"
23 #include "pybind11/eigen.h"
24 #include "pybind11/stl.h"
25 #include "pybind11/numpy.h"
27 #include "ndarray/pybind11.h"
36 using namespace pybind11::literals;
44 [](
auto & mod,
auto &
cls) {
47 cls.attr(
"XX") = py::cast(int(LinearTransform::Parameters::XX));
48 cls.attr(
"YX") = py::cast(int(LinearTransform::Parameters::YX));
49 cls.attr(
"XY") = py::cast(int(LinearTransform::Parameters::XY));
50 cls.attr(
"YY") = py::cast(int(LinearTransform::Parameters::YY));
53 cls.def(py::init<>());
54 cls.def(py::init<LinearTransform::Matrix const &>(),
"matrix"_a);
58 py::overload_cast<Point2D const &>(&LinearTransform::operator(), py::const_));
60 py::overload_cast<Extent2D const &>(&LinearTransform::operator(), py::const_));
77 [](py::object self, py::object x, py::object y) {
78 return py::make_tuple(self.attr(
"applyX")(x, y),
79 self.attr(
"applyY")(x, y));
82 cls.def(
"__getitem__",
87 return self.getMatrix()(
row,
col);
89 cls.def(
"__mul__", &LinearTransform::operator*, py::is_operator());
90 cls.def(
"__add__", &LinearTransform::operator+, py::is_operator());
91 cls.def(
"__sub__", &LinearTransform::operator-, py::is_operator());
92 cls.def(
"__iadd__", &LinearTransform::operator+=);
93 cls.def(
"__isub__", &LinearTransform::operator-=);
96 cls.def_static(
"makeScaling",
97 py::overload_cast<double>(&LinearTransform::makeScaling),
99 cls.def_static(
"makeScaling",
100 py::overload_cast<double, double>(&LinearTransform::makeScaling));
101 cls.def_static(
"makeRotation",
102 py::overload_cast<Angle>(LinearTransform::makeRotation),
104 cls.def(
"getParameterVector", &LinearTransform::getParameterVector);
106 py::overload_cast<>(& LinearTransform::getMatrix, py::const_));
107 cls.def(
"inverted", &LinearTransform::inverted);
108 cls.def(
"computeDeterminant", &LinearTransform::computeDeterminant);
109 cls.def(
"isIdentity", &LinearTransform::isIdentity);
110 cls.def(
"applyX", py::vectorize(&LinearTransform::applyX),
"x"_a,
"y"_a);
111 cls.def(
"applyY", py::vectorize(&LinearTransform::applyY),
"x"_a,
"y"_a);
114 [](
LinearTransform &
self,
double xx,
double yx,
double xy,
double yy) {
115 self[LinearTransform::XX] = xx;
116 self[LinearTransform::XY] = xy;
117 self[LinearTransform::YX] = yx;
118 self[LinearTransform::YY] = yy;
120 "xx"_a,
"yx"_a,
"xy"_a,
"yy"_a);
123 return py::str(py::cast(
self.getMatrix()));
126 return py::str(
"LinearTransform(\n{}\n)").format(py::cast(
self.getMatrix()));
129 return py::make_tuple(
cls, py::make_tuple(py::cast(
self.getMatrix())));