8000 Fix memory issue with Quaternion::normalized by jcarpent · Pull Request #271 · stack-of-tasks/eigenpy · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fix memory issue with Quaternion::normalized #271

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

Merged
merged 2 commits into from
Feb 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
J 10000 ump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions include/eigenpy/quaternion.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
Expand Down Expand Up @@ -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; }
Expand Down
7 changes: 5 additions & 2 deletions src/quaternion.cpp
Original file line number Diff line number Diff line change
@@ -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()
Expand Down
0