Fastness logo - art programming projects
Programming: Wave Espresso Cup
20th July 2011

The latest 3D printing project that I've taken on is to design a cup using Shapeways' new food-safe glazed ceramic material.

It's been an interesting process so far, but unfortunately not a smooth one.

The cup is based on a simple design but I wanted it to use the possibilities of 3D printing to create a product that wouldn't be possible (or at least practical) any other way.

In Processing I adapted a simple solver for the 2D wave equation that I'd found in my old Uni notes & had previously used here.  It makes a rippled outer surface for the cup by reading the disturbances when the solution is perturbed by randomly generated oscillators "pulling" and "pushing" on the surface, I then joined the top, bottom and insides to this with a handle modelled (with difficulty) in Blender.

The wave equation solver allows the ripples to move all the way around the cup but causes them to reflect from the top and bottom edges; the solution is allowed to run until it looks nice.

The code for the wave equation is quite simple:

class Wave {
  float[] f;
  float[] df;
  float[] d;
  int x,y,offset,wide,high;
  float average,damp;
  Wave(int wide, int high, float damp) {
    f = new float[wide*high];
    df = new float[wide*high];
    d = new float[wide*high];
  void disrupt(int posn, float val) {
    d[posn] = val;
  void reset() {
    d=new float[wide*high];
  void tick() {
    // f=f+df
    while(y-->0) {
      if (d[y]!=0) f[y]=d[y];
    // df=df+ddf
    while(y-->1) {
      while(x-->1) {
        df[offset] = df[offset] * damp;        

  public float[][] write2D() {
    float[][] temp = new float[wide][high];
    for (int i=0;ifor (int j=0;jint o=wide*j+i;
        temp[j][i] = f[o];
   return temp;  
This class handles the data and the solver for the wave equation, you can write the results of the matrix (found using the write2D() method or read directly into the pixels array from f )

Calling the tick() method each time the draw() method runs will cause the solution to propagate.

The implementation above will cause the ripples to reflect from all of the sides of the space you create, if you want it to wrap around you need to adapt the way that the average is calculated to include array elements on the other side of the array when you're near the edge.

Creating the model went quite well and I ended up with a design that I was quite happy with:

4 Views of the wave cup model

The ripples on one side are quite flat and subtle, I didn't expect these to come out.  On the other side the ripples are larger and much more obvious.

Unfortunately the cup really didn't come out as I'd hoped.

I ordered the cup from Shapeways in their trial glazed ceramic material, the design was intended to be a good test of the process and hopefully to get me another nice espresso cup.  What I got was this:

Cups compared

The printing process works by binding a ceramic powder into a fragile, "green", state with glue printed layer-by-layer.  This is fired and glazed to produce the final product.

The layers are easily visible on some parts of the cup where the glaze is thinner, and the ripples are only just about visible.  The other side, which should be smoother, is not much better and, while I'd expected the small ripples not to come out, I didn't expect it not to be smooth at all.

However, Shapeways' excellent customer service came to the rescue, they've arranged for a re-print and their production manager was keen to express that they've learned more through the trial and feel that they can do better than this now - I'm waiting for the result and we'll see what comes out in the end...

Please feel free to use the code above in your sketches, I'd be fascinated to know what you make with it.

fastness - Iain Banks Graphics
Fastness - Iain Banks Graphics
All of the content from my Iain M Banks website, now shifted to be a section in this one

fastness - Links & Resources:
An open source programming tool aimed at artists, engineers and designers.  Simple, light and Java-based with a wealth of libraries and a strong user community

3D printing for the masses - plastics and metal to your design or team up with a desigenr to personalise a design with a 'co-creator'.  Visit my Shapeways shop for some things I've designed.

MeshLab is an open source, portable, and extensible system for the processing and editing of unstructured 3D triangular meshes

Blender is the free open source 3D content creation suite, available for all major operating systems under the GNU General Public License

GIMP is the GNU Image Manipulation Program. It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages

An Open Source vector graphics editor, with capabilities similar to Illustrator, CorelDraw, or Xara X, using the W3C standard Scalable Vector Graphics (SVG) file format

Retail laser cutting outlet with centres in New Zealand, USA, Germany, Italy and the UK (if not more by now)

Java development environment