public void AddRegularIcosahedron(Point3D center, double radius, bool shareVertices)
{
double a = Math.Sqrt(2.0 / (5.0 + Math.Sqrt(5.0)));
double b = Math.Sqrt(2.0 / (5.0 - Math.Sqrt(5.0)));
var icosahedronIndices = new[]
{
1, 4, 0, 4, 9, 0, 4, 5, 9, 8, 5, 4, 1, 8, 4, 1, 10, 8, 10, 3, 8, 8, 3, 5, 3, 2, 5, 3, 7, 2, 3, 10, 7,
10, 6, 7, 6, 11, 7, 6, 0, 11, 6, 1, 0, 10, 1, 6, 11, 0, 9, 2, 11, 9, 5, 2, 9, 11, 2, 7
};
var icosahedronVertices = new[]
{
new Vector3D(-a, 0, b), new Vector3D(a, 0, b), new Vector3D(-a, 0, -b), new Vector3D(a, 0, -b),
new Vector3D(0, b, a), new Vector3D(0, b, -a), new Vector3D(0, -b, a), new Vector3D(0, -b, -a),
new Vector3D(b, a, 0), new Vector3D(-b, a, 0), new Vector3D(b, -a, 0), new Vector3D(-b, -a, 0)
};
if (shareVertices)
{
int index0 = this.positions.Count;
foreach (var v in icosahedronVertices)
{
this.positions.Add(center + (v * radius));
}
foreach (int i in icosahedronIndices)
{
this.triangleIndices.Add(index0 + i);
}
}
else
{
for (int i = 0; i + 2 < icosahedronIndices.Length; i += 3)
{
this.AddTriangle(
center + (icosahedronVertices[icosahedronIndices[i]] * radius),
center + (icosahedronVertices[icosahedronIndices[i + 1]] * radius),
center + (icosahedronVertices[icosahedronIndices[i + 2]] * radius));
}
}
}