## Sierpinski Pyramid

This Web page publishes the C++ code that generates a 3-D object that I call a Sierpinski pyramid. The Sierpinski pyramid program displays a wire frame of the pyramid, and rotates it through all three dimensions, using openGL. A DXF description for the object is written to a file or to stdout. The DXF file format was developed by AutoDesk and is commonly used to exchange 3-D models. Most 3-D rendering programs can read DXF format files.

The Sierpinski pyramid is inspired by the two dimensional Sierpinski "gasket" described in Chaos and Fractals: New Frontiers of Science by Peitgen, Jurgens and Saupe, Springer Verlag 1992.

Waclaw Sierpinski (1882-1969) was a professor at Lvov and Warsaw. He was one of the most influential mathematicians of his time in Poland and had a worldwide reputation. In fact, one of the moon's craters is named after him.

The basic geometric construction of the Sierpinski gasket goes as follows. We begin with a triangle in the plane and then apply a repetitive scheme of operations to it (when we say triangle here, we mean a blackened, 'filled-in' triangle). Pick the midpoints of its three sides. Together with the old verticies of the original triangle, these midpoints define four congruent triangles of which we drop the center one. This completes the basic construction step. In other words, after the first step we have three congruent triangles whose sides have exactly half the size of the original triangle and which touch at three points which are common verticies of two contiguous trianges. Now we follow the same procedure with the three remaining triangles and repeat the basic step as often as desired. That is, we start with one triangle and then produce 3, 9, 27, 81, 243, ... triangles, each of which is an exact scaled down version of the triangles in the preceeding step.

Chaos and Fractals, pgs 78-79

A three triangle and a nine triangle Sierpinski gasket are shown below.

The Sierpinski pyramid is a three dimensional version of the one dimensional Sierpinski gasket. Like the Sierpinski gasket, it is a recursive structure. In my program, the Sierpinski pyramid is classified by its power:

Recursive Structure of a Sierpinski Pyramid
Power Pyramid Shape
0 A single pyramid
1 A single pyramid with four pyramid children
2 A power 1 pyramid with four power 1 children
N A power N-1 pyramid with four N-1 children

A power three and a power four Sierpinski pyramid are shown below. These objects were written out in DXF file format and then read into trueSpace to be rendered. You can click on the images to see larger versions. If you use these images, please credit me as their creator.

(178 K bytes) (282K bytes)

Source for the Sierpinski pyramid program

The program that generated the Sierpinski objects above was written in C++ and compiled with Microsoft Visual C++ 4.1. It was tested on Windows NT 3.51 and the 4.0 beta, on a 486DX2-66 system. The program was written using standard UNIX system calls, so it should also compile and run on any NT or UNIX system that supports openGL. Since these files were developed on NT, on a UNIX system they will have the irritating control-M characters at the end of every line. Most UNIX systems have a program like dos2unix or to_unix which will strip these character out once they are untared or unzipped. The idiotic DOS eight character file name limit also caused a problem with the file dxftokens.h which is represented as DXFTOK~1.H in the pkziped file.

Ian Kaplan - May 1996

Changes and bug fixes

June 16, 1996

• Sierpinski display program modified to use openGL display lists. This makes display of the 3-D Sierpinski pyramid somewhat faster.
• Fixed a bug in pagepool.cpp. The page_size variable was being initialized in the global scope, which can result in a divide by zero area, depending on the order in which the constructors are executed.