Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Rotation3d #258

Merged
merged 5 commits into from
Jan 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading