Unverified Commit 3a7acfcc authored by Justin Carpentier's avatar Justin Carpentier Committed by GitHub
Browse files

Merge pull request #235 from jcarpent/devel

Fix constructors for Quaternion
parents d9e2f78f bd746be0
Pipeline #14626 passed with stage
in 11 minutes and 41 seconds
......@@ -97,7 +97,7 @@ namespace eigenpy
typedef typename QuaternionBase::Scalar Scalar;
typedef typename Quaternion::Coefficients Coefficients;
typedef typename QuaternionBase::Vector3 Vector3;
typedef typename Eigen::Matrix<Scalar,4,1> Vector4;
typedef Coefficients Vector4;
typedef typename QuaternionBase::Matrix3 Matrix3;
typedef typename QuaternionBase::AngleAxisType AngleAxis;
......@@ -110,23 +110,25 @@ namespace eigenpy
void visit(PyClass& cl) const
{
cl
.def(bp::init<>(bp::arg("self"),"Default constructor"))
.def(bp::init<>(bp::arg("self"),"Default constructor")[bp::return_value_policy<bp::return_by_value>()])
.def(bp::init<Matrix3>((bp::arg("self"),bp::arg("R")),
"Initialize from rotation matrix.\n"
"\tR : a rotation matrix 3x3."))
.def(bp::init<Vector4>((bp::arg("self"),bp::arg("vec4")),
"Initialize from a vector 4D.\n"
"\tvec4 : a 4D vector representing quaternion coefficients in the order xyzw."))
"\tR : a rotation matrix 3x3.")[bp::return_value_policy<bp::return_by_value>()])
.def(bp::init<AngleAxis>((bp::arg("self"),bp::arg("aa")),
"Initialize from an angle axis.\n"
"\taa: angle axis object."))
.def(bp::init<Quaternion>((bp::arg("self"),bp::arg("quat")),
"Copy constructor.\n"
"\tquat: a quaternion."))
"\tquat: a quaternion.")[bp::return_value_policy<bp::return_by_value>()])
.def("__init__",bp::make_constructor(&QuaternionVisitor::FromTwoVectors,
bp::default_call_policies(),
(bp::arg("u"),bp::arg("v"))),
"Initialize from two vectors u and v")
.def("__init__",bp::make_constructor(&QuaternionVisitor::FromOneVector,
bp::default_call_policies(),
(bp::arg("vec4"))),
"Initialize from a vector 4D.\n"
"\tvec4 : a 4D vector representing quaternion coefficients in the order xyzw.")
.def(bp::init<Scalar,Scalar,Scalar,Scalar>
((bp::arg("self"),bp::arg("w"),bp::arg("x"),bp::arg("y"),bp::arg("z")),
"Initialize from coefficients.\n\n"
......@@ -266,6 +268,12 @@ namespace eigenpy
Quaternion* q(new Quaternion); q->setFromTwoVectors(u,v);
return q;
}
static Quaternion* FromOneVector(const Vector4& v)
{
Quaternion* q(new Quaternion(v));
return q;
}
static bool __eq__(const Quaternion & u, const Quaternion & v)
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment