MRPT  1.9.9
CEllipsoid.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | https://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2019, Individual contributors, see AUTHORS file |
6  | See: https://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See: https://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 #pragma once
10 
11 #include <mrpt/math/CMatrixD.h>
12 #include <mrpt/math/CMatrixFixed.h>
14 
15 namespace mrpt::opengl
16 {
17 /** A 2D ellipse or 3D ellipsoid, depending on the size of the m_cov matrix (2x2
18  *or 3x3).
19  * The center of the ellipsoid is the "m_x,m_y,m_z" object's coordinates. In
20  *the case of
21  * a 2D ellipse it will be drawn in the XY plane, for z=0.
22  * The color is determined by the RGBA fields in the class "CRenderizable".
23  *Note that a
24  * transparent ellipsoid can be drawn for "0<alpha<1" values.
25  * If one of the eigen value of the covariance matrix of the ellipsoid is
26  *null, ellipsoid will not be rendered.
27  * \sa opengl::COpenGLScene
28  *
29  *
30  * Please read the documentation of
31  *CGeneralizedEllipsoidTemplate::setQuantiles() for learning
32  * the mathematical details about setting the desired confidence interval.
33  *
34  * <div align="center">
35  * <table border="0" cellspan="4" cellspacing="4" style="border-width: 1px;
36  *border-style: solid;">
37  * <tr> <td> mrpt::opengl::CEllipsoid </td> <td> \image html
38  *preview_CEllipsoid.png </td> </tr>
39  * </table>
40  * </div>
41  *
42  * \ingroup mrpt_opengl_grp
43  */
45 {
47 
48  protected:
49  /** Used to store computed values the first time this is rendered, and to
50  * avoid recomputing them again.
51  */
53 
54  /** The 2x2 or 3x3 covariance matrix that will determine the aspect of the
55  * ellipsoid. */
57  /** If set to true (default), a whole ellipsoid surface will be drawn, or if
58  * set to "false" it will be drawn as a "wireframe". */
59  bool m_drawSolid3D{true};
60  /** The number of "sigmas" for drawing the ellipse/ellipsoid (default=3) */
61  float m_quantiles{3};
62  /** The number of segments of a 2D ellipse (default=20) */
63  unsigned int m_2D_segments{20};
64  /** The number of segments of a 3D ellipse (in both "axis") (default=20) */
65  unsigned int m_3D_segments{20};
66  /** The line width for 2D ellipses or 3D wireframe ellipsoids (default=1) */
67  float m_lineWidth{1.0};
69 
70  public:
71  /** Set the 2x2 or 3x3 covariance matrix that will determine the aspect of
72  * the ellipsoid (if resizeToSize>0, the matrix will be cut to the square
73  * matrix of the given size) */
74  void setCovMatrix(
75  const mrpt::math::CMatrixDouble& m, int resizeToSize = -1);
76  /** Set the 2x2 or 3x3 covariance matrix that will determine the aspect of
77  * the ellipsoid (if resizeToSize>0, the matrix will be cut to the square
78  * matrix of the given size). */
79  void setCovMatrix(const mrpt::math::CMatrixFloat& m, int resizeToSize = -1);
80 
81  /** Set the 2x2 or 3x3 covariance matrix that will determine the aspect of
82  * the ellipsoid (if resizeToSize>0, the matrix will be cut to the square
83  * matrix of the given size)
84  */
85  template <typename T>
87  const mrpt::math::CMatrixFixed<T, 3, 3>& m, int resizeToSize = -1)
88  {
90  }
91 
92  /** Set the 2x2 or 3x3 covariance matrix that will determine the aspect of
93  * the ellipsoid (if resizeToSize>0, the matrix will be cut to the square
94  * matrix of the given size)
95  */
96  template <typename T>
98  {
100  }
101 
103  {
105  }
106 
107  /** If set to true (default), a whole ellipsoid surface will be drawn, or if
108  * set to "false" it will be drawn as a "wireframe". */
109  void enableDrawSolid3D(bool v)
110  {
111  m_drawSolid3D = v;
113  }
114  /** The number of "sigmas" for drawing the ellipse/ellipsoid (default=3) */
115  void setQuantiles(float q)
116  {
117  m_quantiles = q;
119  }
120  float getQuantiles() const { return m_quantiles; }
121  /** The number of segments of a 2D ellipse (default=20) */
122  void set2DsegmentsCount(unsigned int N)
123  {
124  m_2D_segments = N;
126  }
127  /** The number of segments of a 3D ellipse (in both "axis") (default=20) */
128  void set3DsegmentsCount(unsigned int N)
129  {
130  m_3D_segments = N;
132  }
133 
134  /** The line width for 2D ellipses or 3D wireframe ellipsoids (default=1) */
135  void setLineWidth(float w)
136  {
137  m_lineWidth = w;
139  }
140  float getLineWidth() const { return m_lineWidth; }
141  /** Render
142  * If one of the eigen value of the covariance matrix of the ellipsoid is
143  *null, ellipsoid will not
144  * be rendered to ensure stability in the rendering process.
145  */
146  void render_dl() const override;
147 
148  /** Evaluates the bounding box of this object (including possible children)
149  * in the coordinate frame of the object parent. */
150  void getBoundingBox(
152  mrpt::math::TPoint3D& bb_max) const override;
153 
154  /** Ray tracing
155  */
156  bool traceRay(const mrpt::poses::CPose3D& o, double& dist) const override;
157 
158  /** Constructor
159  */
161  : m_eigVal(),
162  m_eigVec(),
164  m_cov(2, 2),
165 
166  m_bb_min(0, 0, 0),
167  m_bb_max(0, 0, 0)
168  {
169  }
170  /** Private, virtual destructor: only can be deleted from smart pointers */
171  ~CEllipsoid() override = default;
172 };
173 
174 } // namespace mrpt::opengl
void notifyChange() const
Must be called to notify that the object has changed (so, the display list must be updated) ...
A compile-time fixed-size numeric matrix container.
Definition: CMatrixFixed.h:33
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:265
This class is a "CSerializable" wrapper for "CMatrixDynamic<double>".
Definition: CMatrixD.h:23
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:59
~CEllipsoid() override=default
Private, virtual destructor: only can be deleted from smart pointers.
float m_lineWidth
The line width for 2D ellipses or 3D wireframe ellipsoids (default=1)
Definition: CEllipsoid.h:67
math::CMatrixD m_eigVec
Definition: CEllipsoid.h:52
GLdouble GLdouble GLdouble GLdouble q
Definition: glext.h:3727
float getQuantiles() const
Definition: CEllipsoid.h:120
float m_quantiles
The number of "sigmas" for drawing the ellipse/ellipsoid (default=3)
Definition: CEllipsoid.h:61
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:4199
A renderizable object suitable for rendering with OpenGL&#39;s display lists.
mrpt::math::TPoint3D m_bb_min
Definition: CEllipsoid.h:68
unsigned int m_2D_segments
The number of segments of a 2D ellipse (default=20)
Definition: CEllipsoid.h:63
void setQuantiles(float q)
The number of "sigmas" for drawing the ellipse/ellipsoid (default=3)
Definition: CEllipsoid.h:115
void setCovMatrix(const mrpt::math::CMatrixFixed< 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:86
const GLdouble * v
Definition: glext.h:3684
#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:135
bool traceRay(const mrpt::poses::CPose3D &o, double &dist) const override
Ray tracing.
Definition: CEllipsoid.cpp:236
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:84
CEllipsoid()
Constructor.
Definition: CEllipsoid.h:160
unsigned int m_3D_segments
The number of segments of a 3D ellipse (in both "axis") (default=20)
Definition: CEllipsoid.h:65
The namespace for 3D scene representation and rendering.
Definition: CGlCanvasBase.h:15
const auto bb_max
mrpt::math::TPoint3D m_bb_max
Definition: CEllipsoid.h:68
void set2DsegmentsCount(unsigned int N)
The number of segments of a 2D ellipse (default=20)
Definition: CEllipsoid.h:122
math::CMatrixD m_cov
The 2x2 or 3x3 covariance matrix that will determine the aspect of the ellipsoid. ...
Definition: CEllipsoid.h:56
void set3DsegmentsCount(unsigned int N)
The number of segments of a 3D ellipse (in both "axis") (default=20)
Definition: CEllipsoid.h:128
const auto bb_min
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:109
A 2D ellipse or 3D ellipsoid, depending on the size of the m_cov matrix (2x2 or 3x3).
Definition: CEllipsoid.h:44
Lightweight 3D point.
Definition: TPoint3D.h:90
mrpt::math::CMatrixDouble getCovMatrix() const
Definition: CEllipsoid.h:102
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:324
float getLineWidth() const
Definition: CEllipsoid.h:140
math::CMatrixD m_eigVal
Used to store computed values the first time this is rendered, and to avoid recomputing them again...
Definition: CEllipsoid.h:52
math::CMatrixD m_prevComputedCov
Definition: CEllipsoid.h:52
void setCovMatrix(const mrpt::math::CMatrixFixed< T, 2, 2 > &m)
Set the 2x2 or 3x3 covariance matrix that will determine the aspect of the ellipsoid (if resizeToSize...
Definition: CEllipsoid.h:97
CMatrixDynamic< double > CMatrixDouble
Declares a matrix of double numbers (non serializable).



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: abb8b1a1e Fri Oct 18 14:19:12 2019 +0200 at vie oct 18 14:20:13 CEST 2019