CHAPTER 1 ■ 3D MATH FUNCTIONS
2
■ Tip This book presumes you are generally familiar with 3D printing practices. If not,
you can learn how to use a printer from Joan’s previous book, Mastering 3D Printing
(Apress, 2014) or our book 3D Printing With MatterControl (Apress, 2015). Unless we
specifically note otherwise, prints in this book were created on a Deezmaker Bukito in
polylactic acid (PLA) plastic, using the MatterSlice engine in MatterControl (although we
could have used any software compatible with an open source printer).
Math Background
This chapter presumes you know what a function is—a relationship among a number of
variables. In this case, we are dealing with functions using three variables, which we will call
x, y, and z. Function notation looks like this: z = f (x,y). All that means is that our variable, z,
can be computed for any given pair of values for the x and y variables. Having three variables
means we can define shapes in three dimensions, with one variable corresponding to each
dimension. Normally these three-dimensional shapes would be shown on a page with
two-dimensional projections. Often, this is fine and you can see what is going on.
Sometimes, however, it really helps to hold a 3D model in your hand and turn it this way
and that. This chapter will give you the ability to do that for many types of functions.
■ Note 3D printing convention holds that x and y are in the plane of the platform that your
model is being built up on, and z is vertical height above that. In other words, the bottom
of the surfaces generated in this chapter is always the z = 0 plane. In this convention, you
always have to transform what you are printing to have z greater than or equal to zero, since
you cannot build under the platform. In other words, if you know that z would be negative for
some values of x and y that you want to use, you may have to add an offset to your equation
so that z is always greater than zero and remember that the offset is there when you think
about what your model represents.
We will get you started with a model entirely in OpenSCAD that creates surfaces of
functions z = f (x,y), where x and y are the plane of the 3D printer’s build platform, and z is
the height of the surface above that plane. First we will show you how the basic 3D math
model Rich has written and included here works, and what kind of functions you can
print. Then we will show you a simple model that creates surfaces that might be a starting
point for your own projects in OpenSCAD.
Alternatively you may have code you developed that produces a surface you would
like to 3D print. It may not be practical to port that code to an OpenSCAD model. We will
also show you an example in which we wrote a separate Python script that produces a file,
which is then read into OpenSCAD and made into a surface. Finally we will give you some
ideas about how you might use these tools as a teacher or as part of a student project.