# Geodesic Math in OpenScad – Part 2 (of some)

**Posted:**September 4, 2011

**Filed under:**3D Modeling, OpenScad Tutorial 1 Comment

Last time around, I introduced the very simplest concepts related to geodesic math, namely the spherical coordinates. Now, let’s go one step further and utilize these spherical coordinates to do some calculations. Here, I will reference the book: Geodesic Math and How TO Use IT by Hugh Kenner. Although this book was originally written in the 70s, I found it to be the most descriptive when it comes to exploring the details of creating geodesic structures.

First of all, in order to form a geodesic structure, you can start by choosing a platonic solid. For the purposes of the geodesics I’ll be dealing with, I use the Octahedron, and the Icosahedron.

One of the curious aspects of a platonic solid is that all of its vertices touch the circumscribed sphere of that solid. That is the sphere the exactly fits the outside of all the points on the solid.

Given this funny nature, it is relatively easy to imagine extending various other points of the solid to meet the sphere. Why bother? Because each of the points extended in such a way represents another vertex, and when you’re actually building a geodesic dome, each vertex is a connection point for a stick or ‘strut’.

In the picture, we have an octahedron with its center at [0,0,0] of the cartesian coordinate system.

There are a couple of ways of specifying the coordinates of the vertices in the basic solid. One is to simply use cartesian coordinates all around, thinking about the edge length, rather than the radius. To do that, the mid-section might be easy enough:

In clockwise order, starting in the positive x/y quadrant: [1,1,0], [1,-1,0], [-1,-1,0], [-1,1,0]

Then you have to calculate the vertices that are up at the top on the z and at the bottom. If you’re used to such things, you just pull out your handy dandy calculator and come up with the result. If not, perhaps you’d prefer the spherical coordinates. So, to do the same exercise in sperical coordinates, and instead of using an edge length, you use a radius of 1, and rotate around z for easier angles, you’d have: sph(0,90,1), sph(90,90,1), sph(180,90,1), sph(270,90,1) And then, for the top and bottom: sph(0,0,1), sph(0,180,1)

Remeber from the last article, in spherical coordinates, sph(longitude, latitude, radius)

Using this technique, and using the sph_to_cart(), and sph_from_cart() functions, you can easily go between the two systems. This is good because OpenScad knows about how to draw things based on cartesian coordinates, not on spherical coordinates.

The next step involves picking those intermediate points on the face of a platonic solid, and projecting them out to the circumscribed sphere. As it involves a picture to demonstrate the technique, I’ll save it for the next post.

In the meantime, here’s the link to the current version of the code: Platonic Solids for OpenScad -v0.7

With this code, you can play around with the various solids, display in wireframe, take a look at duals of the forms and the like. It’s all good preparation for the next round.

I really like you posts and Openscad codes. Can’t wait for part 3. I am trying to figure out how to join multiples geodesic domes to make a complex structure. I think I will be able to do this by joining your code and this connector generator http://www.thingiverse.com/thing:1512794. Thank you for taking the time to explain your code and the math behind.