# New Year, new tools – OpenScad Tetrahedron

**Posted:**January 2, 2016

**Filed under:**3D Modeling, 3D Models, OpenScad Tutorial, Uncategorized |

**Tags:**openscad, platonic solid, tetrahedron Leave a comment

I fired up OpenScad, and created a new tetrahedron model using it. I’ve done tons with platonic solids in OpenScad in the past. This time around though, I figured I’d create the simplest tetrahedron I know. Here’s the OpenScad code for the same:

hull(){ translate([0,0,0]) sphere(4); translate([100,100,0]) sphere(4); translate([0, 100, 100]) sphere(4); translate([100, 0, 100]) sphere(4); }

The trick here is in the fact of the special relationship between a tetrahedron and a cube. The cube has 8 vertices, and you can create a tetrahedron by using 4 of those vertices. You just have to pick the right ones. You can easily choose the right ones by picking a set at opposite corners of any face (cutting a diagonal across that face). Then, choose the face exactly opposite, and select the two corners that are different from the ones you picked on the first face. Now you have these 4 vertices.

OpenScad has had the ‘hull()’ module since forever, but it didn’t always work so well. In this modern OpenScad, and for this particular case, it works extremely well. Just take the 4 vertices, throw them into a hull(), and out comes a nice tetrahedron!

This is the tetrahedron for the masses. No math required, except to know the vertices of a unit cube. And of course you can scale it up to any size you please.

If you want to do anything tricky with it though, like subtract some holes and the like, you’ll have to know the math again. But, there you have it, tetrahedron solid in a few lines of OpenScad.