How do engineers and designers 3D print real-world functional containers like coffee mugs, flower vases, cereal bowls, or solid chess pieces?
Instead of tracing a 1D path in space, we can use one of the most powerful techniques in 3D geometry: a surface of revolution (also known as lathing).
Imagine drawing a 2D cross-section of a cup wall on paper—graphing its radius $r$ at every vertical height $z$. If you take that 2D curve and spin it $360^\circ$ around the central vertical axis, it sweeps out a symmetrical, solid 3D object!
Our function revolve3d(r, z, thickness) turns your 2D profile into a 3D-printable model:
Hollow Containers (Cups, Vases, Bowls): When you specify a wall thickness (like thickness = 2.2 mm), revolve3d automatically generates an outer wall, a smooth top rim, a hollow interior cavity, and a flat, solid base floor that sits securely on the print bed!
Solid Objects (Chess Pawns, Spinning Tops, Domes): If you set thickness = 0 (or omit it), revolve3d revolves your profile into a 100% solid body of revolution.
Here is how to call revolve3d:
id=revolve3d(r,z,thickness)
Move the mouse over a dotted box for more information.
Watertight Solid Base: For hollow vessels (thickness > 0), our 3D engine automatically closes the bottom with a solid base of thickness $t$ resting flat on the printer bed at $Z = 0$, connects the outer wall to the inner cavity with a smooth rim, and ensures the entire model is 100% watertight (manifold).
Mathematical Profiling: You can create any shape you like by calculating $r$ as a function of height $z$ in a simple loop: straight tapers ($r = a + b \cdot z$), smooth power curves ($r = a + b \cdot z^p$), or wavy fluted bodies ($r = a + b \cdot \sin(c \cdot z)$).
Interactive 3D Viewer: Click and drag with your mouse to rotate the model, use your scroll wheel to zoom, and right-drag to pan. Toggle Spin to watch your cup rotate, or Wire to inspect its triangular polygon mesh.
Ready for Your Slicer: Click the Download STL button below the output to save your .stl file, which you can load directly into Cura, PrusaSlicer, Bambu Studio, or Tinkercad to slice and print!
Now you try. Run the code above to inspect your first revolved 3D cup. Try changing the rim flare from 8 to 14 for a wide latte mug, or adjust thickness to 3.0 for an extra-sturdy heavy mug!
Type your code here:
See your results here:
The code above has ???? for the wall thickness. Replace ???? with 2.2 (mm) to generate a sleek, watertight 3D-printable coffee cup!
The cup has an outer base diameter of $36$ mm (radius $18$ mm), flares outward to an outer rim diameter of $52$ mm (radius $26$ mm), stands $50$ mm tall, and has a solid $2.2$ mm wall and floor thickness.
Hit Run to generate the model, inspect the hollow interior cavity and solid base in the 3D viewer, and download your print-ready STL file.
Explore the examples below to see how easy it is to model Grecian vases, solid chess pawns, and decorative fruit bowls!
Share your code
Show a friend, family member, or teacher what you've done!