72 const S unitX = 1 / std::sqrt(1 + phi * phi);
75 const S x = radius *
unitX;
76 const S z = radius *
unitZ;
78 std::vector<Vector3>
vertices = {{{-x, 0, z},
92 = {{{0, 4, 1}, {0, 9, 4}, {9, 5, 4}, {4, 5, 8}, {4, 8, 1},
93 {8, 10, 1}, {8, 3, 10}, {5, 3, 8}, {5, 2, 3}, {2, 7, 3},
94 {7, 10, 3}, {7, 6, 10}, {7, 11, 6}, {11, 0, 6}, {0, 1, 6},
95 {6, 1, 10}, {9, 0, 11}, {9, 11, 2}, {9, 2, 5}, {7, 2, 11}}};
106 std::is_floating_point<S>::value,
107 "Scalar must be a floating point type.");
124 return mSubdivisions;
134 std::tie(this->mVertices, this->mTriangles) = computeIcosahedron(mRadius);
137 if (mSubdivisions == 0)
141 using IndexMap = std::map<std::pair<std::size_t, std::size_t>, std::size_t>;
146 if (mSubdivisions % 2)
148 this->mTriangles.reserve(getNumTriangles(mSubdivisions - 1));
149 tmpFaces.reserve(getNumTriangles(mSubdivisions));
153 this->mTriangles.reserve(getNumTriangles(mSubdivisions));
154 tmpFaces.reserve(getNumTriangles(mSubdivisions - 1));
158 std::vector<Triangle>*
currFaces = &(this->mTriangles);
160 std::array<std::size_t, 3>
mid;
164 for (std::size_t
i = 0;
i < mSubdivisions; ++
i)
174 for (std::size_t
j = 0;
j < (*currFaces).size(); ++
j)
176 const auto&
outter = (*currFaces)[
j];
179 for (std::size_t
k = 0;
k < 3; ++
k)
197 const auto&
v1 = this->mVertices[
indexA];
198 const auto&
v2 = this->mVertices[
indexB];
CollisionResult * result
Collision result of DART.
Definition FCLCollisionDetector.cpp:160
S_ S
Definition Icosphere.hpp:53
std::size_t getNumSubdivisions() const
Returns the number of subdivisions of the icosphere.
Definition Icosphere-impl.hpp:122
typename Base::Vector3 Vector3
Definition Icosphere.hpp:56
static std::size_t getNumVertices(std::size_t subdivisions)
Returns the number of vertices of icosphere given subdivisions.
Definition Icosphere-impl.hpp:44
static std::size_t getNumEdges(std::size_t subdivisions)
Returns the number of edges of icosphere given subdivisions.
Definition Icosphere-impl.hpp:54
std::vector< Triangle > Triangles
Definition Icosphere.hpp:60
S getRadius() const
Returns the radius of the icosphere.
Definition Icosphere-impl.hpp:115
static std::pair< Vertices, Triangles > computeIcosahedron(S radius)
Returns vertices and faces of icosahedron given radius.
Definition Icosphere-impl.hpp:69
typename Base::Triangle Triangle
Definition Icosphere.hpp:57
Icosphere(S radius, std::size_t subdivisions)
Construct an icosphere given radius and subdivisions.
Definition Icosphere-impl.hpp:102
void build()
Internal function to build icosphere given radius and subdivisions.
Definition Icosphere-impl.hpp:129
static std::size_t getNumTriangles(std::size_t subdivisions)
Returns the number of triangles of icosphere given subdivisions.
Definition Icosphere-impl.hpp:61
Definition BulletCollisionDetector.cpp:65
static constexpr T phi()
The golden ratio.
Definition Constants.hpp:63