diff --git a/include/eigenpy/quaternion.hpp b/include/eigenpy/quaternion.hpp index 95a9215fff0011a5d8d619b862c3233b0ac95deb..1087180a8c7c1b8c4435f150de2702375d812b34 100644 --- a/include/eigenpy/quaternion.hpp +++ b/include/eigenpy/quaternion.hpp @@ -185,16 +185,19 @@ namespace eigenpy "Returns the quaternion describing the inverse rotation.") .def("setIdentity",&Quaternion::setIdentity, bp::arg("self"), - "Set *this to the idendity rotation.",bp::return_self<>()) + "Set *this to the identity rotation.", + bp::return_self<>()) .def("norm",&Quaternion::norm, bp::arg("self"), "Returns the norm of the quaternion's coefficients.") .def("normalize",&Quaternion::normalize, bp::arg("self"), - "Normalizes the quaternion *this.") - .def("normalized",&Quaternion::normalized, + "Normalizes the quaternion *this.", + bp::return_self<>()) + .def("normalized",&normalized, bp::arg("self"), - "Returns a normalized copy of *this.") + "Returns a normalized copy of *this.", + bp::return_value_policy<bp::manage_new_object>()) .def("squaredNorm",&Quaternion::squaredNorm, bp::arg("self"), "Returns the squared norm of the quaternion's coefficients.") @@ -251,6 +254,11 @@ namespace eigenpy ; } private: + + static Quaternion * normalized(const Quaternion & self) + { + return new Quaternion(self.normalized()); + } template<int i> static void setCoeff(Quaternion & self, Scalar value) { self.coeffs()[i] = value; } diff --git a/src/quaternion.cpp b/src/quaternion.cpp index 4ffa866c3537af1715493a65be342be9e1b6b79a..4fabb2bbe77b7a1006795c807dad7b5dfccef269 100644 --- a/src/quaternion.cpp +++ b/src/quaternion.cpp @@ -1,14 +1,17 @@ /* * Copyright 2014-2019, CNRS - * Copyright 2018-2019, INRIA + * Copyright 2018-2022, INRIA */ #include "eigenpy/memory.hpp" #include "eigenpy/geometry.hpp" -#include "eigenpy/quaternion.hpp" + +#include <Eigen/Geometry> EIGENPY_DEFINE_STRUCT_ALLOCATOR_SPECIALIZATION(Eigen::Quaterniond) +#include "eigenpy/quaternion.hpp" + namespace eigenpy { void exposeQuaternion()