71 const S unitX = 1 / std::sqrt(1 + phi * phi);
74 const S x = radius *
unitX;
75 const S z = radius *
unitZ;
77 std::vector<Vector3>
vertices = {{-x, 0, z},
91 = {{0, 4, 1}, {0, 9, 4}, {9, 5, 4}, {4, 5, 8}, {4, 8, 1},
92 {8, 10, 1}, {8, 3, 10}, {5, 3, 8}, {5, 2, 3}, {2, 7, 3},
93 {7, 10, 3}, {7, 6, 10}, {7, 11, 6}, {11, 0, 6}, {0, 1, 6},
94 {6, 1, 10}, {9, 0, 11}, {9, 11, 2}, {9, 2, 5}, {7, 2, 11}};
105 std::is_floating_point<S>::value,
106 "Scalar must be a floating point type.");
123 return mSubdivisions;
133 std::tie(this->mVertices, this->mTriangles) = computeIcosahedron(mRadius);
136 if (mSubdivisions == 0)
140 using IndexMap = std::map<std::pair<std::size_t, std::size_t>, std::size_t>;
145 if (mSubdivisions % 2)
147 this->mTriangles.reserve(getNumTriangles(mSubdivisions - 1));
148 tmpFaces.reserve(getNumTriangles(mSubdivisions));
152 this->mTriangles.reserve(getNumTriangles(mSubdivisions));
153 tmpFaces.reserve(getNumTriangles(mSubdivisions - 1));
157 std::vector<Triangle>*
currFaces = &(this->mTriangles);
159 std::array<std::size_t, 3>
mid;
163 for (std::size_t
i = 0;
i < mSubdivisions; ++
i)
173 for (std::size_t
j = 0;
j < (*currFaces).size(); ++
j)
175 const auto&
outter = (*currFaces)[
j];
178 for (std::size_t
k = 0;
k < 3; ++
k)
196 const auto&
v1 = this->mVertices[
indexA];
197 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:121
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:43
static std::size_t getNumEdges(std::size_t subdivisions)
Returns the number of edges of icosphere given subdivisions.
Definition Icosphere-impl.hpp:53
std::vector< Triangle > Triangles
Definition Icosphere.hpp:60
S getRadius() const
Returns the radius of the icosphere.
Definition Icosphere-impl.hpp:114
static std::pair< Vertices, Triangles > computeIcosahedron(S radius)
Returns vertices and faces of icosahedron given radius.
Definition Icosphere-impl.hpp:68
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:101
void build()
Internal function to build icosphere given radius and subdivisions.
Definition Icosphere-impl.hpp:128
static std::size_t getNumTriangles(std::size_t subdivisions)
Returns the number of triangles of icosphere given subdivisions.
Definition Icosphere-impl.hpp:60
Definition BulletCollisionDetector.cpp:60
static constexpr T phi()
The golden ratio.
Definition Constants.hpp:62