public GeodesicGrid(IIcosahedralGridOptions options) { var icosahedralGrid = new IcosahedralGrid(options); var icosahedralFaces = icosahedralGrid.Faces; var icosahedralEdges = icosahedralFaces.SelectMany(face => face.Edges).Distinct().ToList(); var icosahedralVertices = icosahedralFaces.SelectMany(face => face.Vertices).Distinct().ToList(); var icosahedralFaceToGeodesicVertexMap = CreateGeodesicVertices(icosahedralFaces); var icosahedralEdgeToGeodesicEdgeMap = CreateGeodesicEdges(icosahedralEdges, icosahedralFaceToGeodesicVertexMap); var icosahedralVertexToGeodesicFaceMap = CreateGeodesicFaces(icosahedralVertices, icosahedralEdgeToGeodesicEdgeMap); Faces = icosahedralVertexToGeodesicFaceMap.Values.ToList(); }
// The process is this: create a basic 20-face icosahedron, and break all its edges in two, introducing new // vertices at each break. Then make a pass over each face, subdividing it into four new lil' triangles. public IcosahedralGrid(IIcosahedralGridOptions options) { var targetAngularResolution = options.Resolution / options.Radius; // Create our basic icosahedron CreateIcosahedron(); var currentAngularResolution = 1 / Mathf.Sin(2 * Mathf.PI / 5); while (currentAngularResolution > targetAngularResolution) { // Break all the edges in two and create midpoints between each new pair. var edgeSubdivision = new EdgeSubdivision(Edges, Vertices); Edges = edgeSubdivision.Edges; Vertices = edgeSubdivision.Vertices; // Break all the faces into four, generating some new edges in the process as well. var faceSubdivision = new FaceSubdivision(Faces, Edges, Vertices); Faces = faceSubdivision.Faces; Edges = faceSubdivision.Edges; Vertices = faceSubdivision.Vertices; currentAngularResolution /= 2; } }