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

Previous: Pole Position: Speed, Curves & Steering | Home | Next: Parametric 3D print designs (clovers and more)

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, which previews your model in an interactive 3D viewer and creates 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 you run your code, an interactive 3D WebGL preview of your model appears on the right! You can click and drag with your mouse to rotate the model, use the scroll wheel to zoom, and right-click to pan.

  • A Download STL File button appears directly below your code output. Clicking it downloads the .stl file directly onto your computer with no server delay and no expiration!

  • You can import this STL file into your 3D printer's slicer software (such as Cura, PrusaSlicer, or Bambu Studio) or online modeling tools (like Tinkercad) to slice and print your mathematical creation.

  • All coordinates in your x and y arrays are interpreted as millimeters (mm) on the 3D printer's build plate.

Now you try. Set R = 1.0 above and hit Run to preview and download your first 3D-printed math parabola!

Type your code here:


See your results here: