## Animorph design with OpenSCAD

Par François le mardi 20 janvier 2015, 12:54 - Lien permanent

Hi, you might already have encountered such video of amazing 3D-printed kind of "alive" sculpture:

https://www.youtube.com/watch?v=9AhMMC_CSks

I'll introduce basic explanation of the phenomenon which allows such performance and how to design an aniform/animorph object.

## How does this marvel work?

The object is put at the center of a turntable. A stroboscope flashes every time the object has turned a specific angle. As the object has a periodic repetition of a pattern on its surface, the persistence of vision gives the illusion of the rotation not happening and the motion of the pattern, like for the video film technique or the zootrope/zoetrope :

https://www.youtube.com/watch?v=9hKnLl-zQGs

## How can I design one?

Install OpenSCAD (free libre software) : http://www.openscad.org/ With a few scripting lines, you'll design an object which can then be exported to multiple interchange formats (and 3D-printed etc.).

### The basis frame

We'll position a cube around a sphere, in a pseudo-periodic manner, in a way that:

- every 'angle' degrees of rotation of the sphere, the cube repeats,
- the sphere has to rotate 'floors' time so that the cube reaches the south pole from the north pole.

angles = 8; floors = 8; instances = angles*floors; for (i = [1:instances]) { rotate([0, 0, -360*i/angles]) // rotate around the vertical axis rotate([0, -90+180*i/instances, 0]) // slowly lower the cube translate([40, 0, 0]) // the radius of the sphere cube(10, center=true); // the object being repeated: a cube. }

*(squint in order to see in 3D)*

We can put the cubes more sparsely: instead of having them exactly aligned 'floor' after 'floor', we'll put them just behind their upstairs neighbours by adding 0.5 to the 'angles' variable.

angles = 8.5; floors = 8; instances = angles*floors; for (i = [1:instances]) { rotate([0, 0, -360*i/angles]) // rotate around the vertical axis rotate([0, -90+180*i/instances, 0]) // slowly lower the cube translate([40, 0, 0]) // the radius of the sphere cube(10, center=true); // the object being repeated: a cube. }

*(squint in order to see in 3D)*

### Let's animate that!

We will take advantage of OpenSCAD animation capabilities to simulate the rotation of our object. We'll add a rotation line top of the for loop:

angles = 8.5; floors = 8; instances = angles*floors; rotate([0, 0, $t*360]) for (i = [1:instances]) { rotate([0, 0, -360*i/angles]) // rotate around the vertical axis rotate([0, -90+180*i/instances, 0]) // slowly lower the cube translate([40, 0, 0]) // the radius of the sphere cube(10, center=true); // the object being repeated: a cube. }

We'll activate the animation in OpenSCAD thanks to the View > Animate menu:

And in the box in the bottom right of the window, write FPS: 15 (you can choose whatever frequency you want) and Steps: 9 (which is just above the 'angle' variable value; we could have written 8.5 but the animation does not keep phase, so the animation will show a glitch).

You'll see your object animated:

### Let's do something with the cubes

We'll scale them and join them so that it's a solid object instead of an unprintable constellation of boxes.

angles = 8.5; floors = 8; instances = angles*floors; rotate([0, 0, $t*360]) for (i = [1:instances]) { rotate([0, 0, -360*i/angles]) // rotate around the vertical axis rotate([0, -90+180*i/instances, 0]) // slowly lower the cube translate([40, 0, 0]) // the radius of the sphere scale(0.7+1.7*sin(180*i/instances)) // small near the poles, bigger at the equator cube(10, center=true); // the object being repeated: a cube. }

Let's rotate the cubes around themselves during their lifespan.

angles = 8.5; floors = 8; instances = angles*floors; rotate([0, 0, $t*360]) for (i = [1:instances]) { rotate([0, 0, -360*i/angles]) // rotate around the vertical axis rotate([0, -90+180*i/instances, 0]) // slowly lower the cube translate([40, 0, 0]) // the radius of the sphere scale(0.7+1.4*sin(180*i/instances)) // small near the poles, bigger at the equator rotate([45+45*i/instances, 45+300*i/instances, 0]) cube(10, center=true); // the object being repeated: a cube. }

### Let's replace the cubes with something else.

Let's imagine… well, as we lack imagination and want something simple for the sake of the explanation, let's replace the cubes with spheres, but not any sphere. Elongated, flattened spheres. Oh, and let's shake them. That'll be funny. Won't it? OK, so, here is a deus ex machina. Deus with comments, for god's sake.

angles = 13.5; floors = 13; instances = angles*floors; rotate([0, 0, $t*360]) difference() { for (i = [1:instances]) { rotate([0, 0, -360*i/angles]) // rotate around the vertical axis rotate([0, -90+180*i/instances, 0]) // slowly lower the cube translate([20, 0, 0]) // the radius of the sphere scale(0.5+1.4*sin(180*i/instances)) // small near the poles, bigger at the equator rotate([0, 0, 8*sin(15*180*i/instances)]) // wiggle scale([2+3*sin(180*i/instances), 1, 0.66]) // elongating and flattening the sphere sphere(8, center=true, $fn=50); } translate([0, 0, -133]) cube(200, center=true); // a flat basis }

## (Awe)Some ideas

- Create an animorph in a zootrope/zoetrope.
- Create an animorph which animates a human face.
- Create an animorph with an half-horse riding outwards.

Anyone?

## Commentaires

Another idea: adapt this GIF to an Aniform? https://framasphere.org/posts/37640...