Skip to content

Commit 6338510

Browse files
authored
Merge pull request #269 from jcarpent/devel
Fix Quaternion constructor
2 parents 975e39b + c8be5af commit 6338510

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

cmake

include/eigenpy/quaternion.hpp

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014-2021 CNRS INRIA
2+
* Copyright 2014-2022 CNRS INRIA
33
*/
44

55
#ifndef __eigenpy_quaternion_hpp__
@@ -120,9 +120,11 @@ namespace eigenpy
120120
(bp::arg("aa"))),
121121
"Initialize from an angle axis.\n"
122122
"\taa: angle axis object.")
123-
.def(bp::init<Quaternion>((bp::arg("self"),bp::arg("quat")),
124-
"Copy constructor.\n"
125-
"\tquat: a quaternion.")[bp::return_value_policy<bp::return_by_value>()])
123+
.def("__init__",bp::make_constructor(&QuaternionVisitor::FromOtherQuaternion,
124+
bp::default_call_policies(),
125+
(bp::arg("quat"))),
126+
"Copy constructor.\n"
127+
"\tquat: a quaternion.")
126128
.def("__init__",bp::make_constructor(&QuaternionVisitor::FromTwoVectors,
127129
bp::default_call_policies(),
128130
(bp::arg("u"),bp::arg("v"))),
@@ -286,7 +288,13 @@ namespace eigenpy
286288
Quaternion* q(new Quaternion); q->setFromTwoVectors(u,v);
287289
return q;
288290
}
289-
291+
292+
static Quaternion* FromOtherQuaternion(const Quaternion & other)
293+
{
294+
Quaternion* q(new Quaternion(other));
295+
return q;
296+
}
297+
290298
static Quaternion* DefaultConstructor()
291299
{
292300
return new Quaternion;

0 commit comments

Comments
 (0)