ellipsoid.hpp
Go to the documentation of this file.
1 // Copyright (c) 2015-2018, CNRS
2 // Authors: Justin Carpentier <jcarpent@laas.fr>
3 
4 #ifndef __multicontact_api_python_geometry_ellipsoid_hpp__
5 #define __multicontact_api_python_geometry_ellipsoid_hpp__
6 
7 #include <pinocchio/fwd.hpp>
8 
11 
12 namespace multicontact_api {
13 namespace python {
14 
15 namespace bp = boost::python;
16 
17 template <typename Ellipsoid>
19  : public boost::python::def_visitor<EllipsoidPythonVisitor<Ellipsoid> > {
20  typedef typename Ellipsoid::Matrix Matrix;
21  typedef typename Ellipsoid::Vector Vector;
22 
23  template <class PyClass>
24  void visit(PyClass& cl) const {
25  cl.def(bp::init<Matrix, Vector>((bp::arg("A"), bp::arg("center"))))
26  .def("__str__", &toString)
27  .def("lhsValue", &Ellipsoid::lhsValue, bp::arg("point"),
28  "Returns the value of norm(A*(x-c)).")
29  .add_property("center", &get_center, &set_center,
30  "Accessor to the center property.")
31  .add_property("A", &get_A, &set_A, "Accessor to the A property.");
32  }
33 
34  static void set_center(Ellipsoid& e, const Vector& center) {
35  e.center() = center;
36  }
37  static Vector get_center(const Ellipsoid& e) { return e.center(); }
38 
39  static void set_A(Ellipsoid& e, const Matrix& A) { e.A() = A; }
40  static Matrix get_A(const Ellipsoid& e) { return e.A(); }
41 
42  static void expose(const std::string& class_name) {
43  std::string doc = "Ellipsoid of dimension " + Ellipsoid::dim;
44  doc += " defined by its matrix A and its center.";
45  bp::class_<Ellipsoid>(class_name.c_str(), doc.c_str(), bp::no_init)
47  }
48 
49  protected:
50  static std::string toString(const Ellipsoid& e) {
51  std::ostringstream s;
52  s << e;
53  return s.str();
54  }
55 };
56 
57 } // namespace python
58 } // namespace multicontact_api
59 
60 #endif // ifnef __multicontact_api_python_geometry_ellipsoid_hpp__
static Vector get_center(const Ellipsoid &e)
Definition: ellipsoid.hpp:37
static void set_center(Ellipsoid &e, const Vector &center)
Definition: ellipsoid.hpp:34
static Matrix get_A(const Ellipsoid &e)
Definition: ellipsoid.hpp:40
static void expose(const std::string &class_name)
Definition: ellipsoid.hpp:42
Definition: ellipsoid.hpp:12
static void set_A(Ellipsoid &e, const Matrix &A)
Definition: ellipsoid.hpp:39
Ellipsoid::Matrix Matrix
Definition: ellipsoid.hpp:20
Ellipsoid::Vector Vector
Definition: ellipsoid.hpp:21
static std::string toString(const Ellipsoid &e)
Definition: ellipsoid.hpp:50
void visit(PyClass &cl) const
Definition: ellipsoid.hpp:24