34 std::vector<typename TriangleSet<T>::Triangle> triangles;
36 static const T eps = std::numeric_limits<T>::epsilon();
38 PLB_ASSERT(radius > (
T) 0.0 && !util::fpequal(radius, (
T) 0.0, eps) &&
39 minNumOfTriangles >= 8);
43 T tau = -0.8506508084;
44 T one = -0.5257311121;
47 plb::Array<T,3> v1( tau, one, 0);
48 plb::Array<T,3> v2(-tau, one, 0);
49 plb::Array<T,3> v3(-tau, -one, 0);
50 plb::Array<T,3> v4( tau, -one, 0);
51 plb::Array<T,3> v5( one, 0 , tau);
52 plb::Array<T,3> v6( one, 0 , -tau);
53 plb::Array<T,3> v7(-one, 0 , -tau);
54 plb::Array<T,3> v8(-one, 0 , tau);
55 plb::Array<T,3> v9( 0 , tau, one);
56 plb::Array<T,3> v10( 0 , -tau, one);
57 plb::Array<T,3> v11( 0 , -tau, -one);
58 plb::Array<T,3> v12( 0 , tau, -one);
61 typename TriangleSet<T>::Triangle tmp;
63 tmp[0] = v5; tmp[1] = v8; tmp[2] = v9;
64 triangles.push_back(tmp);
65 tmp[0] = v5; tmp[1] = v10; tmp[2] = v8;
66 triangles.push_back(tmp);
67 tmp[0] = v6; tmp[1] = v12; tmp[2] = v7;
68 triangles.push_back(tmp);
69 tmp[0] = v6; tmp[1] = v7; tmp[2] = v11;
70 triangles.push_back(tmp);
71 tmp[0] = v1; tmp[1] = v4; tmp[2] = v5;
72 triangles.push_back(tmp);
73 tmp[0] = v1; tmp[1] = v6; tmp[2] = v4;
74 triangles.push_back(tmp);
75 tmp[0] = v3; tmp[1] = v2; tmp[2] = v8;
76 triangles.push_back(tmp);
77 tmp[0] = v3; tmp[1] = v7; tmp[2] = v2;
78 triangles.push_back(tmp);
79 tmp[0] = v9; tmp[1] = v12; tmp[2] = v1;
80 triangles.push_back(tmp);
81 tmp[0] = v9; tmp[1] = v2; tmp[2] = v12;
82 triangles.push_back(tmp);
83 tmp[0] = v10; tmp[1] = v4; tmp[2] = v11;
84 triangles.push_back(tmp);
85 tmp[0] = v10; tmp[1] = v11; tmp[2] = v3;
86 triangles.push_back(tmp);
87 tmp[0] = v9; tmp[1] = v1; tmp[2] = v5;
88 triangles.push_back(tmp);
89 tmp[0] = v12; tmp[1] = v6; tmp[2] = v1;
90 triangles.push_back(tmp);
91 tmp[0] = v5; tmp[1] = v4; tmp[2] = v10;
92 triangles.push_back(tmp);
93 tmp[0] = v6; tmp[1] = v11; tmp[2] = v4;
94 triangles.push_back(tmp);
95 tmp[0] = v8; tmp[1] = v2; tmp[2] = v9;
96 triangles.push_back(tmp);
97 tmp[0] = v7; tmp[1] = v12; tmp[2] = v2;
98 triangles.push_back(tmp);
99 tmp[0] = v8; tmp[1] = v10; tmp[2] = v3;
100 triangles.push_back(tmp);
101 tmp[0] = v7; tmp[1] = v3; tmp[2] = v11;
102 triangles.push_back(tmp);
107 plb::Array<T,3> va,vb,vc,vd,ve,vf;
108 while ((size = triangles.size()) < minNumOfTriangles) {
109 for (
plint i = 0; i < size; i++) {
110 va = triangles[i][0];
111 vb = triangles[i][1];
112 vc = triangles[i][2];
114 vd = (
T) 0.5 * (va + vb);
115 ve = (
T) 0.5 * (vb + vc);
116 vf = (
T) 0.5 * (vc + va);
122 triangles[i][0] = vd;
123 triangles[i][1] = ve;
124 triangles[i][2] = vf;
129 triangles.push_back(tmp);
134 triangles.push_back(tmp);
139 triangles.push_back(tmp);
145 TriangleSet<T> triangleSet(triangles);
147 triangleSet.scale(radius);
148 triangleSet.translate(center);
246 plb::Array<T,3>
const& eulerAngles,
pluint initialSphereShape)
248 TriangleSet<T> sphere;
249 if (initialSphereShape == 1) {
250 sphere = constructSphereIcosahedron<T>(plb::Array<T,3>(0,0,0), 1.0, minNumOfTriangles);
251 }
else if (initialSphereShape == 0) {
252 sphere = constructSphere<T>(plb::Array<T,3>(0,0,0), 1.0, minNumOfTriangles);
255 PI/2.0 + eulerAngles[0],
256 PI/2.0 + eulerAngles[1],
257 0. + eulerAngles[2]);
258 std::vector<typename TriangleSet<T>::Triangle> ellipsoidTriangles = sphere.getTriangles();
259 for (
pluint var = 0; var < ellipsoidTriangles.size(); ++var) {
264 TriangleSet<T> ellipsoid(ellipsoidTriangles);
266 PI/2.0 + eulerAngles[0],
267 PI/2.0 + eulerAngles[1],
268 0. + eulerAngles[2]);
269 ellipsoid.translate(center);