@@ -97,7 +97,7 @@ namespace eigenpy
9797 typedef typename QuaternionBase::Scalar Scalar;
9898 typedef typename Quaternion::Coefficients Coefficients;
9999 typedef typename QuaternionBase::Vector3 Vector3;
100- typedef typename Eigen::Matrix<Scalar, 4 , 1 > Vector4;
100+ typedef Coefficients Vector4;
101101 typedef typename QuaternionBase::Matrix3 Matrix3;
102102
103103 typedef typename QuaternionBase::AngleAxisType AngleAxis;
@@ -110,23 +110,25 @@ namespace eigenpy
110110 void visit (PyClass& cl) const
111111 {
112112 cl
113- .def (bp::init<>(bp::arg (" self" )," Default constructor" ))
113+ .def (bp::init<>(bp::arg (" self" )," Default constructor" )[bp::return_value_policy<bp::return_by_value>()] )
114114 .def (bp::init<Matrix3>((bp::arg (" self" ),bp::arg (" R" )),
115115 " Initialize from rotation matrix.\n "
116- " \t R : a rotation matrix 3x3." ))
117- .def (bp::init<Vector4>((bp::arg (" self" ),bp::arg (" vec4" )),
118- " Initialize from a vector 4D.\n "
119- " \t vec4 : a 4D vector representing quaternion coefficients in the order xyzw." ))
116+ " \t R : a rotation matrix 3x3." )[bp::return_value_policy<bp::return_by_value>()])
120117 .def (bp::init<AngleAxis>((bp::arg (" self" ),bp::arg (" aa" )),
121118 " Initialize from an angle axis.\n "
122119 " \t aa: angle axis object." ))
123120 .def (bp::init<Quaternion>((bp::arg (" self" ),bp::arg (" quat" )),
124121 " Copy constructor.\n "
125- " \t quat: a quaternion." ))
122+ " \t quat: a quaternion." )[bp::return_value_policy<bp::return_by_value>()] )
126123 .def (" __init__" ,bp::make_constructor (&QuaternionVisitor::FromTwoVectors,
127124 bp::default_call_policies (),
128125 (bp::arg (" u" ),bp::arg (" v" ))),
129126 " Initialize from two vectors u and v" )
127+ .def (" __init__" ,bp::make_constructor (&QuaternionVisitor::FromOneVector,
128+ bp::default_call_policies (),
129+ (bp::arg (" vec4" ))),
130+ " Initialize from a vector 4D.\n "
131+ " \t vec4 : a 4D vector representing quaternion coefficients in the order xyzw." )
130132 .def (bp::init<Scalar,Scalar,Scalar,Scalar>
131133 ((bp::arg (" self" ),bp::arg (" w" ),bp::arg (" x" ),bp::arg (" y" ),bp::arg (" z" )),
132134 " Initialize from coefficients.\n\n "
@@ -266,6 +268,12 @@ namespace eigenpy
266268 Quaternion* q (new Quaternion); q->setFromTwoVectors (u,v);
267269 return q;
268270 }
271+
272+ static Quaternion* FromOneVector (const Vector4& v)
273+ {
274+ Quaternion* q (new Quaternion (v));
275+ return q;
276+ }
269277
270278 static bool __eq__ (const Quaternion & u, const Quaternion & v)
271279 {
0 commit comments