Main MRPT website > C++ reference for MRPT 1.5.6
CEllipsoid.h
Go to the documentation of this file.
1 /* +---------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2017, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +---------------------------------------------------------------------------+ */
9 #ifndef opengl_CEllipsoid_H
10 #define opengl_CEllipsoid_H
11 
13 #include <mrpt/math/CMatrixD.h>
15 
16 namespace mrpt
17 {
18  namespace opengl
19  {
20  // This must be added to any CSerializable derived class:
21  DEFINE_SERIALIZABLE_PRE_CUSTOM_BASE_LINKAGE( CEllipsoid, CRenderizableDisplayList, OPENGL_IMPEXP )
22 
23  /** A 2D ellipse or 3D ellipsoid, depending on the size of the m_cov matrix (2x2 or 3x3).
24  * The center of the ellipsoid is the "m_x,m_y,m_z" object's coordinates. In the case of
25  * a 2D ellipse it will be drawn in the XY plane, for z=0.
26  * The color is determined by the RGBA fields in the class "CRenderizable". Note that a
27  * transparent ellipsoid can be drawn for "0<alpha<1" values.
28  * If one of the eigen value of the covariance matrix of the ellipsoid is null, ellipsoid will not be rendered.
29  * \sa opengl::COpenGLScene
30  *
31  *
32  * Please read the documentation of CGeneralizedEllipsoidTemplate::setQuantiles() for learning
33  * the mathematical details about setting the desired confidence interval.
34  *
35  * <div align="center">
36  * <table border="0" cellspan="4" cellspacing="4" style="border-width: 1px; border-style: solid;">
37  * <tr> <td> mrpt::opengl::CEllipsoid </td> <td> \image html preview_CEllipsoid.png </td> </tr>
38  * </table>
39  * </div>
40  *
41  * \ingroup mrpt_opengl_grp
42  */
44  {
46 
47  protected:
48  /** Used to store computed values the first time this is rendered, and to avoid recomputing them again.
49  */
50  math::CMatrixD m_eigVal,m_eigVec,m_prevComputedCov;
51 
52  math::CMatrixD m_cov; //!< The 2x2 or 3x3 covariance matrix that will determine the aspect of the ellipsoid.
53  bool m_drawSolid3D; //!< If set to true (default), a whole ellipsoid surface will be drawn, or if set to "false" it will be drawn as a "wireframe".
54  float m_quantiles; //!< The number of "sigmas" for drawing the ellipse/ellipsoid (default=3)
55  unsigned int m_2D_segments; //!< The number of segments of a 2D ellipse (default=20)
56  unsigned int m_3D_segments; //!< The number of segments of a 3D ellipse (in both "axis") (default=20)
57  float m_lineWidth; //!< The line width for 2D ellipses or 3D wireframe ellipsoids (default=1)
58  mutable mrpt::math::TPoint3D m_bb_min, m_bb_max;
59 
60  public:
61  void setCovMatrix( const mrpt::math::CMatrixDouble &m, int resizeToSize = -1 ); //!< Set the 2x2 or 3x3 covariance matrix that will determine the aspect of the ellipsoid (if resizeToSize>0, the matrix will be cut to the square matrix of the given size)
62  void setCovMatrix( const mrpt::math::CMatrixFloat &m, int resizeToSize = -1 ); //!< Set the 2x2 or 3x3 covariance matrix that will determine the aspect of the ellipsoid (if resizeToSize>0, the matrix will be cut to the square matrix of the given size).
63 
64  /** Set the 2x2 or 3x3 covariance matrix that will determine the aspect of the ellipsoid (if resizeToSize>0, the matrix will be cut to the square matrix of the given size)
65  */
66  template <typename T>
67  void setCovMatrix( const mrpt::math::CMatrixFixedNumeric<T,3,3> &m, int resizeToSize = -1 ) {
68  setCovMatrix(mrpt::math::CMatrixTemplateNumeric<T>(m),resizeToSize);
69  }
70 
71  /** Set the 2x2 or 3x3 covariance matrix that will determine the aspect of the ellipsoid (if resizeToSize>0, the matrix will be cut to the square matrix of the given size)
72  */
73  template <typename T>
76  }
77 
79 
80  void enableDrawSolid3D(bool v) { m_drawSolid3D = v; CRenderizableDisplayList::notifyChange(); } //!< If set to true (default), a whole ellipsoid surface will be drawn, or if set to "false" it will be drawn as a "wireframe".
81  void setQuantiles(float q) { m_quantiles=q; CRenderizableDisplayList::notifyChange(); } //!< The number of "sigmas" for drawing the ellipse/ellipsoid (default=3)
82  float getQuantiles() const { return m_quantiles; }
83 
84  void set2DsegmentsCount(unsigned int N) { m_2D_segments=N; CRenderizableDisplayList::notifyChange(); } //!< The number of segments of a 2D ellipse (default=20)
85  void set3DsegmentsCount(unsigned int N) { m_3D_segments=N; CRenderizableDisplayList::notifyChange(); } //!< The number of segments of a 3D ellipse (in both "axis") (default=20)
86 
87  void setLineWidth(float w) { m_lineWidth=w; CRenderizableDisplayList::notifyChange(); } //!< The line width for 2D ellipses or 3D wireframe ellipsoids (default=1)
88  float getLineWidth() const { return m_lineWidth; }
89 
90 
91  /** Render
92  * If one of the eigen value of the covariance matrix of the ellipsoid is null, ellipsoid will not
93  * be rendered to ensure stability in the rendering process.
94  */
95  void render_dl() const MRPT_OVERRIDE;
96 
97  /** Evaluates the bounding box of this object (including possible children) in the coordinate frame of the object parent. */
98  void getBoundingBox(mrpt::math::TPoint3D &bb_min, mrpt::math::TPoint3D &bb_max) const MRPT_OVERRIDE;
99 
100  /** Ray tracing
101  */
102  bool traceRay(const mrpt::poses::CPose3D &o,double &dist) const MRPT_OVERRIDE;
103 
104  private:
105  /** Constructor
106  */
107  CEllipsoid() : m_eigVal(),m_eigVec(),m_prevComputedCov(),
108  m_cov(2,2),
109  m_drawSolid3D(true),
110  m_quantiles(3),
111  m_2D_segments(20),
112  m_3D_segments(20),
113  m_lineWidth(1.0),
114  m_bb_min(0,0,0),
115  m_bb_max(0,0,0)
116  {
117  }
118  /** Private, virtual destructor: only can be deleted from smart pointers */
119  virtual ~CEllipsoid() { }
120  };
121  DEFINE_SERIALIZABLE_POST_CUSTOM_BASE_LINKAGE( CEllipsoid, CRenderizableDisplayList, OPENGL_IMPEXP )
122 
123  } // end namespace
124 
125 } // End of namespace
126 
127 
128 #endif
const GLdouble * v
Definition: glew.h:1296
#define MRPT_OVERRIDE
C++11 "override" for virtuals:
bool BASE_IMPEXP traceRay(const std::vector< TPolygonWithPlane > &vec, const mrpt::poses::CPose3D &pose, double &dist)
Fast ray tracing method using polygons' properties.
Definition: geometry.cpp:1996
GLubyte GLubyte GLubyte GLubyte w
Definition: glew.h:1797
EIGEN_STRONG_INLINE void notifyChange() const
Must be called to notify that the object has changed (so, the display list must be updated) ...
A renderizable object suitable for rendering with OpenGL's display lists.
A numeric matrix of compile-time fixed size.
#define DEFINE_SERIALIZABLE_PRE_CUSTOM_BASE_LINKAGE(class_name, base_name, _LINKAGE_)
This declaration must be inserted in all CSerializable classes definition, before the class declarati...
float getLineWidth() const
Definition: CEllipsoid.h:88
float getQuantiles() const
Definition: CEllipsoid.h:82
CMatrixTemplateNumeric< double > CMatrixDouble
Declares a matrix of double numbers (non serializable).
virtual ~CEllipsoid()
Private, virtual destructor: only can be deleted from smart pointers.
Definition: CEllipsoid.h:119
mrpt::math::CMatrixDouble getCovMatrix() const
Definition: CEllipsoid.h:78
CMatrixTemplateNumeric< float > CMatrixFloat
Declares a matrix of float numbers (non serializable).
void setQuantiles(float q)
The number of "sigmas" for drawing the ellipse/ellipsoid (default=3)
Definition: CEllipsoid.h:81
#define DEFINE_SERIALIZABLE(class_name)
This declaration must be inserted in all CSerializable classes definition, within the class declarati...
void setLineWidth(float w)
The line width for 2D ellipses or 3D wireframe ellipsoids (default=1)
Definition: CEllipsoid.h:87
void setCovMatrix(const mrpt::math::CMatrixFixedNumeric< T, 2, 2 > &m)
Set the 2x2 or 3x3 covariance matrix that will determine the aspect of the ellipsoid (if resizeToSize...
Definition: CEllipsoid.h:74
void set2DsegmentsCount(unsigned int N)
The number of segments of a 2D ellipse (default=20)
Definition: CEllipsoid.h:84
const GLdouble * m
Definition: glew.h:5094
void set3DsegmentsCount(unsigned int N)
The number of segments of a 3D ellipse (in both "axis") (default=20)
Definition: CEllipsoid.h:85
void enableDrawSolid3D(bool v)
If set to true (default), a whole ellipsoid surface will be drawn, or if set to "false" it will be dr...
Definition: CEllipsoid.h:80
A 2D ellipse or 3D ellipsoid, depending on the size of the m_cov matrix (2x2 or 3x3).
Definition: CEllipsoid.h:43
GLdouble GLdouble GLdouble GLdouble q
Definition: glew.h:1319
#define DEFINE_SERIALIZABLE_POST_CUSTOM_BASE_LINKAGE(class_name, base_name, _LINKAGE_)



Page generated by Doxygen 1.8.6 for MRPT 1.5.6 Git: 4c65e84 Tue Apr 24 08:18:17 2018 +0200 at mar abr 24 08:26:17 CEST 2018