Skip to content

Commit

Permalink
Improve Rotation3d (#258)
Browse files Browse the repository at this point in the history
  • Loading branch information
sarlinpe authored Jan 26, 2024
1 parent 3b6b8fe commit ea42af8
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions pycolmap/geometry/bindings.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ void BindGeometry(py::module& m) {
.def(py::init<const Eigen::Matrix3d&>(),
"rotmat"_a,
"3x3 rotation matrix.")
.def(py::init([](const Eigen::Vector3d& vec) {
return Eigen::Quaterniond(
Eigen::AngleAxis<double>(vec.norm(), vec.normalized()));
}),
"axis_angle"_a,
"Axis-angle 3D vector.")
.def_property(
"quat",
py::overload_cast<>(&Eigen::Quaterniond::coeffs),
Expand All @@ -47,6 +53,14 @@ void BindGeometry(py::module& m) {
.def("normalize", &Eigen::Quaterniond::normalize)
.def("matrix", &Eigen::Quaterniond::toRotationMatrix)
.def("norm", &Eigen::Quaterniond::norm)
.def("angle",
[](const Eigen::Quaterniond& self) {
return Eigen::AngleAxis<double>(self).angle();
})
.def("angle_to",
[](const Eigen::Quaterniond& self, const Eigen::Quaterniond& other) {
return self.angularDistance(other);
})
.def("inverse", &Eigen::Quaterniond::inverse)
.def("__repr__", [](const Eigen::Quaterniond& self) {
std::stringstream ss;
Expand Down

0 comments on commit ea42af8

Please sign in to comment.