33 #if MRPT_HAS_OPENGL_GLUT
36 const size_t dim = m_cov.cols();
38 if (m_eigVal(0, 0) != 0.0 && m_eigVal(1, 1) != 0.0 &&
39 (dim == 2 || m_eigVal(2, 2) != 0.0) && m_quantiles != 0.0)
71 M.noalias() = double(m_quantiles) * m_eigVal * m_eigVec.adjoint();
76 for (i = 0, ang = 0; i < m_2D_segments;
77 i++, ang += (
M_2PI / m_2D_segments))
79 double ccos = cos(ang);
80 double ssin = sin(ang);
83 ccos * M.get_unsafe(0, 0) + ssin * M.get_unsafe(1, 0);
85 ccos * M.get_unsafe(0, 1) + ssin * M.get_unsafe(1, 1);
93 const double max_radius =
94 m_quantiles * std::max(m_eigVal(0, 0), m_eigVal(1, 1));
98 m_pose.composePoint(m_bb_min, m_bb_min);
99 m_pose.composePoint(m_bb_max, m_bb_max);
117 mat[3] = mat[7] = mat[11] = 0;
119 mat[12] = mat[13] = mat[14] = 0;
121 mat[0] = m_eigVec(0, 0);
122 mat[1] = m_eigVec(1, 0);
123 mat[2] = m_eigVec(2, 0);
124 mat[4] = m_eigVec(0, 1);
125 mat[5] = m_eigVec(1, 1);
126 mat[6] = m_eigVec(2, 1);
127 mat[8] = m_eigVec(0, 2);
128 mat[9] = m_eigVec(1, 2);
129 mat[10] = m_eigVec(2, 2);
131 GLUquadricObj*
obj = gluNewQuadric();
137 gluQuadricDrawStyle(
obj, m_drawSolid3D ? GLU_FILL : GLU_LINE);
142 m_eigVal(0, 0) * m_quantiles, m_eigVal(1, 1) * m_quantiles,
143 m_eigVal(2, 2) * m_quantiles);
145 gluSphere(
obj, 1, m_3D_segments, m_3D_segments);
150 gluDeleteQuadric(
obj);
154 const double max_radius =
157 m_eigVal(0, 0), std::max(m_eigVal(1, 1), m_eigVal(2, 2)));
161 m_pose.composePoint(m_bb_min, m_bb_min);
162 m_pose.composePoint(m_bb_max, m_bb_max);
170 cout <<
"Covariance matrix leading to error is:" << endl
178 writeToStreamRender(out);
179 out << m_cov << m_drawSolid3D << m_quantiles << (
uint32_t)m_2D_segments
180 << (
uint32_t)m_3D_segments << m_lineWidth;
192 readFromStreamRender(
in);
197 m_cov =
c.cast<
double>();
204 in >> m_drawSolid3D >> m_quantiles;
212 m_prevComputedCov = m_cov;
226 return (
t = -b_2 /
a) >= 0;
230 if ((
t = (-b_2 - delta) /
a) >= 0)
233 return (
t = (-b_2 + delta) /
a) >= 0;
241 if (m_cov.rows() != 3)
return false;
246 for (
size_t i = 0; i < 3; i++)
250 for (
size_t j = 0; j < 3; j++)
252 double vji = m_eigVec(j, i);
257 double a = 0, b_2 = 0,
c = -
square(m_quantiles);
258 for (
size_t i = 0; i < 3; i++)
260 double ev = m_eigVal(i, i);
275 m.rows() == 2 || m.rows() == 3 ||
276 (resizeToSize > 0 && (resizeToSize == 2 || resizeToSize == 3)));
279 if (resizeToSize > 0 && resizeToSize < (
int)m.rows())
280 m_cov.setSize(resizeToSize, resizeToSize);
282 if (m_cov == m_prevComputedCov)
return;
287 const double d = m_cov.det();
288 if (d == 0 || d != d)
292 m_prevComputedCov = m_cov;
293 m_eigVec.zeros(3, 3);
294 m_eigVal.zeros(3, 3);
299 m_prevComputedCov = m_cov;
300 if (m_cov.eigenVectors(m_eigVec, m_eigVal))
302 m_eigVal = m_eigVal.array().sqrt().matrix();
308 m_eigVec.zeros(3, 3);
309 m_eigVal.zeros(3, 3);