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



Page generated by Doxygen 1.9.1 for MRPT 1.9.9 Git: 814d80880 Fri Aug 24 01:51:28 2018 +0200 at mar 26 may 2026 12:30:59 CEST