DART 6.12.2
Loading...
Searching...
No Matches
Icosphere.hpp
Go to the documentation of this file.
1/*
2 * Copyright (c) 2011-2021, The DART development contributors
3 * All rights reserved.
4 *
5 * The list of contributors can be found at:
6 * https://github.com/dartsim/dart/blob/master/LICENSE
7 *
8 * This file is provided under the following "BSD-style" License:
9 * Redistribution and use in source and binary forms, with or
10 * without modification, are permitted provided that the following
11 * conditions are met:
12 * * Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * * Redistributions in binary form must reproduce the above
15 * copyright notice, this list of conditions and the following
16 * disclaimer in the documentation and/or other materials provided
17 * with the distribution.
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
19 * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
20 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
26 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
27 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
29 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
31 */
32
33#ifndef DART_MATH_ICOSPHERE_HPP_
34#define DART_MATH_ICOSPHERE_HPP_
35
36#include <map>
37#include <vector>
38
39#include <Eigen/Core>
40
41#include "dart/math/TriMesh.hpp"
42
43namespace dart {
44namespace math {
45
48template <typename S_>
49class Icosphere : public TriMesh<S_>
50{
51public:
52 // Type aliases
53 using S = S_;
55 using Index = typename Base::Index;
56 using Vector3 = typename Base::Vector3;
57 using Triangle = typename Base::Triangle;
58 using Vertices = std::vector<Vector3>;
59 using Normals = typename Base::Normals;
60 using Triangles = std::vector<Triangle>;
61
63 static std::size_t getNumVertices(std::size_t subdivisions);
64
66 static std::size_t getNumEdges(std::size_t subdivisions);
67
69 static std::size_t getNumTriangles(std::size_t subdivisions);
70
72 static std::pair<Vertices, Triangles> computeIcosahedron(S radius);
73
79 Icosphere(S radius, std::size_t subdivisions);
80
82 S getRadius() const;
83
85 std::size_t getNumSubdivisions() const;
86
87private:
89 void build();
90
93
95 std::size_t mSubdivisions;
96};
97
100
101} // namespace math
102} // namespace dart
103
105
106#endif // DART_MATH_ICOSPHERE_HPP_
The class Icosphere represents an icosphere where the subdivision and radius are configurable.
Definition Icosphere.hpp:50
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::Index Index
Definition Icosphere.hpp:55
typename Base::Normals Normals
Definition Icosphere.hpp:59
S mRadius
Radius of icosphere.
Definition Icosphere.hpp:92
typename Base::Triangle Triangle
Definition Icosphere.hpp:57
std::size_t mSubdivisions
Number of subdividing an icosahedron.
Definition Icosphere.hpp:95
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
std::vector< Vector3 > Vertices
Definition Icosphere.hpp:58
This class represents triangle meshes.
Definition TriMesh.hpp:46
typename Base::Index Index
Definition TriMesh.hpp:51
typename Base::Normals Normals
Definition TriMesh.hpp:55
typename Base::Vector3 Vector3
Definition TriMesh.hpp:52
Eigen::Matrix< Index, 3, 1 > Triangle
Definition TriMesh.hpp:53
Definition BulletCollisionDetector.cpp:60