43 for (
size_t i = 0; i < f.
vertices.size(); i++)
50 const vector<math::TPolygon3D>& polys, vector<TPoint3D>& vertices,
51 vector<CPolyhedron::TPolyhedronFace>& faces)
53 vertices.reserve(4 * polys.size());
54 faces.reserve(polys.size());
56 it != polys.end(); ++it)
58 size_t N = it->size();
59 if (N < 3)
return false;
62 for (
size_t i = 0; i < N; i++)
65 find(vertices.begin(), vertices.end(), (*it)[i]);
66 if (it2 == vertices.end())
69 vertices.push_back((*it)[i]);
72 f.
vertices[i] = it2 - vertices.begin();
98 vector<JohnsonBodyPart>& parts)
109 if (parts.size() == 0) parts.push_back(
INF_NO_BODY);
114 if (numBaseEdges & 1)
return false;
115 if (i == N - 1)
return false;
119 if (i != N - 1)
return false;
120 if (parts.size() == 0) parts.push_back(
INF_NO_BODY);
127 if (parts.size() > 0)
return false;
137 if (numBaseEdges != 10)
return false;
138 if (i == N - 1)
return false;
142 if (i != N - 1)
return false;
143 if (parts.size() == 0) parts.push_back(
INF_NO_BODY);
150 if (parts.size() > 0)
return false;
160 if (i == N - 1)
return false;
171 if (i == N - 1)
return false;
176 if (numBaseEdges > 5)
return false;
177 if (i != N - 1)
return false;
178 if (parts.size() == 0) parts.push_back(
INF_NO_BODY);
182 if (numBaseEdges > 5)
return false;
183 if (i != 1)
return false;
188 if (parts.size() > 0 && (*parts.rbegin() ==
PRISM))
190 if (parts.size() == 0) parts.push_back(
INF_NO_BODY);
191 parts.push_back(
PRISM);
202 if (parts.size() == 0)
return false;
217 return numBaseEdges >> 1;
224 size_t numBaseEdges,
double angleShift,
double baseRadius,
225 double edgeLength,
bool isRotated,
bool isUpwards,
size_t base,
226 vector<TPoint3D>& verts, vector<CPolyhedron::TPolyhedronFace>& faces)
228 size_t edges2 = numBaseEdges >> 1;
230 baseRadius * sin(
M_PI / numBaseEdges) / sin(
M_PI / edges2);
237 baseRadius * cos(
M_PI / numBaseEdges) -
238 minorRadius * cos(
M_PI / edges2)));
239 double height = verts[base].z + (isUpwards ? h : -h);
240 angleShift +=
M_PI / edges2 +
241 (isRotated ? -
M_PI / numBaseEdges :
M_PI / numBaseEdges);
242 size_t minorBase = verts.size();
243 for (
size_t i = 0; i < edges2; i++)
245 double ang = angleShift + 2 *
M_PI * i / edges2;
247 TPoint3D(minorRadius * cos(ang), minorRadius * sin(ang),
height));
253 size_t iq = isRotated ? 1 : 2, it = 0;
254 for (
size_t i = 0; i < edges2; i++)
257 size_t iiq = (iq + 1) % numBaseEdges + base;
258 size_t iiiq = (iiq + 1) % numBaseEdges + base;
259 size_t iit = (it + 1) % edges2 + minorBase;
267 iq = (iq + 2) % numBaseEdges;
268 it = (it + 1) % edges2;
269 faces.push_back(tri);
270 faces.push_back(quad);
272 if (edges2 >= 3) faces.push_back(cBase);
275 double angleShift,
double baseRadius,
bool isRotated,
bool isUpwards,
276 size_t base, vector<TPoint3D>& verts,
277 vector<CPolyhedron::TPolyhedronFace>& faces)
279 double R1 = baseRadius * sqrt((5.0 - sqrt(5.0)) / 10.0);
280 double R2 = baseRadius * sqrt((5.0 + sqrt(5.0)) / 10.0);
281 double baseHeight = verts[base].z;
283 angleShift +=
M_PI / 10;
284 if (isRotated) angleShift +=
M_PI / 5;
285 for (
size_t i = 0; i < 5; i++)
287 double a = (i + i + 1) *
M_PI / 5 + angleShift;
288 double b = (i + i) *
M_PI / 5 + angleShift;
289 double ca = cos(
a), sa = sin(
a), cb = cos(
b), sb = sin(
b);
292 p1[i].
z = baseHeight + (isUpwards ? R2 : -R2);
295 p2[i].
z = baseHeight + (isUpwards ? R1 : -R1);
297 size_t newBase = verts.size();
298 for (
size_t i = 0; i < 5; i++) verts.push_back(p1[i]);
299 for (
size_t i = 0; i < 5; i++) verts.push_back(p2[i]);
302 g.vertices.resize(5);
303 size_t baseStart = isRotated ? 2 : 1;
304 for (
size_t i = 0; i < 5; i++)
306 size_t ii = (i + 1) % 5;
312 f.
vertices[1] = ((i + i + baseStart) % 10) + base;
313 f.
vertices[2] = ((i + i + 9 + baseStart) % 10) + base;
315 g.vertices[0] = newBase + (ii % 5) + 5;
316 g.vertices[1] = newBase + i;
317 g.vertices[2] = newBase + i + 5;
318 g.vertices[3] = (i + i + baseStart) % 10 + base;
319 g.vertices[4] = (i + i + baseStart + 1) % 10 + base;
322 for (
size_t i = 0; i < 5; i++)
g.vertices[i] = i + newBase;
333 return numBaseEdges + ((numBaseEdges >= 6) ? 1 : 0);
337 return numBaseEdges << 1;
349 if (*it == e.
v1 || *it == e.
v2) hm++;
355 if (planes.size() < 3)
return false;
360 for (
size_t i = 1; i < planes.size(); i++)
switch (o)
364 if (
obj.getPlane(pl))
366 else if (
obj.getLine(l))
368 else if (
obj.getPoint(pnt))
377 else if (
obj.getPoint(pnt))
383 if (!planes[i]->contains(pnt))
return false;
396 it != fs.end(); ++it)
398 const vector<uint32_t>& f = it->vertices;
410 if (hmf == 7)
return true;
418 for (where = 0; where < es.size(); where++)
426 throw std::logic_error(
"Internal error. Edge not found");
436 const vector<uint32_t>& f = it->vertices;
444 if (
res == 3)
return true;
452 throw std::logic_error(
"Faces must have exactly 3, 4 or 5 vertices.");
455 for (
size_t i = 1; i < N; i++)
458 throw std::logic_error(
"There is a non-regular polygon.");
462 throw std::logic_error(
"There is a non-regular polygon.");
475 const vector<TPoint3D>& vertices)
const 480 double CPolyhedron::TPolyhedronFace::area(
const vector<TPoint3D>& vs)
const 483 size_t N = vertices.size();
484 vector<SegmentVector> d(N - 1);
485 for (
size_t i = 1; i < N; i++)
488 for (
size_t j = 0; j < 3; j++)
490 d[i - 1][j] = vs[vertices[i]][j] - vs[vertices[0]][j];
491 d[i - 1].mod +=
square(d[i - 1][j]);
493 d[i - 1].mod = sqrt(d[i - 1].mod);
496 for (
size_t i = 1; i < N - 1; i++)
498 square(d[i - 1].mod * d[i].mod) -
499 square(dotProduct<3, double>(d[i - 1], d[i])));
503 void CPolyhedron::TPolyhedronFace::getCenter(
504 const vector<TPoint3D>& vrts,
TPoint3D&
p)
const 506 p.x =
p.y =
p.z = 0.0;
508 it != vertices.end(); ++it)
514 size_t N = vertices.size();
520 CPolyhedron::CPolyhedron(
const std::vector<math::TPolygon3D>& polys)
521 : mEdges(), mWireframe(false), mLineWidth(1), polygonsUpToDate(false)
523 std::vector<TPoint3D> vertices(0);
524 std::vector<TPolyhedronFace> faces;
526 throw std::logic_error(
"Can't create CPolygon");
528 mFaces = std::move(faces);
534 const vector<TPoint3D>& vertices,
const vector<vector<uint32_t>>& faces)
536 vector<TPolyhedronFace> aux;
538 it != faces.end(); ++it)
548 double x1,
double x2,
double y1,
double y2,
double z1,
double z2)
550 vector<TPoint3D> verts;
551 vector<TPolyhedronFace> faces;
552 for (
int i = 0; i < 8; i++)
554 TPoint3D((i & 1) ? x2 : x1, (i & 2) ? y2 : y1, (i & 4) ?
z2 :
z1));
555 static uint32_t faceVertices[] = {0, 1, 5, 4, 2, 3, 7, 6, 0, 2, 6, 4,
556 1, 3, 7, 5, 0, 1, 3, 2, 4, 5, 7, 6};
558 for (
uint32_t*
p = reinterpret_cast<uint32_t*>(&faceVertices);
569 const vector<TPoint2D>& baseVertices,
double height)
572 if (baseVertices.size() < 3)
throw std::logic_error(
"Not enought vertices");
573 vector<TPoint3D> verts;
574 vector<TPolyhedronFace> faces;
577 it != baseVertices.end(); ++it)
578 verts.push_back(
TPoint3D(it->x, it->y, 0));
583 g.vertices.push_back(1);
590 g.vertices.push_back(i);
597 const vector<TPoint2D>& baseVertices,
double height1,
double height2)
600 if (N < 3)
throw std::logic_error(
"Not enought vertices");
601 vector<TPoint3D> verts;
602 verts.reserve(N + 2);
603 vector<TPolyhedronFace> faces;
604 faces.reserve(N << 1);
605 verts.push_back(
TPoint3D(0, 0, height1));
607 it != baseVertices.end(); ++it)
608 verts.push_back(
TPoint3D(it->x, it->y, 0));
609 verts.push_back(
TPoint3D(0, 0, -height2));
612 g.vertices.resize(3);
614 g.vertices[0] = N + 1;
629 const vector<TPoint2D>& baseVertices,
double height,
double ratio)
632 if (
n < 3)
throw std::logic_error(
"Not enough vertices");
633 vector<TPoint3D> verts(
n +
n);
634 vector<TPolyhedronFace> faces(
n + 2);
637 g.vertices.resize(
n);
641 verts[i] =
TPoint3D(baseVertices[i].
x, baseVertices[i].
y, 0);
643 baseVertices[i].
x * ratio, baseVertices[i].
y * ratio,
height);
659 const vector<TPoint2D>& bottomBase,
const vector<TPoint2D>& topBase,
663 if (
n < 3)
throw std::logic_error(
"Not enough vertices");
664 if (
n != topBase.size())
665 throw std::logic_error(
"Bases' number of vertices do not match");
666 vector<TPoint3D> verts(
n +
n);
667 vector<TPolyhedronFace> faces(
n +
n + 2);
670 g.vertices.resize(
n);
674 verts[i] =
TPoint3D(bottomBase[i].
x, bottomBase[i].
y, 0);
689 faces[
n +
n + 1] = h;
697 vector<TPoint3D> verts(8);
698 vector<TPolyhedronFace> faces(6);
702 if (i & 1) verts[i] = verts[i] +
v1;
703 if (i & 2) verts[i] = verts[i] +
v2;
704 if (i & 4) verts[i] = verts[i] +
v3;
726 faces[i + 3].vertices.resize(4);
728 faces[i + 3].vertices[j] = faces[i].vertices[j] + valueAdd;
734 const vector<TPoint2D>& baseVertices,
double height1,
double ratio1,
735 double height2,
double ratio2)
738 size_t N = baseVertices.size();
739 vector<TPoint3D> verts(3 * N);
741 for (
size_t i = 0; i < N; i++)
743 double x = baseVertices[i].x;
744 double y = baseVertices[i].y;
748 verts[i + N].x =
x * ratio1;
749 verts[i + N].y =
y * ratio1;
750 verts[i + N].z = height1;
751 verts[i + N2].x =
x * ratio2;
752 verts[i + N2].y =
y * ratio2;
753 verts[i + N2].z = -height2;
757 vector<TPolyhedronFace> faces(N2 + 2);
760 g.vertices.resize(N);
762 for (
size_t i = 0; i < N; i++)
764 size_t i2 = (i + 1) % N;
782 uint32_t numBaseEdges,
double baseRadius,
double basesDistance)
784 if (numBaseEdges < 3)
throw std::logic_error(
"Not enough vertices");
785 if (basesDistance == 0 || baseRadius == 0)
return CreateEmpty();
786 size_t numBaseEdges2 = numBaseEdges << 1;
787 vector<TPoint3D> verts(numBaseEdges2 + 2);
788 double space = 2 *
M_PI / numBaseEdges;
789 double shift = space / 2;
790 double height1 = basesDistance / 2;
791 double cospii = cos(
M_PI / numBaseEdges);
793 height1 * (cospii + 1) /
795 for (
size_t i = 0; i < numBaseEdges; i++)
797 double ang = space * i;
798 double ang2 = ang + shift;
799 size_t ii = i + numBaseEdges;
800 verts[i].x = baseRadius * cos(ang);
801 verts[i].y = baseRadius * sin(ang);
802 verts[i].z = -height1;
803 verts[ii].x = baseRadius * cos(ang2);
804 verts[ii].y = baseRadius * sin(ang2);
805 verts[ii].z = height1;
807 verts[numBaseEdges2].x = 0;
808 verts[numBaseEdges2].y = 0;
809 verts[numBaseEdges2].z = -height2;
810 verts[numBaseEdges2 + 1].x = 0;
811 verts[numBaseEdges2 + 1].y = 0;
812 verts[numBaseEdges2 + 1].z = height2;
813 vector<TPolyhedronFace> faces(numBaseEdges2);
816 g.vertices.resize(4);
818 g.vertices[3] = numBaseEdges2 + 1;
819 for (
size_t i = 0; i < numBaseEdges; i++)
821 size_t ii = (i + 1) % numBaseEdges;
822 size_t i2 = i + numBaseEdges;
828 g.vertices[2] = ii + numBaseEdges;
830 faces[i + numBaseEdges] =
g;
840 if (numBaseEdges < 3)
throw std::logic_error(
"Not enough vertices");
841 vector<JohnsonBodyPart> parts;
843 throw std::logic_error(
"Invalid string");
845 size_t nParts = parts.size();
846 double edgeLength = 2 * baseRadius * sin(
M_PI / numBaseEdges);
847 double antiPrismHeight = sqrt(
849 square(baseRadius) * (2 - 2 * cos(
M_PI / numBaseEdges)));
851 size_t nVerts = numBaseEdges * (nParts - 1) +
855 for (
size_t i = 0; i < nParts; i++)
857 vector<TPoint3D> verts;
858 verts.reserve(nVerts);
859 vector<TPolyhedronFace> faces;
860 faces.reserve(nFaces);
863 double h, mHeight = 0;
864 vector<pair<double, size_t>> basePositionInfo(nParts - 1);
865 for (
size_t i = 0; i < nParts - 1; i++)
867 if (parts[i] ==
PRISM)
876 basePositionInfo[i] = make_pair(mHeight += h, shifts);
879 double semi =
M_PI / numBaseEdges;
882 basePositionInfo.begin();
883 it != basePositionInfo.end(); ++it)
885 numBaseEdges, baseRadius, it->first - mHeight, semi * it->second,
887 size_t initialBase = 0, endBase = 0;
889 face.vertices.reserve(numBaseEdges);
891 for (
size_t i = 0; i < nParts; i++)
897 face.vertices.resize(numBaseEdges);
898 for (
size_t i = 0; i < numBaseEdges; i++)
899 face.vertices[i] = endBase + i;
900 faces.push_back(
face);
904 face.vertices.resize(numBaseEdges);
905 for (
size_t i = 0; i < numBaseEdges; i++)
906 face.vertices[i] = initialBase + i;
907 faces.push_back(
face);
913 baseRadius * sqrt(4 *
square(sin(
M_PI / numBaseEdges)) - 1);
914 face.vertices.resize(3);
915 face.vertices[0] = verts.size();
916 face.vertices[1] = initialBase + numBaseEdges - 1;
917 face.vertices[2] = initialBase;
920 faces.push_back(
face);
921 face.vertices[1] =
face.vertices[2];
923 }
while (
face.vertices[2] < initialBase + numBaseEdges);
925 TPoint3D(0, 0, verts[initialBase].
z + apexHeight));
932 baseRadius * sqrt(4 *
square(sin(
M_PI / numBaseEdges)) - 1);
933 face.vertices.resize(3);
934 face.vertices[0] = verts.size();
935 face.vertices[1] = endBase + numBaseEdges - 1;
936 face.vertices[2] = endBase;
939 faces.push_back(
face);
940 face.vertices[1] =
face.vertices[2];
942 }
while (
face.vertices[2] < endBase + numBaseEdges);
943 verts.push_back(
TPoint3D(0, 0, verts[endBase].
z - apexHeight));
950 numBaseEdges, basePositionInfo.rbegin()->second * semi,
951 baseRadius, edgeLength,
false,
true, initialBase, verts,
958 numBaseEdges, basePositionInfo[0].second * semi, baseRadius,
959 edgeLength,
false,
false, endBase, verts, faces);
965 numBaseEdges, basePositionInfo.rbegin()->second * semi,
966 baseRadius, edgeLength,
true,
true, initialBase, verts,
973 numBaseEdges, basePositionInfo[0].second * semi, baseRadius,
974 edgeLength,
true,
false, endBase, verts, faces);
978 face.vertices.resize(4);
979 for (
size_t i = 0; i < numBaseEdges; i++)
981 size_t ii = (i + 1) % numBaseEdges;
982 face.vertices[0] = initialBase + i;
983 face.vertices[1] = endBase + i;
984 face.vertices[2] = endBase + ii;
985 face.vertices[3] = initialBase + ii;
986 faces.push_back(
face);
992 face.vertices.resize(3);
993 face.vertices[0] = initialBase;
994 face.vertices[1] = endBase;
995 face.vertices[2] = initialBase + 1;
996 bool nextIsEnd =
true;
998 size_t nextInitial = 2;
999 for (
size_t i = 0; i < numBaseEdges << 1; i++)
1001 faces.push_back(
face);
1002 face.vertices[0] =
face.vertices[1];
1003 face.vertices[1] =
face.vertices[2];
1006 face.vertices[2] = endBase + nextEnd;
1007 nextEnd = (nextEnd + 1) % numBaseEdges;
1011 face.vertices[2] = initialBase + nextInitial;
1012 nextInitial = (nextInitial + 1) % numBaseEdges;
1014 nextIsEnd = !nextIsEnd;
1022 basePositionInfo.rbegin()->second * semi, baseRadius,
false,
1023 true, initialBase, verts, faces);
1029 basePositionInfo[0].second * semi, baseRadius,
false,
false,
1030 endBase, verts, faces);
1036 basePositionInfo.rbegin()->second * semi, baseRadius,
true,
1037 true, initialBase, verts, faces);
1043 basePositionInfo[0].second * semi, baseRadius,
true,
false,
1044 endBase, verts, faces);
1047 throw std::logic_error(
"Internal error");
1049 initialBase = endBase;
1050 endBase += numBaseEdges;
1061 #if MRPT_HAS_OPENGL_GLUT 1071 it !=
mEdges.end(); ++it)
1089 it !=
mFaces.end(); ++it)
1092 glNormal3f(it->normal[0], it->normal[1], it->normal[2]);
1094 it2 != it->vertices.end(); ++it2)
1114 lengths.resize(
mEdges.size());
1117 it !=
mEdges.end(); ++it, ++it2)
1123 areas.resize(
mFaces.size());
1126 it !=
mFaces.end(); ++it, ++it2)
1142 vector<double> areas(
mFaces.size());
1146 it !=
mFaces.end(); ++it, ++itP, ++itA)
1147 res += abs(itP->plane.distance(center)) * (*itA);
1156 for (
size_t i = 0; i < N; i++) vec[i] =
tempPolygons[i].poly;
1160 std::vector<math::TPolygon3D>& vec)
const 1162 vec.resize(
mFaces.size());
1164 vector<TPoint3D> nVerts;
1175 vector<TPolygon3D> polys, polysTMP, polys2;
1177 polys2.reserve(polys.size());
1179 it != polys.end(); ++it)
1181 polys2.insert(polys2.end(), polysTMP.begin(), polysTMP.end());
1183 polys2.push_back(*it);
1189 it !=
mFaces.end(); ++it)
1192 throw std::logic_error(
"Bad face specification");
1200 if (N == 0)
throw new std::logic_error(
"There are no vertices");
1201 center.
x = center.
y = center.
z = 0;
1319 size_t NV =
mFaces.size();
1320 size_t NE =
mEdges.size();
1322 vector<TPlane> planes(NF);
1323 for (
size_t i = 0; i < NF; i++)
1333 vector<TPoint3D> vertices(NV);
1334 for (
size_t i = 0; i < NV; i++)
1336 for (
size_t j = 0; j < NF; j++) incidence(i, j) =
false;
1337 vector<const TPlane*> fPls;
1338 fPls.reserve(
mFaces[i].vertices.size());
1340 it !=
mFaces[i].vertices.end(); ++it)
1342 incidence(i, *it) =
true;
1343 fPls.push_back(&planes[*it]);
1346 throw std::logic_error(
"Dual polyhedron cannot be found");
1348 vector<TPolyhedronFace> faces(NF);
1349 for (
size_t i = 0; i < NF; i++)
1350 for (
size_t j = 0; j < NV; j++)
1351 if (incidence(j, i)) faces[i].vertices.push_back(j);
1355 for (
size_t i = 0; i < NE; i++)
1356 for (
size_t j = 0; j < NV; j++)
1359 it != faces.end(); ++it)
1361 vector<uint32_t>&
face = it->vertices;
1362 if (
face.size() <= 3)
continue;
1369 for (
size_t i = 0; i < NE; i++)
1385 return mrpt::make_aligned_shared<CPolyhedron>(vertices, faces);
1393 else if (factor < 1)
1395 size_t NE =
mEdges.size();
1397 size_t NF =
mFaces.size();
1398 vector<TPoint3D> vertices(NE << 1);
1399 vector<TPolyhedronFace> faces(NV + NF);
1400 for (
size_t i = 0; i < NE; i++)
1406 for (
size_t j = 0; j < 3; j++)
1408 double d = (p2[j] - p1[j]) * factor / 2;
1412 faces[
mEdges[i].v1].vertices.push_back(i + i);
1413 faces[
mEdges[i].v2].vertices.push_back(i + i + 1);
1415 for (
size_t i = 0; i < NV; i++)
1417 vector<uint32_t>& f = faces[i].vertices;
1418 size_t sf = f.size();
1419 if (sf == 3)
continue;
1420 for (
size_t j = 1; j < sf - 1; j++)
1426 if (!((e1.
v1 == i || e1.
v2 == i) &&
1427 (e2.
v1 == i || e2.
v2 == i)))
1431 (e2.
v1 == i) ? e2.
v2 : e2.
v1))
1434 f.erase(f.begin() + j);
1439 for (
size_t i = 0; i < NF; i++)
1441 vector<uint32_t>& f = faces[i + NV].vertices;
1442 const vector<uint32_t>& cf =
mFaces[i].vertices;
1443 size_t hmV = cf.size();
1444 f.reserve(hmV << 1);
1445 for (
size_t j = 0; j < hmV; j++)
1450 f.push_back(where << 1);
1451 f.push_back((where << 1) + 1);
1455 f.push_back((where << 1) + 1);
1456 f.push_back(where << 1);
1460 return mrpt::make_aligned_shared<CPolyhedron>(vertices, faces);
1462 else if (factor == 1)
1464 size_t NE =
mEdges.size();
1466 size_t NF =
mFaces.size();
1467 vector<TPoint3D> vertices(NE);
1468 vector<TPolyhedronFace> faces(NV + NF);
1469 for (
size_t i = 0; i < NE; i++)
1474 for (
size_t j = 0; j < 3; j++)
dst[j] = (p1[j] + p2[j]) / 2;
1475 faces[
mEdges[i].v1].vertices.push_back(i);
1476 faces[
mEdges[i].v2].vertices.push_back(i);
1478 for (
size_t i = 0; i < NV; i++)
1480 vector<uint32_t>& f = faces[i].vertices;
1481 size_t sf = f.size();
1482 if (sf == 3)
continue;
1483 for (
size_t j = 1; j < sf - 1; j++)
1489 if (!((e1.
v1 == i || e1.
v2 == i) &&
1490 (e2.
v1 == 1 || e2.
v2 == i)))
1494 (e2.
v1 == i) ? e2.
v2 : e2.
v1))
1497 f.erase(f.begin() + j);
1502 for (
size_t i = 0; i < NF; i++)
1504 vector<uint32_t>& f = faces[i + NV].vertices;
1505 const vector<uint32_t>& cf =
mFaces[i].vertices;
1506 size_t hmV = cf.size();
1508 for (
size_t j = 0; j < hmV; j++)
1515 return mrpt::make_aligned_shared<CPolyhedron>(vertices, faces);
1525 else if (factor == 0)
1528 size_t NE =
mEdges.size();
1529 size_t NF =
mFaces.size();
1530 vector<TPolygon3D> origFaces(NF);
1534 vector<TPoint3D> polyCenters(NF);
1535 vector<TPoint3D> polyNewCenters(NF);
1537 for (
size_t i = 0; i < NF; i++)
1539 origFaces[i].getCenter(polyCenters[i]);
1540 polyCenters[i] -= cnt;
1541 polyNewCenters[i] = polyCenters[i];
1542 polyNewCenters[i] *= (1 + factor);
1543 polyNewCenters[i] += cnt;
1544 NNV += origFaces[i].size();
1546 vector<TPoint3D> vertices(NNV);
1547 vector<TPolyhedronFace> faces(NF + NV + NE);
1549 for (
size_t i = 0; i < NF; i++)
1551 const TPoint3D& oC = polyCenters[i];
1552 const TPoint3D& nC = polyNewCenters[i];
1554 vector<uint32_t>& f = faces[i].vertices;
1555 size_t oPS = oP.size();
1556 for (
size_t j = 0; j < oPS; j++)
1558 vertices[j + ind] = nC + (oP[j] - oC);
1559 f.push_back(j + ind);
1560 size_t curr =
mFaces[i].vertices[j];
1561 faces[NF + curr].vertices.push_back(j + ind);
1564 mEdges, curr,
mFaces[i].vertices[(j + oPS - 1) % oPS], edge);
1565 faces[NF + NV + edge].vertices.push_back(j + ind);
1567 mEdges, curr,
mFaces[i].vertices[(j + 1) % oPS], edge);
1568 faces[NF + NV + edge].vertices.push_back(j + ind);
1573 edgeBegin = faces.begin() + NF + NV,
1576 it != faces.begin() + NF + NV; ++it)
1578 vector<uint32_t>& f = it->vertices;
1579 if (f.size() == 3)
continue;
1580 for (
size_t i = 1; i < f.size() - 1; i++)
1587 f.erase(f.begin() + i);
1592 it != faces.end(); ++it)
1594 vector<uint32_t>& f =
1596 for (
size_t i = 1; i < 3; i++)
1603 f.erase(f.begin() + i);
1607 return mrpt::make_aligned_shared<CPolyhedron>(vertices, faces);
1613 size_t NF =
mFaces.size();
1614 vector<TPoint3D> vertices(NV + NF);
1618 it !=
mFaces.end(); ++it)
1619 tnf += it->vertices.size();
1620 vector<TPolyhedronFace> faces(tnf);
1629 for (
size_t i = 0; i < NF; i++)
1631 TPoint3D& vertex = vertices[NV + i];
1632 const vector<uint32_t>&
face =
mFaces[i].vertices;
1633 size_t N =
face.size();
1640 for (
size_t j = 0; j < 3; j++)
1643 for (
size_t j = 0; j < 3; j++)
1646 for (
size_t j = 0; j < N; j++)
1650 faces[iF + j] = fTmp;
1660 size_t NF =
mFaces.size();
1664 it !=
mFaces.end(); ++it)
1665 if (it->vertices.size() == numVertices)
1673 vector<TPoint3D> vertices(tnv);
1675 vector<TPolyhedronFace> faces(tnf);
1685 for (
size_t i = 0; i < NF; i++)
1687 const vector<uint32_t>&
face =
mFaces[i].vertices;
1688 size_t N =
face.size();
1689 if (N != numVertices)
1691 faces[iF].vertices =
face;
1696 for (
size_t j = 0; j < numVertices; j++) tmp[j] =
mVertices[
face[j]];
1701 for (
size_t j = 0; j < 3; j++)
1704 for (
size_t j = 0; j < 3; j++)
1707 for (
size_t j = 0; j < N; j++)
1711 faces[iF + j] = fTmp;
1722 size_t NF =
mFaces.size();
1723 vector<TPoint3D> vertices(NV + NF);
1727 it !=
mFaces.end(); ++it)
1728 tnf += it->vertices.size();
1729 vector<TPolyhedronFace> faces(tnf);
1738 for (
size_t i = 0; i < NF; i++)
1740 TPoint3D& vertex = vertices[NV + i];
1741 const vector<uint32_t>&
face =
mFaces[i].vertices;
1742 size_t N =
face.size();
1750 for (
size_t j = 0; j < 3; j++)
1753 for (
size_t j = 0; j < 3; j++)
1756 for (
size_t j = 0; j < N; j++)
1760 faces[iF + j] = fTmp;
1770 size_t NF =
mFaces.size();
1774 it !=
mFaces.end(); ++it)
1775 if (it->vertices.size() == numVertices)
1783 vector<TPoint3D> vertices(tnv);
1785 vector<TPolyhedronFace> faces(tnf);
1795 for (
size_t i = 0; i < NF; i++)
1797 const vector<uint32_t>&
face =
mFaces[i].vertices;
1798 size_t N =
face.size();
1799 if (N != numVertices)
1801 faces[iF].vertices =
face;
1806 for (
size_t j = 0; j < numVertices; j++) tmp[j] =
mVertices[
face[j]];
1812 for (
size_t j = 0; j < 3; j++)
1815 for (
size_t j = 0; j < 3; j++)
1818 for (
size_t j = 0; j < N; j++)
1822 faces[iF + j] = fTmp;
1833 double c = cos(angle),
s = sin(angle);
1839 it->x = A *
c - B *
s;
1840 it->y = B *
c + A *
s;
1849 throw std::logic_error(
"Factor must be a strictly positive number");
1860 uint32_t numBaseEdges,
double baseRadius)
1862 vector<TPoint2D> base(numBaseEdges);
1863 for (
size_t i = 0; i < numBaseEdges; i++)
1865 double ang = 2 *
M_PI * i / numBaseEdges;
1866 base[i].x = baseRadius * cos(ang);
1867 base[i].y = baseRadius * sin(ang);
1873 uint32_t numBaseEdges,
double baseRadius)
1875 vector<TPoint2D> base(numBaseEdges);
1876 double shift =
M_PI / numBaseEdges;
1877 for (
size_t i = 0; i < numBaseEdges; i++)
1879 double ang = shift + 2 *
M_PI * i / numBaseEdges;
1880 base[i].x = baseRadius * cos(ang);
1881 base[i].y = baseRadius * sin(ang);
1888 vector<TPoint3D>& vec)
1890 for (
size_t i = 0; i < numBaseEdges; i++)
1892 double ang = 2 *
M_PI * i / numBaseEdges;
1899 uint32_t numBaseEdges,
double baseRadius,
double height,
double shift,
1900 vector<TPoint3D>& vec)
1902 for (
size_t i = 0; i < numBaseEdges; i++)
1904 double ang = 2 *
M_PI * i / numBaseEdges + shift;
1921 size_t N = doCheck ? f.
vertices.size() : 3;
1925 if (!poly.
getPlane(tmp))
return false;
1929 if (tmp.evaluatePoint(
c) > 0)
1930 for (
size_t i = 0; i < 3; i++) f.
normal[i] = -f.
normal[i];
1954 const vector<TPoint3D>& vertices,
const vector<TPolyhedronFace>& faces)
1956 size_t N = vertices.size();
1957 if (vertices.size() > 0)
1959 it != vertices.end() - 1; ++it)
1961 it2 != vertices.end(); ++it2)
1962 if (*it == *it2)
return false;
1964 it != faces.end(); ++it)
1966 const vector<uint32_t>& e = it->vertices;
1969 if (*it2 >= N)
return false;
1978 it !=
mEdges.end(); ++it)
1979 if (it->v1 == vertex || it->v2 == vertex)
res++;
1987 it !=
mFaces.end(); ++it)
1988 if (
find(it->vertices.begin(), it->vertices.end(), vertex) !=
2004 out << o.
v1 << o.
v2;
2042 throw std::logic_error(
"Inconsistent data read from stream");
2044 it !=
mFaces.end(); ++it)
2047 throw std::logic_error(
"Bad face specification");
2115 it != tetra->mVertices.end(); ++it)
2116 it->z -= radius / 3;
2122 double r = radius / sqrt(3.0);
2135 double ang =
M_PI / 5;
2136 double s2 = 4 *
square(sin(ang));
2137 double prop = sqrt(s2 - 1) + sqrt(s2 - 2 + 2 * cos(ang)) / 2;
2151 ->truncate(2 - sqrt(2.0));
2158 double radius,
bool type)
2162 type ?
"C-PRC+" :
"GC-PRC+", 3);
2167 10, radius,
type ?
"GR-R+" :
"R-R+", 1);
2172 ->truncate(1 - sqrt(0.2));
2177 ->truncate(2.0 / 3.0);
2182 ->cantellate(1.5 * (sqrt(5.0) - 1));
2235 const vector<TPoint2D>& baseVertices,
double height,
double ratio)
2240 const vector<TPoint2D>& baseVertices,
double height)
2262 uint32_t numBaseEdges,
double baseRadius,
double height1,
double height2)
2265 generateBase(numBaseEdges, baseRadius), height1, height2);
2268 uint32_t numBaseEdges,
double baseRadius)
2273 uint32_t numBaseEdges,
double baseRadius)
2278 uint32_t numBaseEdges,
double baseRadius,
double height,
double ratio)
2284 uint32_t numBaseEdges,
double baseRadius,
double height,
double ratio)
2287 numBaseEdges, baseRadius,
height, ratio);
2290 uint32_t numBaseEdges,
double baseRadius,
double height1,
double ratio1,
2291 double height2,
double ratio2)
2294 generateBase(numBaseEdges, baseRadius), height1, ratio1, height2,
2298 uint32_t numBaseEdges,
double edgeLength)
2301 numBaseEdges, edgeLength / (2 * sin(
M_PI / numBaseEdges)),
"C+");
2315 const vector<TPoint3D>& vertices,
const vector<TPolyhedronFace>& faces)
static CPolyhedron::Ptr CreateEmpty()
Creates an empty Polyhedron.
static CPolyhedron::Ptr CreateRhombicuboctahedron(double radius, bool type=true)
Creates a rhombicuboctahedron, with 18 squares and 8 triangles (see http://en.wikipedia.org/wiki/Rhombicuboctahedron), calculated as an elongated square bicupola.
static CPolyhedron::Ptr CreateBifrustum(const std::vector< mrpt::math::TPoint2D > &baseVertices, double height1, double ratio1, double height2, double ratio2)
Creates a bifrustum, or double truncated pyramid, given a base which will lie on the XY plane...
static CPolyhedron::Ptr CreateTrapezohedron(uint32_t numBaseEdges, double baseRadius, double basesDistance)
Creates a trapezohedron, consisting of 2*N kites, where N is the number of edges in the base...
bool mWireframe
This flag determines whether the polyhedron will be displayed as a solid object or as a set of edges...
void insertCupola(size_t numBaseEdges, double angleShift, double baseRadius, double edgeLength, bool isRotated, bool isUpwards, size_t base, vector< TPoint3D > &verts, vector< CPolyhedron::TPolyhedronFace > &faces)
static CPolyhedron::Ptr CreateRhombicTriacontahedron(double radius)
Creates a rhombic triacontahedron, dual to the icosidodecahedron.
static CPolyhedron::Ptr CreateIcosidodecahedron(double radius, bool type=true)
Creates an icosidodecahedron, with 12 pentagons and 20 triangles (see http://en.wikipedia.org/wiki/Icosidodecahedron).
void writeToStreamRender(utils::CStream &out) const
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
void addEdges(const TPolyhedronFace &e)
Adds, to the existing list of edges, each edge in a given face.
bool splitInConvexComponents(const TPolygon2D &poly, std::vector< TPolygon2D > &components)
Splits a 2D polygon into convex components.
mrpt::utils::CStream & operator<<(mrpt::utils::CStream &out, const mrpt::opengl::CLight &o)
size_t facesInVertex(size_t vertex) const
Returns how many faces converge in a given vertex.
size_t edgesInVertex(size_t vertex) const
Returns how many edges converge in a given vertex.
GLAPI void GLAPIENTRY glEnable(GLenum cap)
double getVolume() const
Gets the polyhedron volume.
static std::vector< mrpt::math::TPoint2D > generateShiftedBase(uint32_t numBaseEdges, double baseRadius)
Generates a list of 2D vertices constituting a regular polygon, with an angle shift which makes it su...
#define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)
This must be inserted in all CSerializable classes implementation files.
bool traceRay(const std::vector< TPolygonWithPlane > &vec, const mrpt::poses::CPose3D &pose, double &dist)
Fast ray tracing method using polygons' properties.
void InitFromVertAndFaces(const std::vector< mrpt::math::TPoint3D > &vertices, const std::vector< TPolyhedronFace > &faces, bool doCheck=true)
static CPolyhedron::Ptr CreateCuboctahedron(double radius)
Creates a cuboctahedron, consisting of six square faces and eight triangular ones (see http://en...
void makeConvexPolygons()
Recomputes polygons, if necessary, so that each one is convex.
#define THROW_EXCEPTION(msg)
bool getVerticesAndFaces(const vector< math::TPolygon3D > &polys, vector< TPoint3D > &vertices, vector< CPolyhedron::TPolyhedronFace > &faces)
static CPolyhedron::Ptr CreateTriakisIcosahedron(double radius)
Creates a triakis icosahedron, dual to the truncated dodecahedron.
GLAPI void GLAPIENTRY glNormal3f(GLfloat nx, GLfloat ny, GLfloat nz)
This file implements several operations that operate element-wise on individual or pairs of container...
CPolyhedron::Ptr getDual() const
Given a polyhedron, creates its dual.
EIGEN_STRONG_INLINE iterator begin()
std::shared_ptr< CPolyhedron > Ptr
static CPolyhedron::Ptr CreateCatalanDoublePyramid(uint32_t numBaseEdges, double height)
Creates a double pyramid whose dual is exactly an archimedean prism.
size_t additionalFaces(JohnsonBodyPart j, uint32_t numBaseEdges)
for(ctr=DCTSIZE;ctr > 0;ctr--)
CPolyhedron::Ptr rotate(double angle) const
Rotates a polyhedron around the Z axis a given amount of radians.
Standard object for storing any 3D lightweight object.
EIGEN_STRONG_INLINE void notifyChange() const
Must be called to notify that the object has changed (so, the display list must be updated) ...
static CPolyhedron::Ptr CreateTetrakisHexahedron(double radius)
Creates a tetrakis hexahedron, dual to the truncated octahedron.
static CPolyhedron::Ptr CreateIcosahedron(double radius)
Creates a regular icosahedron (see http://en.wikipedia.org/wiki/Icosahedron).
static CPolyhedron::Ptr CreateRegularPrism(uint32_t numBaseEdges, double baseRadius, double height)
Creates a regular prism whose base is a regular polygon and whose edges are either parallel or perpen...
static CPolyhedron::Ptr CreateArchimedeanRegularAntiprism(uint32_t numBaseEdges, double baseRadius)
Creates a regular antiprism whose lateral polygons are equilateral triangles, and so each face of its...
const Scalar * const_iterator
#define GL_ONE_MINUS_SRC_ALPHA
const_iterator find(const KEY &key) const
GLenum GLenum GLuint components
bool getPlanesIntersection(const vector< const TPlane *> &planes, TPoint3D &pnt)
static CPolyhedron::Ptr CreateCubicPrism(double x1, double x2, double y1, double y2, double z1, double z2)
Creates a cubic prism, given the coordinates of two opposite vertices.
GLsizei GLsizei GLuint * obj
GLAPI void GLAPIENTRY glLineWidth(GLfloat width)
mrpt::poses::CPose3D m_pose
6D pose wrt the parent coordinate reference.
static CPolyhedron::Ptr CreateCupola(uint32_t numBaseEdges, double edgeLength)
Creates a cupola.
This class represents arbitrary polyhedra.
const vector< TPoint3D > & verts
static CPolyhedron::Ptr CreateTriakisTetrahedron(double radius)
Creates a triakis tetrahedron, dual to the truncated tetrahedron.
GLAPI void GLAPIENTRY glBlendFunc(GLenum sfactor, GLenum dfactor)
T square(const T x)
Inline function for the square of a number.
A renderizable object suitable for rendering with OpenGL's display lists.
static CPolyhedron::Ptr CreateJohnsonSolidWithConstantBase(uint32_t numBaseEdges, double baseRadius, const std::string &components, size_t shifts=0)
Creates a series of concatenated solids (most of which are prismatoids) whose base is a regular polyg...
CPolyhedron::Ptr cantellate(double factor) const
Cantellates a polyhedron to a given factor.
bool traceRay(const mrpt::poses::CPose3D &o, double &dist) const override
Ray trace.
static CPolyhedron::Ptr CreateTetrahedron(double radius)
Creates a regular tetrahedron (see http://en.wikipedia.org/wiki/Tetrahedron).
static CPolyhedron::Ptr CreateCatalanTrapezohedron(uint32_t numBaseEdges, double height)
Creates a trapezohedron whose dual is exactly an archimedean antiprism.
uint32_t v2
Second vertex.
static CPolyhedron::Ptr CreateTruncatedPyramid(const std::vector< mrpt::math::TPoint2D > &baseVertices, double height, double ratio)
Creates a truncated pyramid, using a set of vertices which will lie on the XY plane.
static CPolyhedron::Ptr CreateTruncatedDodecahedron(double radius)
Creates a truncated dodecahedron, consisting of 12 dodecagons and 20 triangles (see http://en...
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
std::vector< uint32_t > vertices
Vector of indices to the vertex list.
This base provides a set of functions for maths stuff.
std::vector< mrpt::math::TPolygonWithPlane > tempPolygons
Mutable list of actual polygons, maintained for speed.
static CPolyhedron::Ptr CreateRandomPolyhedron(double radius)
Creates a random polyhedron from the static methods.
static CPolyhedron::Ptr CreateFrustum(const std::vector< mrpt::math::TPoint2D > &baseVertices, double height, double ratio)
This is a synonym for CreateTruncatedPyramid.
static CPolyhedron::Ptr CreateRhombicosidodecahedron(double radius)
Creates a rhombicosidodecahedron, consisting of 30 squares, 12 pentagons and 20 triangles (see http:/...
void insertRotunda(double angleShift, double baseRadius, bool isRotated, bool isUpwards, size_t base, vector< TPoint3D > &verts, vector< CPolyhedron::TPolyhedronFace > &faces)
FCreatePolygonFromFace(const vector< TPoint3D > &v)
static CPolyhedron::Ptr CreatePentagonalRotunda(double radius)
Creates a pentagonal rotunda (half an icosidodecahedron), consisting of six pentagons, ten triangles and a decagon (see http://en.wikipedia.org/wiki/Pentagonal_rotunda).
Struct used to store a polyhedron face.
void getSetOfPolygons(std::vector< math::TPolygon3D > &vec) const
Gets the polyhedron as a set of polygons.
static CPolyhedron::Ptr CreateTruncatedOctahedron(double radius)
Creates a truncated octahedron, with eight hexagons and eight squares (see http://en.wikipedia.org/wiki/Truncated_octahedron).
void readFromStream(mrpt::utils::CStream &in, int version) override
Introduces a pure virtual method responsible for loading from a CStream This can not be used directly...
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
static CPolyhedron::Ptr CreatePyramid(const std::vector< mrpt::math::TPoint2D > &baseVertices, double height)
Creates a custom pyramid, using a set of 2D vertices which will lie on the XY plane.
static CPolyhedron::Ptr CreateRegularPyramid(uint32_t numBaseEdges, double baseRadius, double height)
Creates a regular pyramid whose base is a regular polygon.
double normal[3]
Normal vector.
void unitarize()
Unitarize normal vector.
void readFromStreamRender(mrpt::utils::CStream &in)
CPolyhedron()
Basic empty constructor.
Struct used to store a polyhedron edge.
bool searchForEdge(const vector< CPolyhedron::TPolyhedronEdge > &es, uint32_t v1, uint32_t v2, size_t &where)
GLfloat GLfloat GLfloat GLfloat v3
3D Plane, represented by its equation
static CPolyhedron::Ptr CreateTriakisOctahedron(double radius)
Creates a triakis octahedron, dual to the truncated hexahedron.
static CPolyhedron::Ptr CreateOctahedron(double radius)
Creates a regular octahedron (see http://en.wikipedia.org/wiki/Octahedron).
bool getPlane(TPlane &p) const
Gets a plane which contains the polygon.
mrpt::utils::TColor m_color
Color components in the range [0,255].
static std::vector< mrpt::math::TPoint2D > generateBase(uint32_t numBaseEdges, double baseRadius)
Generates a list of 2D vertices constituting a regular polygon.
double x
X,Y,Z coordinates.
GLAPI void GLAPIENTRY glBegin(GLenum mode)
GLsizei const GLchar ** string
static CPolyhedron::Ptr CreateParallelepiped(const mrpt::math::TPoint3D &base, const mrpt::math::TPoint3D &v1, const mrpt::math::TPoint3D &v2, const mrpt::math::TPoint3D &v3)
Creates a parallelepiped, given a base point and three vectors represented as points.
std::vector< TPolyhedronEdge > mEdges
List of polyhedron's edges.
std::vector< mrpt::math::TPoint3D > mVertices
List of vertices presents in the polyhedron.
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...
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
GLAPI void GLAPIENTRY glVertex3f(GLfloat x, GLfloat y, GLfloat z)
CPolyhedron::Ptr scale(double factor) const
Scales a polyhedron to a given factor.
GLAPI void GLAPIENTRY glColor4ub(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha)
size_t additionalVertices(JohnsonBodyPart j, uint32_t numBaseEdges)
static CPolyhedron::Ptr CreateCustomAntiprism(const std::vector< mrpt::math::TPoint2D > &bottomBase, const std::vector< mrpt::math::TPoint2D > &topBase, double height)
Creates a custom antiprism, using two custom bases.
static CPolyhedron::Ptr CreateTruncatedTetrahedron(double radius)
Creates a truncated tetrahedron, consisting of four triangular faces and for hexagonal ones (see http...
mrpt::utils::CStream & operator>>(mrpt::utils::CStream &in, mrpt::opengl::CLight &o)
static CPolyhedron::Ptr CreateRegularAntiprism(uint32_t numBaseEdges, double baseRadius, double height)
Creates an antiprism whose base is a regular polygon.
static void checkOpenGLError()
Checks glGetError and throws an exception if an error situation is found.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
bool polygonsUpToDate
Whether the set of actual polygons is up to date or not.
bool setNormal(TPolyhedronFace &f, bool doCheck=true)
Calculates the normal vector to a face.
bool analyzeJohnsonPartsString(const std::string &components, uint32_t numBaseEdges, vector< JohnsonBodyPart > &parts)
GLdouble GLdouble GLdouble r
void updatePolygons() const
Updates the mutable list of polygons used in rendering and ray tracing.
static CPolyhedron::Ptr CreateRhombicDodecahedron(double radius)
Creates a rhombic dodecahedron, dual to the cuboctahedron.
static CPolyhedron::Ptr CreateRegularDoublePyramid(uint32_t numBaseEdges, double baseRadius, double height1, double height2)
Creates a regular double pyramid whose base is a regular polygon.
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
double & operator[](size_t i)
static CPolyhedron::Ptr CreateRegularBifrustum(uint32_t numBaseEdges, double baseRadius, double height1, double ratio1, double height2, double ratio2)
Creates a bifrustum (double truncated pyramid) whose base is a regular polygon lying in the XY plane...
void writeToStream(mrpt::utils::CStream &out, int *getVersion) const override
Introduces a pure virtual method responsible for writing to a CStream.
static CPolyhedron::Ptr CreateNoCheck(const std::vector< mrpt::math::TPoint3D > &vertices, const std::vector< TPolyhedronFace > &faces)
Creates a polyhedron without checking its correctness.
double coefs[4]
Plane coefficients, stored as an array: .
void composePoint(double lx, double ly, double lz, double &gx, double &gy, double &gz, mrpt::math::CMatrixFixedNumeric< double, 3, 3 > *out_jacobian_df_dpoint=nullptr, mrpt::math::CMatrixFixedNumeric< double, 3, 6 > *out_jacobian_df_dpose=nullptr, mrpt::math::CMatrixFixedNumeric< double, 3, 6 > *out_jacobian_df_dse3=nullptr, bool use_small_rot_approx=false) const
An alternative, slightly more efficient way of doing with G and L being 3D points and P this 6D pose...
static CPolyhedron::Ptr CreateTruncatedIcosahedron(double radius)
Creates a truncated icosahedron, consisting of 20 hexagons and 12 pentagons.
GLuint GLsizei GLsizei * length
static CPolyhedron::Ptr CreateDodecahedron(double radius)
Creates a regular dodecahedron (see http://en.wikipedia.org/wiki/Dodecahedron).
The namespace for 3D scene representation and rendering.
static CPolyhedron::Ptr CreateRegularTruncatedPyramid(uint32_t numBaseEdges, double baseRadius, double height, double ratio)
Creates a regular truncated pyramid whose base is a regular polygon.
double evaluatePoint(const TPoint3D &point) const
Evaluate a point in the plane's equation.
GLAPI void GLAPIENTRY glEnd(void)
CPolyhedron::Ptr truncate(double factor) const
Truncates a polyhedron to a given factor.
static CPolyhedron::Ptr CreateArchimedeanRegularPrism(uint32_t numBaseEdges, double baseRadius)
Creates a regular prism whose lateral area is comprised of squares, and so each face of its is a regu...
static CPolyhedron::Ptr CreateDeltoidalHexecontahedron(double radius)
Creates a deltoidal hexecontahedron, dual to the rhombicosidodecahedron.
static CPolyhedron::Ptr CreateHexahedron(double radius)
Creates a regular cube, also called hexahedron (see http://en.wikipedia.org/wiki/Hexahedron).
void getEdgesLength(std::vector< double > &lengths) const
Gets a vector with each edge's length.
static CPolyhedron::Ptr CreateRegularFrustum(uint32_t numBaseEdges, double baseRadius, double height, double ratio)
This is a synonym for CreateRegularTruncatedPyramid.
static bool checkConsistence(const std::vector< mrpt::math::TPoint3D > &vertices, const std::vector< TPolyhedronFace > &faces)
Checks whether a set of faces is suitable for a set of vertices.
double mLineWidth
When displaying as wireframe object, this variable stores the width of the edges. ...
T operator()(const CPolyhedron::TPolyhedronFace &f)
void render_dl() const override
Render.
GLfloat GLfloat GLfloat v2
double operator[](size_t i) const
void getCenter(mrpt::math::TPoint3D ¢er) const
Gets the center of the polyhedron.
std::vector< TPolyhedronFace > mFaces
List of polyhedron's faces.
void getFacesArea(std::vector< double > &areas) const
Gets a vector with each face's area.
GLuint GLenum GLenum transform
void getBestFittingPlane(TPlane &p) const
Gets the best fitting plane, disregarding whether the polygon actually fits inside or not...
double getHeight(const TPolygon3D &p, const TPoint3D &c)
GLenum GLsizei GLsizei height
double getEpsilon()
Gets the value of the geometric epsilon (default = 1e-5)
unsigned __int32 uint32_t
CRandomGenerator & getRandomGenerator()
A static instance of a CRandomGenerator class, for use in single-thread applications.
GLAPI void GLAPIENTRY glDisable(GLenum cap)
static CPolyhedron::Ptr CreatePentakisDodecahedron(double radius)
Creates a pentakis dodecahedron, dual to the truncated icosahedron.
GLubyte GLubyte GLubyte a
bool searchForFace(const vector< CPolyhedron::TPolyhedronFace > &fs, uint32_t v1, uint32_t v2, uint32_t v3)
bool intersect(const TSegment3D &s1, const TSegment3D &s2, TObject3D &obj)
Gets the intersection between two 3D segments.
static CPolyhedron::Ptr CreateDeltoidalIcositetrahedron(double radius)
Creates a deltoidal icositetrahedron, dual to the rhombicuboctahedron.
static CPolyhedron::Ptr CreateCustomPrism(const std::vector< mrpt::math::TPoint2D > &baseVertices, double height)
Creates a custom prism with vertical edges, given any base which will lie on the XY plane...
GLuint GLuint GLsizei GLenum type
3D polygon, inheriting from std::vector<TPoint3D>
double distance(const TPoint2D &p1, const TPoint2D &p2)
Gets the distance between two points in a 2D space.
void getCenter(TPoint3D &p) const
Get polygon's central point.
static CPolyhedron::Ptr CreateDoublePyramid(const std::vector< mrpt::math::TPoint2D > &baseVertices, double height1, double height2)
Creates a double pyramid, using a set of 2D vertices which will lie on the XY plane.
GLenum GLuint GLint GLenum face
CPolyhedron::Ptr augment(double height) const
Augments a polyhedron to a given height.
bool faceContainsEdge(const CPolyhedron::TPolyhedronFace &f, const CPolyhedron::TPolyhedronEdge &e)
static CPolyhedron::Ptr CreateTruncatedHexahedron(double radius)
Creates a truncated hexahedron, with six octogonal faces and eight triangular ones (see http://en...
void getSetOfPolygonsAbsolute(std::vector< math::TPolygon3D > &vec) const
Gets the polyhedron as a set of polygons, with the pose transformation already applied.
void getNormalVector(double(&vec)[3]) const
Get plane's normal vector.
3D line, represented by a base point and a director vector.