Lesson goal: Make a 3D-printable XY-graph

Previous: Play a chirp | Home | Next: Turn an LED on and off

Do you have a 3D printer? How would you like to design an object that you can actually print, using your math and coding skills?

If you understand arrays, from this lesson or this lesson or how to fill arrays and make on-screen plots from this lesson, then you should be all set.

To make 3D prints using math, you need to fill two arrays with data points. One will hold x-axis points, and the other y-axis points. Once done, our function called print3d, will prepare your arrays for 3D-printing. It will cause your printer to lay down plastic at the corresponding (x,y) millimeter positions on your print-platform as read from your x and y arrays. (Think of your print-platform as a piece of graph paper. Your x and y arrays are the points you'd normally plot with a pencil on the graph paper.)

Here's print3d, that will create a print-ready STL file, based on the numbers in your arrays:

id=print3d(x,y,R)
Move the mouse over a dotted box for more information.

  • When done, the varible id will contain an identifier that allows you to retrieve you 3d-printable STL file from this link:
    http://www.codebymath.com/welcome/index.php/getstl/--INSERT-YOUR-RETURNED-ID-HERE--

  • This STL file should be loaded into your 3D-printer's software for printing.

  • All numbers you use will be interpreted by your 3D-printer to be in millimeters.

Now you try. Go for it! Let's get your 3D printer cranking! Design with math!

Type your code here:


See your results here:

The code above will make a section of the parabola $y=0.1x^2$ for $x$ between -10 and 10.

See some of the examples for filling the x and y arrays using a for-loop.

Printing the value in id, as returned by print3d, will show you the identifer you'll need to retrieve your print-ready file, using this link:
http://www.codebymath.com/welcome/index.php/getstl/--PUT-ID-HERE--

Note that your STL file will be deleted from our server in approximately 60 minutes.

Dismiss.

Show a friend, family member, or teacher what you've done!

Here is a share link to your code:

Does your code work? Want to run it on your iPhone?

Here's your code:

  1. Use [Control]-[C] (Windows) or [⌘]-[C] (MacOS) to copy your code.

  2. Paste it using [Control]-[V] (Windows) or [⌘]-[V] (MacOS) into this page

  3. Then click the "Use on iPhone" button that you'll see.