GCC Code Coverage Report | |||||||||||||||||||||
|
|||||||||||||||||||||
Line | Branch | Exec | Source |
1 |
/* |
||
2 |
* Copyright 2014-2023 CNRS INRIA |
||
3 |
*/ |
||
4 |
|||
5 |
#ifndef __eigenpy_angle_axis_hpp__ |
||
6 |
#define __eigenpy_angle_axis_hpp__ |
||
7 |
|||
8 |
#include "eigenpy/eigenpy.hpp" |
||
9 |
|||
10 |
namespace eigenpy { |
||
11 |
|||
12 |
template <typename AngleAxis> |
||
13 |
class AngleAxisVisitor; |
||
14 |
|||
15 |
template <typename Scalar> |
||
16 |
struct call<Eigen::AngleAxis<Scalar> > { |
||
17 |
typedef Eigen::AngleAxis<Scalar> AngleAxis; |
||
18 |
|||
19 |
12 |
static inline void expose() { AngleAxisVisitor<AngleAxis>::expose(); } |
|
20 |
|||
21 |
2 |
static inline bool isApprox( |
|
22 |
const AngleAxis& self, const AngleAxis& other, |
||
23 |
const Scalar& prec = Eigen::NumTraits<Scalar>::dummy_precision()) { |
||
24 |
2 |
return self.isApprox(other, prec); |
|
25 |
} |
||
26 |
}; |
||
27 |
|||
28 |
template <typename AngleAxis> |
||
29 |
class AngleAxisVisitor : public bp::def_visitor<AngleAxisVisitor<AngleAxis> > { |
||
30 |
typedef typename AngleAxis::Scalar Scalar; |
||
31 |
typedef typename AngleAxis::Vector3 Vector3; |
||
32 |
typedef typename AngleAxis::Matrix3 Matrix3; |
||
33 |
|||
34 |
typedef typename Eigen::Quaternion<Scalar, 0> Quaternion; |
||
35 |
typedef Eigen::RotationBase<AngleAxis, 3> RotationBase; |
||
36 |
|||
37 |
✓✗ | 28 |
BOOST_PYTHON_FUNCTION_OVERLOADS(isApproxAngleAxis_overload, |
38 |
call<AngleAxis>::isApprox, 2, 3) |
||
39 |
|||
40 |
public: |
||
41 |
template <class PyClass> |
||
42 |
12 |
void visit(PyClass& cl) const { |
|
43 |
12 |
cl.def(bp::init<>(bp::arg("self"), "Default constructor")) |
|
44 |
✓✗✓✗ |
12 |
.def(bp::init<Scalar, Vector3>(bp::args("self", "angle", "axis"), |
45 |
"Initialize from angle and axis.")) |
||
46 |
✓✗✓✗ ✓✗ |
24 |
.def(bp::init<Matrix3>(bp::args("self", "R"), |
47 |
"Initialize from a rotation matrix")) |
||
48 |
✓✗✓✗ ✓✗ |
24 |
.def(bp::init<Quaternion>(bp::args("self", "quaternion"), |
49 |
"Initialize from a quaternion.")) |
||
50 |
✓✗✓✗ ✓✗ |
24 |
.def(bp::init<AngleAxis>(bp::args("self", "copy"), "Copy constructor.")) |
51 |
|||
52 |
/* --- Properties --- */ |
||
53 |
✓✗✓✗ ✓✗ |
24 |
.add_property( |
54 |
"axis", |
||
55 |
bp::make_function((Vector3 & (AngleAxis::*)()) & AngleAxis::axis, |
||
56 |
bp::return_internal_reference<>()), |
||
57 |
&AngleAxisVisitor::setAxis, "The rotation axis.") |
||
58 |
✓✗✓✗ |
24 |
.add_property("angle", |
59 |
(Scalar(AngleAxis::*)() const) & AngleAxis::angle, |
||
60 |
&AngleAxisVisitor::setAngle, "The rotation angle.") |
||
61 |
|||
62 |
/* --- Methods --- */ |
||
63 |
✓✗ | 12 |
.def("inverse", &AngleAxis::inverse, bp::arg("self"), |
64 |
"Return the inverse rotation.") |
||
65 |
✓✗ | 24 |
.def("fromRotationMatrix", |
66 |
&AngleAxis::template fromRotationMatrix<Matrix3>, |
||
67 |
(bp::arg("self"), bp::arg("rotation matrix")), |
||
68 |
"Sets *this from a 3x3 rotation matrix", bp::return_self<>()) |
||
69 |
✓✗✓✗ ✓✗✓✗ |
24 |
.def("toRotationMatrix", &AngleAxis::toRotationMatrix, |
70 |
// bp::arg("self"), |
||
71 |
"Constructs and returns an equivalent rotation matrix.") |
||
72 |
✓✗ | 12 |
.def("matrix", &AngleAxis::matrix, bp::arg("self"), |
73 |
"Returns an equivalent rotation matrix.") |
||
74 |
|||
75 |
✓✗✓✗ |
24 |
.def("isApprox", &call<AngleAxis>::isApprox, |
76 |
isApproxAngleAxis_overload( |
||
77 |
bp::args("self", "other", "prec"), |
||
78 |
"Returns true if *this is approximately equal to other, " |
||
79 |
"within the precision determined by prec.")) |
||
80 |
|||
81 |
/* --- Operators --- */ |
||
82 |
✓✗✓✗ ✓✗✓✗ |
24 |
.def(bp::self * bp::other<Vector3>()) |
83 |
✓✗ | 12 |
.def(bp::self * bp::other<Quaternion>()) |
84 |
✓✗ | 24 |
.def(bp::self * bp::self) |
85 |
✓✗ | 12 |
.def("__eq__", &AngleAxisVisitor::__eq__) |
86 |
✓✗ | 12 |
.def("__ne__", &AngleAxisVisitor::__ne__) |
87 |
|||
88 |
✓✗ | 12 |
.def("__str__", &print) |
89 |
✓✗✓✗ |
12 |
.def("__repr__", &print); |
90 |
12 |
} |
|
91 |
|||
92 |
private: |
||
93 |
1 |
static void setAxis(AngleAxis& self, const Vector3& axis) { |
|
94 |
1 |
self.axis() = axis; |
|
95 |
1 |
} |
|
96 |
|||
97 |
static void setAngle(AngleAxis& self, const Scalar& angle) { |
||
98 |
self.angle() = angle; |
||
99 |
} |
||
100 |
|||
101 |
static bool __eq__(const AngleAxis& u, const AngleAxis& v) { |
||
102 |
return u.axis() == v.axis() && v.angle() == u.angle(); |
||
103 |
} |
||
104 |
|||
105 |
static bool __ne__(const AngleAxis& u, const AngleAxis& v) { |
||
106 |
return !__eq__(u, v); |
||
107 |
} |
||
108 |
|||
109 |
static std::string print(const AngleAxis& self) { |
||
110 |
std::stringstream ss; |
||
111 |
ss << "angle: " << self.angle() << std::endl; |
||
112 |
ss << "axis: " << self.axis().transpose() << std::endl; |
||
113 |
|||
114 |
return ss.str(); |
||
115 |
} |
||
116 |
|||
117 |
public: |
||
118 |
12 |
static void expose() { |
|
119 |
✓✗ | 12 |
bp::class_<AngleAxis>( |
120 |
"AngleAxis", "AngleAxis representation of a rotation.\n\n", bp::no_init) |
||
121 |
.def(AngleAxisVisitor<AngleAxis>()); |
||
122 |
|||
123 |
// Cast to Eigen::RotationBase |
||
124 |
12 |
bp::implicitly_convertible<AngleAxis, RotationBase>(); |
|
125 |
12 |
} |
|
126 |
}; |
||
127 |
|||
128 |
} // namespace eigenpy |
||
129 |
|||
130 |
#endif // ifndef __eigenpy_angle_axis_hpp__ |
Generated by: GCOVR (Version 4.2) |