23 const auto& pts = m_render_pts;
30 const auto N = pts.size();
31 for (
size_t i = 0; i < N; i++)
33 const auto ip = (i + 1) % N;
34 vbd.emplace_back(pts[i][0], pts[i][1], .0f);
35 vbd.emplace_back(pts[ip][0], pts[ip][1], .0f);
39 cbd.assign(vbd.size(), m_color);
45 const auto& pts = m_render_pts;
51 const auto slices = m_numSegments, stacks = m_numSegments;
58 const size_t idx_1st_slice = 1;
62 for (
size_t i = 0; i < stacks; i++)
64 const auto idx = idx_1st_slice + i;
65 vbd.emplace_back(pts[0]);
66 vbd.emplace_back(pts[idx]);
71 for (
size_t s = 0; s < slices - 3; s++)
73 size_t idx0 = idx_1st_slice + stacks * s;
74 size_t idx1 = idx0 + stacks;
76 for (
size_t i = 0; i < stacks; i++)
79 (i == (stacks - 1) ? 0 : i + 1);
81 vbd.emplace_back(pts[idx0 + i]);
82 vbd.emplace_back(pts[idx1 + ii]);
84 vbd.emplace_back(pts[idx1 + ii]);
85 vbd.emplace_back(pts[idx1 + i]);
87 vbd.emplace_back(pts[idx1 + i]);
88 vbd.emplace_back(pts[idx0 + i]);
90 vbd.emplace_back(pts[idx0 + i]);
91 vbd.emplace_back(pts[idx0 + ii]);
93 vbd.emplace_back(pts[idx0 + ii]);
94 vbd.emplace_back(pts[idx1 + ii]);
100 const size_t idxN = pts.size() - 1;
101 const size_t idx_last_slice = idx_1st_slice + (slices - 3) * stacks;
103 for (
size_t i = 0; i < stacks; i++)
105 vbd.emplace_back(pts[idxN]);
106 vbd.emplace_back(pts[idx_last_slice + i]);
110 cbd.assign(vbd.size(), m_color);
117 const auto& pts = m_render_pts;
123 const auto N = pts.size();
124 for (
size_t i = 0; i < N; i++)
126 const auto ip = (i + 1) % N;
128 P3f(0, 0, 0), P3f(pts[i][0], pts[i][1], .0f),
129 P3f(pts[ip][0], pts[ip][1], .0f));
133 for (
auto& t : tris) t.setColor(m_color);
139 const auto& pts = m_render_pts;
145 const auto slices = m_numSegments, stacks = m_numSegments;
152 const size_t idx_1st_slice = 1;
156 for (
size_t i = 0; i < stacks; i++)
158 const auto idx = idx_1st_slice + i;
159 const auto idxp = idx_1st_slice + ((i + 1) % stacks);
163 pts[0], pts[idx], pts[idxp],
165 pts[0], pts[idx], pts[idxp]);
170 for (
size_t s = 0; s < slices - 3; s++)
172 size_t idx0 = idx_1st_slice + stacks * s;
173 size_t idx1 = idx0 + stacks;
175 for (
size_t i = 0; i < stacks; i++)
178 (i == (stacks - 1) ? 0 : i + 1);
182 pts[idx0 + i], pts[idx0 + ii], pts[idx1 + i],
184 pts[idx0 + i], pts[idx0 + ii], pts[idx1 + i]);
187 pts[idx1 + ii], pts[idx1 + i], pts[idx0 + ii],
189 pts[idx1 + ii], pts[idx1 + i], pts[idx0 + ii]);
195 const size_t idxN = pts.size() - 1;
196 const size_t idx_last_slice = idx_1st_slice + (slices - 3) * stacks;
198 for (
size_t i = 0; i < stacks; i++)
200 const auto idx = idx_last_slice + i;
201 const auto idxp = idx_last_slice + ((i + 1) % stacks);
205 pts[idx], pts[idxN], pts[idxp],
207 pts[idx], pts[idxN], pts[idxp]);
211 for (
auto& t : tris) t.setColor(m_color);
220 pts.reserve(m_numSegments);
221 const double Aa = 2 *
M_PI / m_numSegments;
222 for (
double ang = 0; ang < 2 *
M_PI; ang += Aa)
224 const double ccos = cos(ang);
225 const double ssin = sin(ang);
227 pts.resize(pts.size() + 1);
229 auto& pt = pts.back();
231 pt[0] =
d2f(m_mean[0] + ccos * U(0, 0) + ssin * U(0, 1));
232 pt[1] =
d2f(m_mean[1] + ccos * U(1, 0) + ssin * U(1, 1));
237 const double x,
const double y,
const double z,
242 pts.resize(pts.size() + 1);
244 pt[0] =
d2f(
mean[0] + x * M(0, 0) + y * M(0, 1) + z * M(0, 2));
245 pt[1] =
d2f(
mean[1] + x * M(1, 0) + y * M(1, 1) + z * M(1, 2));
246 pt[2] =
d2f(
mean[2] + x * M(2, 0) + y * M(2, 1) + z * M(2, 2));
255 const auto slices = m_numSegments, stacks = m_numSegments;
260 std::vector<double> slice_cos(slices), slice_sin(slices);
261 for (uint32_t i = 0; i < slices; i++)
263 double angle =
M_PI * i / double(slices - 1);
264 slice_sin[i] = sin(angle);
265 slice_cos[i] = cos(angle);
268 std::vector<double> stack_sin(stacks), stack_cos(stacks);
269 for (uint32_t i = 0; i < stacks; i++)
271 double angle = 2 *
M_PI * i / double(stacks);
272 stack_sin[i] = sin(angle);
273 stack_cos[i] = cos(angle);
281 pts.reserve((slices - 2) * stacks + 2);
283 for (uint32_t i = 0; i < slices; i++)
287 else if (i == (slices - 1))
291 const double x = slice_cos[i];
292 const double R = slice_sin[i];
294 for (uint32_t j = 0; j < stacks; j++)
296 const double y =
R * stack_cos[j];
297 const double z =
R * stack_sin[j];
void generatePoints(const cov_matrix_t &U, std::vector< array_parameter_t > &out_params_pts) const
A compile-time fixed-size numeric matrix container.
void aux_add3DpointWithEigenVectors(const double x, const double y, const double z, std::vector< mrpt::math::CMatrixFixed< float, 3, 1 >> &pts, const mrpt::math::CMatrixFixed< double, 3, 3 > &M, const mrpt::math::CMatrixFixed< double, 3, 1 > &mean)
void implUpdate_Wireframe()
void implUpdate_Triangles()
std::vector< mrpt::math::TPoint3Df > m_vertex_buffer_data
float d2f(const double d)
shortcut for static_cast<float>(double)
This base provides a set of functions for maths stuff.
#define ASSERT_EQUAL_(__A, __B)
Assert comparing two values, reporting their actual values upon failure.
#define ASSERT_ABOVEEQ_(__A, __B)
A class that generalizes the concept of an ellipsoid to arbitrary parameterizations of uncertainty sh...
std::vector< mrpt::img::TColor > m_color_buffer_data
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
std::vector< mrpt::opengl::TTriangle > m_triangles
List of triangles.
The namespace for 3D scene representation and rendering.
double mean(const CONTAINER &v)
Computes the mean value of a vector.
TPoint3D_< float > TPoint3Df