MCPcopy Create free account
hub / github.com/dartsim/dart / eigen_geometry

Function eigen_geometry

python/dartpy/eigen_geometry_pybind.cpp:121–486  ·  view source on GitHub ↗

PYBIND11_MODULE(eigen_geometry, m) {

Source from the content-addressed store, hash-verified

119
120// PYBIND11_MODULE(eigen_geometry, m) {
121void eigen_geometry(pybind11::module& parent_m)
122{
123 auto m = parent_m.def_submodule("math");
124
125 m.doc() = "Bindings for Eigen geometric types.";
126
127 using T = double;
128
129 // Do not return references to matrices (e.g. `Eigen::Ref<>`) so that we have
130 // tighter control over validation.
131
132 // Isometry3d.
133 // @note `linear` implies rotation, and `affine` implies translation.
134 {
135 using Class = Eigen::Transform<T, 3, Eigen::Isometry>;
136 ::pybind11::class_<Class> py_class(m, "Isometry3");
137 py_class.def(::pybind11::init([]() { return Class::Identity(); }))
138 .def_static("Identity", []() { return Class::Identity(); })
139 .def(
140 ::pybind11::init([](const Eigen::Matrix<T, 4, 4>& matrix) {
141 Class out(matrix);
142 CheckIsometry(out);
143 return out;
144 }),
145 ::pybind11::arg("matrix"))
146 .def(
147 ::pybind11::init([](const Eigen::Matrix<T, 3, 3>& rotation,
148 const Eigen::Matrix<T, 3, 1>& translation) {
149 CheckRotMat(rotation);
150 Class out = Class::Identity();
151 out.linear() = rotation;
152 out.translation() = translation;
153 return out;
154 }),
155 ::pybind11::arg("rotation"),
156 ::pybind11::arg("translation"))
157 .def(
158 ::pybind11::init([](const Eigen::Quaternion<T>& q,
159 const Eigen::Matrix<T, 3, 1>& translation) {
160 CheckQuaternion(q);
161 Class out = Class::Identity();
162 out.linear() = q.toRotationMatrix();
163 out.translation() = translation;
164 return out;
165 }),
166 ::pybind11::arg("quaternion"),
167 ::pybind11::arg("translation"))
168 .def(
169 ::pybind11::init([](const Class& other) {
170 CheckIsometry(other);
171 return other;
172 }),
173 ::pybind11::arg("other"))
174 .def(
175 "matrix",
176 [](const Class* self) -> Eigen::Matrix<T, 4, 4> {
177 return self->matrix();
178 })

Callers 1

PYBIND11_MODULEFunction · 0.85

Calls 5

CheckIsometryFunction · 0.85
CheckRotMatFunction · 0.85
CheckQuaternionFunction · 0.85
CheckAngleAxisFunction · 0.85
translateMethod · 0.45

Tested by

no test coverage detected