Hard Faced Geodesic Sphere

219 Views Asked by At

This is an image of the type of geometry I'm looking to create.

enter image description here

I'm wanting to create an algorithm for a geodesic sphere like this. My thing is I need the faces of the hexagons & pentagons to be flat not spherical in nature like most algorithms I find. It would also be nice if the algorithm could find the next step so I can move up 'tesselations' for lack of a better word. Essentially have smaller hexagons & pentagons that approximate it.

Found a few ways to make some of the lower tesselations, but even on that would make one like the attached picture would be enough for my task. The faces need to be hard though for my project.

1

There are 1 best solutions below

0
On

Here is a script to generate a regular icosahedron.

And then you can subdivide each triangle with this algorithm (C# with Vector3 struct):

Vector3[] icoTriangleCorners = new Vector3[3];

public void Subdivide(HashSet<Vector3[]> faces, int subdivision, double radius) {

    Vector3 x = (icoTriangleCorners[1] - icoTriangleCorners[0]) / (subdivision + 1);
    Vector3 y = (icoTriangleCorners[2] - icoTriangleCorners[1]) / (subdivision + 1);

    for(int i = 0; i <= subdivision; ++i) {
        for(int j = 0; j <= i; ++j) {
            Vector3 a = (icoTriangleCorners[0] + i * x + j * y).normalized * radius;
            Vector3 b = (icoTriangleCorners[0] + (i + 1) * x + j * y).normalized * radius;
            Vector3 c = (icoTriangleCorners[0] + (i + 1) * x + (j + 1) * y).normalized * radius;

            faces.Add(new Vector3[] {a, b, c});

            if (i == j) continue;

            Vector3 d = (icoTriangleCorners[0] + i * x + (j + 1) * y).normalized * radius;

            faces.Add(new Vector3[] {c, d, a});
        }
    }
}

It generates the new triangle faces with vertices in the same clockwise order. The vertices of the geodesic sphere are the centroids of the triangles. The centers of the pentagons and hexagons are the corners of the triangles.

You can improve the algorythm by creating a new class for the corners and checking if the Vector3 of the corner has already been created. You can then collect the triangles joining a corner in the corner object. This approach makes the generation of the final faces easier.