Added tutorial 404

Former-commit-id: 0258e9fb60
This commit is contained in:
Sebastian Koch
2016-07-11 18:20:22 +02:00
parent 23143da4d2
commit d74da4cd6f
13 changed files with 579 additions and 7 deletions
+47 -7
View File
@@ -692,10 +692,12 @@ void python_export_vector(py::module &m) {
.def("solve",[](const Eigen::SimplicialLLT<Eigen::SparseMatrix<double > >& s, const Eigen::MatrixXd& rhs) { return Eigen::MatrixXd(s.solve(rhs)); })
;
// Bindings for Affine3d
py::class_<Eigen::Affine3d > affine3d(me, "Affine3d");
affine3d
.def(py::init<>())
.def_static("Identity", []() { return Eigen::Affine3d::Identity(); })
.def("setIdentity",[](Eigen::Affine3d& a){
return a.setIdentity();
})
@@ -703,6 +705,9 @@ void python_export_vector(py::module &m) {
assert_is_Vector3("axis", axis);
return a.rotate(Eigen::AngleAxisd(angle, Eigen::Vector3d(axis)));
})
.def("rotate",[](Eigen::Affine3d& a, Eigen::Quaterniond quat) {
return a.rotate(quat);
})
.def("translate",[](Eigen::Affine3d& a, Eigen::MatrixXd offset) {
assert_is_Vector3("offset", offset);
return a.translate(Eigen::Vector3d(offset));
@@ -711,13 +716,48 @@ void python_export_vector(py::module &m) {
return Eigen::MatrixXd(a.matrix());
})
;
/* Bindings for Quaterniond*/
//py::class_<Eigen::Quaterniond > quaterniond(me, "Quaterniond");
//
// quaterniond
// .def(py::init<>())
// .def(py::init<double, double, double, double>())
// ;
// Bindings for Quaterniond
py::class_<Eigen::Quaterniond > quaterniond(me, "Quaterniond");
quaterniond
.def(py::init<>())
.def(py::init<double, double, double, double>())
.def("__init__", [](Eigen::Quaterniond &q, double angle, Eigen::MatrixXd axis) {
assert_is_Vector3("axis", axis);
new (&q) Eigen::Quaterniond(Eigen::AngleAxisd(angle, Eigen::Vector3d(axis)));
})
.def_static("Identity", []() { return Eigen::Quaterniond::Identity(); })
.def("__repr__", [](const Eigen::Quaterniond &v) {
std::ostringstream oss;
oss << "(" << v.w() << ", " << v.x() << ", " << v.y() << ", " << v.z() << ")";
return oss.str();
})
.def("conjugate",[](Eigen::Quaterniond& q) {
return q.conjugate();
})
.def("slerp",[](Eigen::Quaterniond& q, double & t, Eigen::Quaterniond other) {
return q.slerp(t, other);
})
// .def_cast(-py::self)
// .def_cast(py::self + py::self)
// .def_cast(py::self - py::self)
.def_cast(py::self * py::self)
// .def_cast(py::self - Scalar())
// .def_cast(py::self * Scalar())
// .def_cast(py::self / Scalar())
// .def("__mul__", []
// (const Type &a, const Scalar& b)
// {
// return Eigen::Matrix<Scalar,Eigen::Dynamic,Eigen::Dynamic>(a * b);
// })
// .def("__rmul__", [](const Type& a, const Scalar& b)
// {
// return Eigen::Matrix<Scalar,Eigen::Dynamic,Eigen::Dynamic>(b * a);
// })
;