Skip to content

Commit e3087e9

Browse files
authored
Merge pull request #135 from jcarpent/topic/devel
Fix Python documentation
2 parents a5268cc + 16b3685 commit e3087e9

File tree

2 files changed

+77
-38
lines changed

2 files changed

+77
-38
lines changed

include/eigenpy/angle-axis.hpp

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
#include "eigenpy/fwd.hpp"
1010

11-
#include <boost/python.hpp>
1211
#include <Eigen/Core>
1312
#include <Eigen/Geometry>
1413

@@ -54,15 +53,15 @@ namespace eigenpy
5453
void visit(PyClass& cl) const
5554
{
5655
cl
57-
.def(bp::init<>("Default constructor"))
56+
.def(bp::init<>(bp::arg("self"),"Default constructor"))
5857
.def(bp::init<Scalar,Vector3>
59-
((bp::arg("angle"),bp::arg("axis")),
58+
((bp::arg("self"),bp::arg("angle"),bp::arg("axis")),
6059
"Initialize from angle and axis."))
6160
.def(bp::init<Matrix3>
62-
((bp::arg("rotationMatrix")),
61+
((bp::arg("self"),bp::arg("rotation matrix")),
6362
"Initialize from a rotation matrix"))
64-
.def(bp::init<Quaternion>(bp::arg("quaternion"),"Initialize from a quaternion."))
65-
.def(bp::init<AngleAxis>(bp::arg("copy"),"Copy constructor."))
63+
.def(bp::init<Quaternion>((bp::arg("self"),bp::arg("quaternion")),"Initialize from a quaternion."))
64+
.def(bp::init<AngleAxis>((bp::arg("self"),bp::arg("copy")),"Copy constructor."))
6665

6766
/* --- Properties --- */
6867
.add_property("axis",
@@ -74,15 +73,24 @@ namespace eigenpy
7473
&AngleAxisVisitor::setAngle,"The rotation angle.")
7574

7675
/* --- Methods --- */
77-
.def("inverse",&AngleAxis::inverse,"Return the inverse rotation.")
76+
.def("inverse",&AngleAxis::inverse,
77+
bp::arg("self"),
78+
"Return the inverse rotation.")
7879
.def("fromRotationMatrix",&AngleAxis::template fromRotationMatrix<Matrix3>,
79-
bp::arg("Sets *this from a 3x3 rotation matrix."),bp::return_self<>())
80-
.def("toRotationMatrix",&AngleAxis::toRotationMatrix,"Constructs and returns an equivalent 3x3 rotation matrix.")
81-
.def("matrix",&AngleAxis::matrix,"Returns an equivalent rotation matrix.")
80+
(bp::arg("self"),bp::arg("rotation matrix")),
81+
"Sets *this from a 3x3 rotation matrix",
82+
bp::return_self<>())
83+
.def("toRotationMatrix",
84+
// bp::arg("self"),
85+
&AngleAxis::toRotationMatrix,
86+
"Constructs and returns an equivalent 3x3 rotation matrix.")
87+
.def("matrix",&AngleAxis::matrix,
88+
bp::arg("self"),
89+
"Returns an equivalent rotation matrix.")
8290

8391
.def("isApprox",
8492
&call<AngleAxis>::isApprox,
85-
isApproxAngleAxis_overload(bp::args("other","prec"),
93+
isApproxAngleAxis_overload(bp::args("self","other","prec"),
8694
"Returns true if *this is approximately equal to other, within the precision determined by prec."))
8795

8896
/* --- Operators --- */
@@ -125,7 +133,7 @@ namespace eigenpy
125133
static void expose()
126134
{
127135
bp::class_<AngleAxis>("AngleAxis",
128-
"AngleAxis representation of rotations.\n\n",
136+
"AngleAxis representation of a rotation.\n\n",
129137
bp::no_init)
130138
.def(AngleAxisVisitor<AngleAxis>());
131139
}

include/eigenpy/quaternion.hpp

Lines changed: 57 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
#include <Eigen/Geometry>
1313

1414
#include "eigenpy/exception.hpp"
15-
#include "eigenpy/registration.hpp"
1615

1716
namespace eigenpy
1817
{
@@ -69,25 +68,25 @@ namespace eigenpy
6968
void visit(PyClass& cl) const
7069
{
7170
cl
72-
.def(bp::init<>("Default constructor"))
73-
.def(bp::init<Vector4>((bp::arg("vec4")),
71+
.def(bp::init<>(bp::arg("self"),"Default constructor"))
72+
.def(bp::init<Vector4>((bp::arg("self"),bp::arg("vec4")),
7473
"Initialize from a vector 4D.\n"
7574
"\tvec4 : a 4D vector representing quaternion coefficients in the order xyzw."))
76-
.def(bp::init<Matrix3>((bp::arg("R")),
75+
.def(bp::init<Matrix3>((bp::arg("self"),bp::arg("R")),
7776
"Initialize from rotation matrix.\n"
7877
"\tR : a rotation matrix 3x3."))
79-
.def(bp::init<AngleAxis>((bp::arg("aa")),
78+
.def(bp::init<AngleAxis>((bp::arg("self"),bp::arg("aa")),
8079
"Initialize from an angle axis.\n"
8180
"\taa: angle axis object."))
82-
.def(bp::init<Quaternion>((bp::arg("quat")),
81+
.def(bp::init<Quaternion>((bp::arg("self"),bp::arg("quat")),
8382
"Copy constructor.\n"
8483
"\tquat: a quaternion."))
8584
.def("__init__",bp::make_constructor(&QuaternionVisitor::FromTwoVectors,
8685
bp::default_call_policies(),
8786
(bp::arg("u: a 3D vector"),bp::arg("v: a 3D vector"))),
8887
"Initialize from two vectors u and v")
8988
.def(bp::init<Scalar,Scalar,Scalar,Scalar>
90-
((bp::arg("w"),bp::arg("x"),bp::arg("y"),bp::arg("z")),
89+
((bp::arg("self"),bp::arg("w"),bp::arg("x"),bp::arg("y"),bp::arg("z")),
9190
"Initialize from coefficients.\n\n"
9291
"... note:: The order of coefficients is *w*, *x*, *y*, *z*. "
9392
"The [] operator numbers them differently, 0...4 for *x* *y* *z* *w*!"))
@@ -107,30 +106,61 @@ namespace eigenpy
107106

108107
.def("isApprox",
109108
&call<Quaternion>::isApprox,
110-
isApproxQuaternion_overload(bp::args("other","prec"),
109+
isApproxQuaternion_overload(bp::args("self","other","prec"),
111110
"Returns true if *this is approximately equal to other, within the precision determined by prec."))
112111

113112
/* --- Methods --- */
114113
.def("coeffs",(const Vector4 & (Quaternion::*)()const)&Quaternion::coeffs,
114+
bp::arg("self"),
115+
"Returns a vector of the coefficients (x,y,z,w)",
115116
bp::return_value_policy<bp::copy_const_reference>())
116-
.def("matrix",&Quaternion::matrix,"Returns an equivalent 3x3 rotation matrix. Similar to toRotationMatrix.")
117-
.def("toRotationMatrix",&Quaternion::toRotationMatrix,"Returns an equivalent 3x3 rotation matrix.")
117+
.def("matrix",&Quaternion::matrix,
118+
bp::arg("self"),
119+
"Returns an equivalent 3x3 rotation matrix. Similar to toRotationMatrix.")
120+
.def("toRotationMatrix",&Quaternion::toRotationMatrix,
121+
// bp::arg("self"), // Bug in Boost.Python
122+
"Returns an equivalent 3x3 rotation matrix.")
118123

119-
.def("setFromTwoVectors",&setFromTwoVectors,((bp::arg("a"),bp::arg("b"))),"Set *this to be the quaternion which transforms a into b through a rotation."
124+
.def("setFromTwoVectors",&setFromTwoVectors,((bp::arg("self"),bp::arg("a"),bp::arg("b"))),
125+
"Set *this to be the quaternion which transforms a into b through a rotation."
120126
,bp::return_self<>())
121-
.def("conjugate",&Quaternion::conjugate,"Returns the conjugated quaternion. The conjugate of a quaternion represents the opposite rotation.")
122-
.def("inverse",&Quaternion::inverse,"Returns the quaternion describing the inverse rotation.")
123-
.def("setIdentity",&Quaternion::setIdentity,bp::return_self<>(),"Set *this to the idendity rotation.")
124-
.def("norm",&Quaternion::norm,"Returns the norm of the quaternion's coefficients.")
125-
.def("normalize",&Quaternion::normalize,"Normalizes the quaternion *this.")
126-
.def("normalized",&Quaternion::normalized,"Returns a normalized copy of *this.")
127-
.def("squaredNorm",&Quaternion::squaredNorm,"Returns the squared norm of the quaternion's coefficients.")
128-
.def("dot",&Quaternion::template dot<Quaternion>,bp::arg("other"),"Returns the dot product of *this with other"
127+
.def("conjugate",&Quaternion::conjugate,
128+
bp::arg("self"),
129+
"Returns the conjugated quaternion.\n"
130+
"The conjugate of a quaternion represents the opposite rotation.")
131+
.def("inverse",&Quaternion::inverse,
132+
bp::arg("self"),
133+
"Returns the quaternion describing the inverse rotation.")
134+
.def("setIdentity",&Quaternion::setIdentity,
135+
bp::arg("self"),
136+
"Set *this to the idendity rotation.",bp::return_self<>())
137+
.def("norm",&Quaternion::norm,
138+
bp::arg("self"),
139+
"Returns the norm of the quaternion's coefficients.")
140+
.def("normalize",&Quaternion::normalize,
141+
bp::arg("self"),
142+
"Normalizes the quaternion *this.")
143+
.def("normalized",&Quaternion::normalized,
144+
bp::arg("self"),
145+
"Returns a normalized copy of *this.")
146+
.def("squaredNorm",&Quaternion::squaredNorm,
147+
bp::arg("self"),
148+
"Returns the squared norm of the quaternion's coefficients.")
149+
.def("dot",&Quaternion::template dot<Quaternion>,
150+
(bp::arg("self"),bp::arg("other")),
151+
"Returns the dot product of *this with an other Quaternion.\n"
129152
"Geometrically speaking, the dot product of two unit quaternions corresponds to the cosine of half the angle between the two rotations.")
130-
.def("_transformVector",&Quaternion::_transformVector,bp::arg("vector"),"Rotation of a vector by a quaternion.")
131-
.def("vec",&vec,"Returns a vector expression of the imaginary part (x,y,z).")
132-
.def("angularDistance",&Quaternion::template angularDistance<Quaternion>,"Returns the angle (in radian) between two rotations.")
133-
.def("slerp",&slerp,bp::args("t","other"),
153+
.def("_transformVector",&Quaternion::_transformVector,
154+
(bp::arg("self"),bp::arg("vector")),
155+
"Rotation of a vector by a quaternion.")
156+
.def("vec",&vec,
157+
bp::arg("self"),
158+
"Returns a vector expression of the imaginary part (x,y,z).")
159+
.def("angularDistance",
160+
// (bp::arg("self"),bp::arg("other")), // Bug in Boost.Python
161+
&Quaternion::template angularDistance<Quaternion>,
162+
"Returns the angle (in radian) between two rotations.")
163+
.def("slerp",&slerp,bp::args("self","t","other"),
134164
"Returns the spherical linear interpolation between the two quaternions *this and other at the parameter t in [0;1].")
135165

136166
/* --- Operators --- */
@@ -144,9 +174,9 @@ namespace eigenpy
144174
.def("__setitem__",&QuaternionVisitor::__setitem__)
145175
.def("__getitem__",&QuaternionVisitor::__getitem__)
146176
.def("assign",&assign<Quaternion>,
147-
bp::arg("quat"),"Set *this from an quaternion quat and returns a reference to *this.",bp::return_self<>())
177+
bp::args("self","quat"),"Set *this from an quaternion quat and returns a reference to *this.",bp::return_self<>())
148178
.def("assign",(Quaternion & (Quaternion::*)(const AngleAxis &))&Quaternion::operator=,
149-
bp::arg("aa"),"Set *this from an angle-axis aa and returns a reference to *this.",bp::return_self<>())
179+
bp::args("self","aa"),"Set *this from an angle-axis aa and returns a reference to *this.",bp::return_self<>())
150180
.def("__str__",&print)
151181
.def("__repr__",&print)
152182

@@ -158,7 +188,8 @@ namespace eigenpy
158188
"Returns the quaternion which transforms a into b through a rotation.",
159189
bp::return_value_policy<bp::manage_new_object>())
160190
.staticmethod("FromTwoVectors")
161-
.def("Identity",&Quaternion::Identity,"Returns a quaternion representing an identity rotation.")
191+
.def("Identity",&Quaternion::Identity,
192+
"Returns a quaternion representing an identity rotation.")
162193
.staticmethod("Identity")
163194
;
164195
}

0 commit comments

Comments
 (0)