# Grid layout on a sphere

Hi,

Has anyone ever tried to layout a grid of objects onto a sphere in code?

For example, I would like to instantiate a grid of hexagon prefabs (or whatever polygon shape could wrap a sphere) around a sphere at runtime. Is there a formula that could do that with 3D objects (ie: find each prefab’s position and rotation around the sphere)?

-JJ

Mapping identical shapes onto a sphere only works with a few shapes: triangles (4 sides, 8 sides and 20 sides), squares (6 sides), pentagons (12 sides).

If you’re a bit more relaxed and allow the sphere to be less than perfectly symmetrical the job becomes a bit easier. You can combine pentagons and hexagons as shown on many soccer balls. Or you can use triangles in less than perfect symmetry.

I’m guessing you want more than 20 sides in which case there is NO perfect solution. This is the real problem, since there are no mathematical perfect solution there are thousands of methods each as good as the next. One of the best is making that perfect 20 sided triangle based sphere (icosahedron) and then subdividing each of those 20 sides into more triangles. You’ll need to recalculate the subdivision vertexes and scale them correctly from Center to make it look like a sphere.

You can use this method to make a sphere out of Hexagons with 20? or so Pentagons (where the 20 original triangles meet.) as long as you Subdivide an even number of times, with an uneven number of splits the hexagons wont cover the surface properly as shown on the attachment

Cheers,
UnLogick

Thanks UnLogic. I don’t mind if it’s actually only 20 objects or so, I’m okay with anything in the 20-40 range. These would basically be grid tiles that could be selected when clicked on. They would only appear during the selection mode, otherwise their renderers would be disabled and all you would see is the regular sphere.

So, let’s say I went with the 20 triangles, how would I position and rotate them correctly around my sphere in code when they are being instantiate from a flat triangle prefab?

-JJ