Sunday, October 14, 2007

Random sculptures

Here is a piece of Mathematica code for generating interesting random sculptures by generating 2-dimensional manifolds embedded in 3-dimensional space.

Define a function that computes a random sum of sinewaves, where the maximum frequency is controlled by the n parameter. Differently seeded versions of this function will be used to determine the displacement of the 2-dimensional manifold in each of the directions in 3-dimensional space.

f[x_,n_]:=Sum[RandomReal[{-1,1}]Cos[i x+RandomReal[2\[Pi]]], {i,0,n}];

Display a random sculpture. The n parameter controls the complexity of the sculpture.

With[{n=1}, ParametricPlot3D[Table[f[u,n]f[v,n],{3}]//Evaluate, {u,0,2\[Pi]},{v,0,2\[Pi]}, PlotStyle->Opacity[0.25], Mesh->False, Boxed->False, Axes->False]]

Here are 3 examples of the sort of result that you can obtain. Not bad for a simple piece of code!



2 comments:

Anonymous said...

They are pretty

Stephen Luttrell said...

I forgot to mention in my posting (I wrote it and the Mathematica code after a session at the pub!) that I was inspired by the Fire Art here which I was led to by the Backreaction posting here.

In this Fire Art the flames appear (to me at least) to be like a crumpled-up sheet, which suggested that I could mimic this to create some synthetic art, i.e. create random 2-dimensional manifolds embedded in 3-dimensional space. Although my synthetic results actually look very little like real Fire Art, I think they are pretty anyway.

I'll see whether this idea can be developed further.