# 3D Printing with Mathematica

The previous solution of modeling 3D parametric surfaces proved to be very computationally demanding and inefficient. I found a new, very little known way to use Mathematica to create 3D parametric surfaces and/or implicit plots.

## Theory

Mathematica is a powerful tool that has built in functions that can take care of the entire process for us. By creating a graph under certain parameters, we can export it as an STL file.

The three functions we can use:

• ContourPlot3D[] Allows us to plot implicitly.
• RegionPlot3D[] Allows us to plot a region (ex. the inside of a sphere).
• ParametricPlot3D[] Allows us to plot a parametric equation.

We can then call the Export[] function.

## Gyroid Example:

A gyroid is an infinitely connected triply periodic minimal surface discovered by Alan Schoen in 1970. It can be approximated by the expression: $$\sin{x}\cos{y}+\sin{y}\cos{z}+\sin{z}\cos{x}=0$$

We can use ContourPlot3D[] to generate the geometry:

s = 3;
gyroid = ContourPlot3D[
Sin[x]*Cos[y] + Sin[y]*Cos[z] + Sin[z]*Cos[x] == 0, {x, -s, s},
{y, -s, s }, {z, -s, s}, Extrusion -> 0.2, Mesh -> False,
PlotPoints -> 4]
Export["gyroid.stl", gyroid]


I printed one of these out on my 3D printer. It was pretty neat. I ended up doing a public speaking assignment about it for my writing class at the time, and I got positive feedback.

## Breather Example:

In physics, a breather is a nonlinear wave in which energy concentrates in a localized and oscillatory fashion. This contradicts with the expectations derived from the corresponding linear system for infinitesimal amplitudes, which tends towards an even distribution of initially localized energy.

It can be evaluated with the parametric equation:

$$x = \frac{2 \left(1-b^2\right) \sinh (b u) \cosh (b u)}{b \left(\left(1-b^2\right) \cosh ^2(b u)+b^2 \sin ^2\left(\sqrt{1-b^2} v\right)\right)}-u,$$ $$y = \frac{2 \sqrt{1-b^2} \cosh (b u) \left(\left(-\sqrt{1-b^2}\right) \cos (v) \cos \left(\sqrt{1-b^2} v\right)-\sin (v) \sin \left(\sqrt{1-b^2} v\right)\right)}{b \left(\left(1-b^2\right) \cosh ^2(b u)+b^2 \sin ^2\left(\sqrt{1-b^2} v\right)\right)},$$ $$z = \frac{2 \sqrt{1-b^2} \cosh (b u) \left(\cos (v) \sin \left(\sqrt{1-b^2} v\right)-\sqrt{1-b^2} \sin (v) \cos \left(\sqrt{1-b^2} v\right)\right)}{b \left(\left(1-b^2\right) \cosh ^2(b u)+b^2 \sin ^2\left(\sqrt{1-b^2} v\right)\right)}$$

We can use ParametricPlot3D[] to generate the geometry:

r := 1 - b^2;
w := Sqrt[r];
denom := b*((w*Cosh[b*u])^2 + (b*Sin[w*v])^2)
breather = {-u + (2*r*Cosh[b*u]*Sinh[b*u])/denom,
(2*w*Cosh[b*u]*(-(w*Cos[v]*Cos[w*v]) - Sin[v]*Sin[w*v]))/denom,
(2*w*Cosh[b*u]*(-(w*Sin[v]*Cos[w*v]) + Cos[v]*Sin[w*v]))/denom};
breathersurf = ParametricPlot3D[
Evaluate[breather /. b -> 0.4], {u, -13.2, 13.2}, {v, -37.4, 37.4},
PlotRange -> All, Extrusion -> 0.3, Mesh -> False,
PlotPoints -> {200, 40}]
Export["breathersurf.stl", breathersurf]


Geometry Index: