Main MRPT website > C++ reference for MRPT 1.9.9
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-2018, 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 /** A 2D ellipse or 3D ellipsoid, depending on the size of the m_cov matrix (2x2
21  *or 3x3).
22  * The center of the ellipsoid is the "m_x,m_y,m_z" object's coordinates. In
23  *the case of
24  * a 2D ellipse it will be drawn in the XY plane, for z=0.
25  * The color is determined by the RGBA fields in the class "CRenderizable".
26  *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
29  *null, ellipsoid will not be rendered.
30  * \sa opengl::COpenGLScene
31  *
32  *
33  * Please read the documentation of
34  *CGeneralizedEllipsoidTemplate::setQuantiles() for learning
35  * the mathematical details about setting the desired confidence interval.
36  *
37  * <div align="center">
38  * <table border="0" cellspan="4" cellspacing="4" style="border-width: 1px;
39  *border-style: solid;">
40  * <tr> <td> mrpt::opengl::CEllipsoid </td> <td> \image html
41  *preview_CEllipsoid.png </td> </tr>
42  * </table>
43  * </div>
44  *
45  * \ingroup mrpt_opengl_grp
46  */
48 {
50 
51  protected:
52  /** Used to store computed values the first time this is rendered, and to
53  * avoid recomputing them again.
54  */
56 
57  /** The 2x2 or 3x3 covariance matrix that will determine the aspect of the
58  * ellipsoid. */
60  /** If set to true (default), a whole ellipsoid surface will be drawn, or if
61  * set to "false" it will be drawn as a "wireframe". */
63  /** The number of "sigmas" for drawing the ellipse/ellipsoid (default=3) */
64  float m_quantiles;
65  /** The number of segments of a 2D ellipse (default=20) */
66  unsigned int m_2D_segments;
67  /** The number of segments of a 3D ellipse (in both "axis") (default=20) */
68  unsigned int m_3D_segments;
69  /** The line width for 2D ellipses or 3D wireframe ellipsoids (default=1) */
70  float m_lineWidth;
72 
73  public:
74  /** Set the 2x2 or 3x3 covariance matrix that will determine the aspect of
75  * the ellipsoid (if resizeToSize>0, the matrix will be cut to the square
76  * matrix of the given size) */
77  void setCovMatrix(
78  const mrpt::math::CMatrixDouble& m, int resizeToSize = -1);
79  /** Set the 2x2 or 3x3 covariance matrix that will determine the aspect of
80  * the ellipsoid (if resizeToSize>0, the matrix will be cut to the square
81  * matrix of the given size). */
82  void setCovMatrix(const mrpt::math::CMatrixFloat& m, int resizeToSize = -1);
83 
84  /** Set the 2x2 or 3x3 covariance matrix that will determine the aspect of
85  * the ellipsoid (if resizeToSize>0, the matrix will be cut to the square
86  * matrix of the given size)
87  */
88  template <typename T>
91  int resizeToSize = -1)
92  {
94  }
95 
96  /** Set the 2x2 or 3x3 covariance matrix that will determine the aspect of
97  * the ellipsoid (if resizeToSize>0, the matrix will be cut to the square
98  * matrix of the given size)
99  */
100  template <typename T>
102  {
104  }
105 
107  {
109  }
110 
111  /** If set to true (default), a whole ellipsoid surface will be drawn, or if
112  * set to "false" it will be drawn as a "wireframe". */
113  void enableDrawSolid3D(bool v)
114  {
115  m_drawSolid3D = v;
117  }
118  /** The number of "sigmas" for drawing the ellipse/ellipsoid (default=3) */
119  void setQuantiles(float q)
120  {
121  m_quantiles = q;
123  }
124  float getQuantiles() const { return m_quantiles; }
125  /** The number of segments of a 2D ellipse (default=20) */
126  void set2DsegmentsCount(unsigned int N)
127  {
128  m_2D_segments = N;
130  }
131  /** The number of segments of a 3D ellipse (in both "axis") (default=20) */
132  void set3DsegmentsCount(unsigned int N)
133  {
134  m_3D_segments = N;
136  }
137 
138  /** The line width for 2D ellipses or 3D wireframe ellipsoids (default=1) */
139  void setLineWidth(float w)
140  {
141  m_lineWidth = w;
143  }
144  float getLineWidth() const { return m_lineWidth; }
145  /** Render
146  * If one of the eigen value of the covariance matrix of the ellipsoid is
147  *null, ellipsoid will not
148  * be rendered to ensure stability in the rendering process.
149  */
150  void render_dl() const override;
151 
152  /** Evaluates the bounding box of this object (including possible children)
153  * in the coordinate frame of the object parent. */
154  void getBoundingBox(
155  mrpt::math::TPoint3D& bb_min,
156  mrpt::math::TPoint3D& bb_max) const override;
157 
158  /** Ray tracing
159  */
160  bool traceRay(const mrpt::poses::CPose3D& o, double& dist) const override;
161 
162  /** Constructor
163  */
165  : m_eigVal(),
166  m_eigVec(),
168  m_cov(2, 2),
169  m_drawSolid3D(true),
170  m_quantiles(3),
171  m_2D_segments(20),
172  m_3D_segments(20),
173  m_lineWidth(1.0),
174  m_bb_min(0, 0, 0),
175  m_bb_max(0, 0, 0)
176  {
177  }
178  /** Private, virtual destructor: only can be deleted from smart pointers */
179  virtual ~CEllipsoid() {}
180 };
181 
182 } // end namespace
183 
184 } // End of namespace
185 
186 #endif
mrpt::math::CMatrixDouble
CMatrixTemplateNumeric< double > CMatrixDouble
Declares a matrix of double numbers (non serializable).
Definition: CMatrixTemplateNumeric.h:144
mrpt::opengl::CEllipsoid::getBoundingBox
void getBoundingBox(mrpt::math::TPoint3D &bb_min, mrpt::math::TPoint3D &bb_max) const override
Evaluates the bounding box of this object (including possible children) in the coordinate frame of th...
Definition: CEllipsoid.cpp:325
mrpt::opengl::CEllipsoid::CEllipsoid
CEllipsoid()
Constructor.
Definition: CEllipsoid.h:164
q
GLdouble GLdouble GLdouble GLdouble q
Definition: glext.h:3721
CMatrixFixedNumeric.h
CRenderizableDisplayList.h
mrpt::opengl::CEllipsoid::m_eigVec
math::CMatrixD m_eigVec
Definition: CEllipsoid.h:55
mrpt::opengl::CEllipsoid::setCovMatrix
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:101
mrpt::opengl::CEllipsoid::m_3D_segments
unsigned int m_3D_segments
The number of segments of a 3D ellipse (in both "axis") (default=20)
Definition: CEllipsoid.h:68
mrpt::opengl::CRenderizableDisplayList
A renderizable object suitable for rendering with OpenGL's display lists.
Definition: CRenderizableDisplayList.h:39
mrpt::opengl::CEllipsoid::m_quantiles
float m_quantiles
The number of "sigmas" for drawing the ellipse/ellipsoid (default=3)
Definition: CEllipsoid.h:64
mrpt::opengl::CRenderizableDisplayList::notifyChange
EIGEN_STRONG_INLINE void notifyChange() const
Must be called to notify that the object has changed (so, the display list must be updated)
Definition: CRenderizableDisplayList.h:57
mrpt::opengl::CEllipsoid::getCovMatrix
mrpt::math::CMatrixDouble getCovMatrix() const
Definition: CEllipsoid.h:106
mrpt
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Definition: CKalmanFilterCapable.h:30
mrpt::opengl::CEllipsoid::m_drawSolid3D
bool m_drawSolid3D
If set to true (default), a whole ellipsoid surface will be drawn, or if set to "false" it will be dr...
Definition: CEllipsoid.h:62
w
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:4178
mrpt::opengl::CEllipsoid::m_cov
math::CMatrixD m_cov
The 2x2 or 3x3 covariance matrix that will determine the aspect of the ellipsoid.
Definition: CEllipsoid.h:59
mrpt::opengl::CEllipsoid::setCovMatrix
void setCovMatrix(const mrpt::math::CMatrixFixedNumeric< T, 3, 3 > &m, int resizeToSize=-1)
Set the 2x2 or 3x3 covariance matrix that will determine the aspect of the ellipsoid (if resizeToSize...
Definition: CEllipsoid.h:89
mrpt::math::CMatrixTemplateNumeric< double >
v
const GLdouble * v
Definition: glext.h:3678
mrpt::opengl::CEllipsoid::m_eigVal
math::CMatrixD m_eigVal
Used to store computed values the first time this is rendered, and to avoid recomputing them again.
Definition: CEllipsoid.h:55
mrpt::poses::CPose3D
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:88
mrpt::opengl::CEllipsoid::m_bb_max
mrpt::math::TPoint3D m_bb_max
Definition: CEllipsoid.h:71
mrpt::opengl::CEllipsoid::getLineWidth
float getLineWidth() const
Definition: CEllipsoid.h:144
mrpt::opengl::CEllipsoid::m_prevComputedCov
math::CMatrixD m_prevComputedCov
Definition: CEllipsoid.h:55
mrpt::opengl::CEllipsoid::set2DsegmentsCount
void set2DsegmentsCount(unsigned int N)
The number of segments of a 2D ellipse (default=20)
Definition: CEllipsoid.h:126
CMatrixD.h
mrpt::opengl::CEllipsoid::traceRay
bool traceRay(const mrpt::poses::CPose3D &o, double &dist) const override
Ray tracing.
Definition: CEllipsoid.cpp:239
mrpt::math::CMatrixFixedNumeric
A numeric matrix of compile-time fixed size.
Definition: CMatrixFixedNumeric.h:40
mrpt::opengl::CEllipsoid::setLineWidth
void setLineWidth(float w)
The line width for 2D ellipses or 3D wireframe ellipsoids (default=1)
Definition: CEllipsoid.h:139
mrpt::opengl::CEllipsoid::getQuantiles
float getQuantiles() const
Definition: CEllipsoid.h:124
mrpt::math::TPoint3D
Lightweight 3D point.
Definition: lightweight_geom_data.h:378
mrpt::opengl::CEllipsoid::render_dl
void render_dl() const override
Render If one of the eigen value of the covariance matrix of the ellipsoid is null,...
Definition: CEllipsoid.cpp:31
mrpt::opengl::CEllipsoid::setCovMatrix
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...
Definition: CEllipsoid.cpp:268
mrpt::opengl::CEllipsoid::set3DsegmentsCount
void set3DsegmentsCount(unsigned int N)
The number of segments of a 3D ellipse (in both "axis") (default=20)
Definition: CEllipsoid.h:132
mrpt::opengl::CEllipsoid::enableDrawSolid3D
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:113
DEFINE_SERIALIZABLE
#define DEFINE_SERIALIZABLE(class_name)
This declaration must be inserted in all CSerializable classes definition, within the class declarati...
Definition: CSerializable.h:102
mrpt::opengl::CEllipsoid::setQuantiles
void setQuantiles(float q)
The number of "sigmas" for drawing the ellipse/ellipsoid (default=3)
Definition: CEllipsoid.h:119
mrpt::opengl::CEllipsoid::m_bb_min
mrpt::math::TPoint3D m_bb_min
Definition: CEllipsoid.h:71
mrpt::math::CMatrixD
This class is a "CSerializable" wrapper for "CMatrixTemplateNumeric<double>".
Definition: CMatrixD.h:24
mrpt::opengl::CEllipsoid::~CEllipsoid
virtual ~CEllipsoid()
Private, virtual destructor: only can be deleted from smart pointers.
Definition: CEllipsoid.h:179
mrpt::opengl::CEllipsoid::m_2D_segments
unsigned int m_2D_segments
The number of segments of a 2D ellipse (default=20)
Definition: CEllipsoid.h:66
mrpt::opengl::CEllipsoid
A 2D ellipse or 3D ellipsoid, depending on the size of the m_cov matrix (2x2 or 3x3).
Definition: CEllipsoid.h:47
mrpt::opengl::CEllipsoid::m_lineWidth
float m_lineWidth
The line width for 2D ellipses or 3D wireframe ellipsoids (default=1)
Definition: CEllipsoid.h:70



Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST