Eindhoven, 21 October 2009. A short while ago I came across some pictures of a globe, made out of LEGO! I quickly searched on Google for more structures like this, and was a bit disappointed that there where not much others. I decided to try to write a script to generate a sphere made out of LEGO bricks. After a (very long) evening of scripting in PHP, it did work. A sphere made of LEGO, in any radius you want!
The idea behind it is quite simple: look at a sphere as if it consists of layers, i.e. cylinders with a different radius. If you stack these cylinders, you will end up with a sphere. One has to consider some things, e.g. the ratio of the LEGO bricks (6 bricks next to each other is more or less equal to 5 bricks on top of each other).
The other day I saw another globe made of LEGO, but with an entirely different approach: the general idea was a cube, so six identical faces, with on each face a part of a globe made of LEGO plates. Looks very nice, and it certainly approaches the spherical shape better, or maybe just quicker in the sense of the radius, than the one made of bricks. The only disadvantage is you need quite some plates.
Because the sphere had been an easy project, I wanted to give the globe a try. Little did I know...
The first problem was to invent which brick should represent which part of the world. Thanks to Kohsuke Kawaguchi, who did something similar some ago, I was able to continue.
This main idea is as follows: there is a LEGO sphere, and within this sphere is a bright light, exactly in the center of it. Around the LEGO sphere is another sphere, for example a hollow earth (so, just a shell). Imagine the LEGO sphere entirely transparent, except for one brick (at a random position). Now, the light within this LEGO sphere will cast the shadow of this one brick on the outer sphere, the earth. If this earth is (semi-) transparent, you can see from the outside which part of land or sea is covered by this shadow. Repeat this for every brick in the LEGO sphere, and the globe will be entirely covered in shadow (wow, that sounds dark).
The next question was, "how do I actually calculate this shadow"? One has to realize that the transparent LEGO sphere and shell-earth aren't tangible; they are just visualizations inside your head. The key to creating the shadows is to determine which faces of the bricks are exposed to the outer world. This can be just one face (bottom, top, or side), two faces (two side faces, one top and one side, one bottom and one side) and three faces (one top/bottom and two side faces). There are no other possibilities.
The shadow of the first category is the easiest: it will be a quadrangle. The other categories will both produce a hexagonal (but if there would be a layer ("cylinder") exactly halfway the sphere, the second category could also result in a quadrangle).
To calculate the angular points of the shadows, one has to calculate the angles Phi (φ) and Theta (θ) - spherical coordinates. This is useful because one can equate them with the longitude (-180° to 180°) and latitude (-90° to 90°).
Next step, the decision which type of map to work with. I found out there exist a ridiculous amount of ways how to project a sphere on a map! I chose the simplest, the plate carrée. This one is twice as long as it is high.
Ok, by now the points of the shadows could be projected on the 2D map. But how to make a polygon out of them? This was another task. I do not know how to explain this concise and clear, for which I apologize. Just assume there are polygons already all over the 2D map.
The last to do, is average the color of the area within each polygon. Because you mostly deal with RGB colors, you have to take the mean values of the R, G and B values separately. Unfortunately, there is one drawback on this method: when there are many colors within the polygon, the mean value can be a color that isn't even present in that area. This is the reason why some oddly colored bricks are present in the pictures below.
Of course there where many other problems: how to output a file that MLCAD can read, figuring out the .LDR filetype, check the code why the continents are mirrored and other, often very weird, bugs.
That's it for now. I used the great application MLCAD to open the models and view them. Have fun, and if you have any questions please feel free to send me an e-mail: