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
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
This class is a "CSerializable" wrapper for "CMatrixTemplateNumeric<double>".
Definition: CMatrixD.h:24
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
float m_lineWidth
The line width for 2D ellipses or 3D wireframe ellipsoids (default=1)
Definition: CEllipsoid.h:70
math::CMatrixD m_eigVec
Definition: CEllipsoid.h:55
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
GLdouble GLdouble GLdouble GLdouble q
Definition: glext.h:3721
float getQuantiles() const
Definition: CEllipsoid.h:124
float m_quantiles
The number of "sigmas" for drawing the ellipse/ellipsoid (default=3)
Definition: CEllipsoid.h:64
EIGEN_STRONG_INLINE void notifyChange() const
Must be called to notify that the object has changed (so, the display list must be updated) ...
void render_dl() const override
Render If one of the eigen value of the covariance matrix of the ellipsoid is null, ellipsoid will not be rendered to ensure stability in the rendering process.
Definition: CEllipsoid.cpp:31
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:4178
A renderizable object suitable for rendering with OpenGL&#39;s display lists.
mrpt::math::TPoint3D m_bb_min
Definition: CEllipsoid.h:71
A numeric matrix of compile-time fixed size.
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:179
unsigned int m_2D_segments
The number of segments of a 2D ellipse (default=20)
Definition: CEllipsoid.h:66
void setQuantiles(float q)
The number of "sigmas" for drawing the ellipse/ellipsoid (default=3)
Definition: CEllipsoid.h:119
const GLdouble * v
Definition: glext.h:3678
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
#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:139
bool traceRay(const mrpt::poses::CPose3D &o, double &dist) const override
Ray tracing.
Definition: CEllipsoid.cpp:239
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:88
CEllipsoid()
Constructor.
Definition: CEllipsoid.h:164
unsigned int m_3D_segments
The number of segments of a 3D ellipse (in both "axis") (default=20)
Definition: CEllipsoid.h:68
mrpt::math::TPoint3D m_bb_max
Definition: CEllipsoid.h:71
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
void set2DsegmentsCount(unsigned int N)
The number of segments of a 2D ellipse (default=20)
Definition: CEllipsoid.h:126
math::CMatrixD m_cov
The 2x2 or 3x3 covariance matrix that will determine the aspect of the ellipsoid. ...
Definition: CEllipsoid.h:59
void set3DsegmentsCount(unsigned int N)
The number of segments of a 3D ellipse (in both "axis") (default=20)
Definition: CEllipsoid.h:132
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
A 2D ellipse or 3D ellipsoid, depending on the size of the m_cov matrix (2x2 or 3x3).
Definition: CEllipsoid.h:47
Lightweight 3D point.
mrpt::math::CMatrixDouble getCovMatrix() const
Definition: CEllipsoid.h:106
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
float getLineWidth() const
Definition: CEllipsoid.h:144
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
math::CMatrixD m_prevComputedCov
Definition: CEllipsoid.h:55



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at lun oct 28 00:14:14 CET 2019