Directory: | ./ |
---|---|
File: | include/multicontact-api/geometry/ellipsoid.hpp |
Date: | 2025-03-10 16:17:01 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 5 | 14 | 35.7% |
Branches: | 2 | 8 | 25.0% |
Line | Branch | Exec | Source |
---|---|---|---|
1 | // Copyright (c) 2015-2018, CNRS | ||
2 | // Authors: Justin Carpentier <jcarpent@laas.fr> | ||
3 | |||
4 | #ifndef __multicontact_api_geometry_ellipsoid_hpp__ | ||
5 | #define __multicontact_api_geometry_ellipsoid_hpp__ | ||
6 | |||
7 | #include <Eigen/Dense> | ||
8 | #include <iostream> | ||
9 | |||
10 | #include "multicontact-api/geometry/fwd.hpp" | ||
11 | |||
12 | namespace multicontact_api { | ||
13 | namespace geometry { | ||
14 | template <typename _Scalar, int _dim, int _Options> | ||
15 | struct Ellipsoid { | ||
16 | EIGEN_MAKE_ALIGNED_OPERATOR_NEW | ||
17 | typedef _Scalar Scalar; | ||
18 | enum { dim = _dim }; | ||
19 | enum { Options = _Options }; | ||
20 | |||
21 | typedef Eigen::Matrix<Scalar, dim, dim, Options> Matrix; | ||
22 | typedef Eigen::Matrix<Scalar, dim, 1, Options> Vector; | ||
23 | |||
24 | 1 | Ellipsoid(const Matrix& A, const Vector& center) : m_A(A), m_center(center) {} | |
25 | |||
26 | 1 | Scalar lhsValue(const Vector& point) const { | |
27 |
2/4✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
|
1 | return (m_A * (point - m_center)).norm(); |
28 | } | ||
29 | |||
30 | 1 | const Matrix& A() const { return m_A; } | |
31 | ✗ | Matrix& A() { return m_A; } | |
32 | 1 | const Vector& center() const { return m_center; } | |
33 | ✗ | Vector& center() { return m_center; } | |
34 | |||
35 | ✗ | void disp(std::ostream& os) const { | |
36 | ✗ | os << "A:\n" | |
37 | ✗ | << m_A << std::endl | |
38 | ✗ | << "center: " << m_center.transpose() << std::endl; | |
39 | } | ||
40 | |||
41 | ✗ | friend std::ostream& operator<<(std::ostream& os, const Ellipsoid& E) { | |
42 | ✗ | E.disp(os); | |
43 | ✗ | return os; | |
44 | } | ||
45 | |||
46 | protected: | ||
47 | /// \brief | ||
48 | Matrix m_A; | ||
49 | |||
50 | /// \brief Center of the ellipsoid expressed in the global frame. | ||
51 | Vector m_center; | ||
52 | }; | ||
53 | } // namespace geometry | ||
54 | } // namespace multicontact_api | ||
55 | |||
56 | #endif // ifndef __multicontact_api_geometry_ellipsoid_hpp__ | ||
57 |