Mathematics Department quick guide

From recursion to a printable Sierpiński solid

Install OpenSCAD, add optional geometry libraries, and turn a recursive definition into a connected tetrahedral model ready for slicing.

  • No library required
  • Windows, macOS, and Linux
  • Printable overlap included
First recursive stage of a Sierpiński tetrahedron Four smaller wireframe tetrahedra occupy the corners of one larger tetrahedron.
Recursive rule Place four half-size copies at the vertices.
01

Install the modeller

Start with the stable OpenSCAD release

Use the official download page. Development snapshots are useful later, but the stable build is the simpler classroom default.

Windows

Download the 64-bit EXE installer, or install from Windows Terminal.

winget install --id=OpenSCAD.OpenSCAD -e

macOS

Choose the macOS installer listed for your Mac on the official downloads page. Open the DMG, then drag OpenSCAD into Applications.

If macOS blocks the first launch, control-click the app and choose Open.

Linux

On Debian or Ubuntu, install the repository package. Other distributions can use the official AppImage.

sudo apt-get install openscad
02

Optional libraries

Add helpers after the basic model works

The Sierpiński example below uses only native OpenSCAD. Libraries become useful when you add rounded parts, paths, labels, fixtures, or more complicated polyhedra.

  1. 1
    Open the library folder

    In OpenSCAD, choose File → Show Library Folder.

  2. 2
    Extract each library once

    Place its top-level folder inside libraries; for example, libraries/BOSL2/std.scad.

  3. 3
    Restart and verify

    Open Help → Library Info and confirm the folder appears in the search path.

BOSL2

OpenSCAD 2021.01+

Broad geometry toolkit with transforms, attachable shapes, paths, sweeps, polyhedral data structures, and math helpers.

include <BOSL2/std.scad>
Download BOSL2

MCAD

Mechanical and mathematical parts

Smaller collection with regular shapes, curves, constants, transformations, gears, and common mechanical components.

use <MCAD/regular_shapes.scad>
Download MCAD

Default user library folders: Documents\OpenSCAD\libraries on Windows, ~/Documents/OpenSCAD/libraries on macOS, and ~/.local/share/OpenSCAD/libraries on Linux.

03

Build the fractal

Four copies, half scale, repeated

At depth d, the model contains 4d tetrahedra. Its similarity dimension is log(4) / log(2) = 2.

sierpinski_tetrahedron.scad
// Printable Sierpinski tetrahedron
edge  = 64;    // outer edge length, mm
depth = 3;     // 4^3 = 64 small tetrahedra
weld  = 1.03;  // slight overlap for a connected print

corners = [
  [ 1,  1,  1], [ 1, -1, -1],
  [-1,  1, -1], [-1, -1,  1]
];

module tetrahedron(side) {
  scale(side / (2 * sqrt(2)))
    polyhedron(
      points = corners,
      faces  = [[0,2,1], [0,1,3],
                [0,3,2], [1,2,3]]
    );
}

module sierpinski(side, level) {
  if (level == 0) {
    scale([weld, weld, weld]) tetrahedron(side);
  } else {
    for (p = corners)
      translate(p * (side / (4 * sqrt(2))))
        sierpinski(side / 2, level - 1);
  }
}

color("#f26b38") sierpinski(edge, depth);
04

Render and export

Check the solid before spending filament

Preview

Open the SCAD file and press F5. Rotate the view and confirm all four branches appear at each level.

Render

Press F6. Read the console. If the model is disconnected or non-manifold, increase weld slightly.

Export

Choose File → Export → Export as STL, then inspect the sliced preview before printing.