Cellular Automata Experiment: 01

Intialize

Defines System Name for file export later

In[32]:=

sys = "Cellular" ;

iteration = "01" ;

Import raster image, get RGB vector list and stripping the Mathematica Graphics data.

In[141]:=

picture = Import [projectPath <> "Initial_Pic-01.jpg"] ;

image = (picture[[1]][[1]]/128) - 1 ;

Show[picture] ;

[Graphics:../HTMLFiles/index_139.gif]

Acceleration Field

Wrap vectors in function named 'vector' so it will work with the Cellular Automata function.  The Cellular Automata function utilizes a ListCorrelate while workings and the vector list causes errors.  Later this 'vector' function will return the vector list unchanged.

In[36]:=

imageSymb = Map[vector, image, {2}] ;

Acceleration
The Acceleration function takes a 2D list of symbols represeting 3D vectors and outputs a new symbol of the sum of the cross products of the vectors in the Von Neuman neighborhood times the time enveloped by a Sin curve.  This will give an every increasing magintude to the acceleration that will increase in cycles.

In[37]:=

Define the intial conditions of the Cellular Automata inculding the number of time steps.

In[38]:=

ruleSet = {Acceleration[#1, #2] &, {}, {1, 1}} ;

initial = imageSymb ;

duration = 3 ;

Run the Cellular Automat

In[41]:=

AccelerationField = N[CellularAutomaton[ruleSet, initial , duration] /. vector[v_List] -> v] ;

Velocity Field

Velocity
Takes the acceleration field and a 2D list of 3D vectors as the initial velocity and compiles a velocity field at each time step by adding the acceleration at that time step to the previous time step's velocity.

In[42]:=

Produce still initial velocity and calculate velocity field.

In[43]:=

InitialVelocity = Table[0, {i, 1, Dimensions[AccelerationField][[2]]}, {j, 1,   Dimensions[AccelerationField][[3]]}] ;

VelocityField = Velocity[AccelerationField, InitialVelocity] ;

Surfaces

SurfaceField
Similiar to the Velocity function.  Given the velocity field and a 2D list of 3D vectors as the positions of the vertices of the surface, the function compiles a series of coordinates at each time step by moving each point by the velocity of that point at each time step.

In[45]:=

In[46]:=

Plane = Table[{.25 * i, .25 * j, 0}, {i, 1, Dimensions[VelocityField][[2]]}, {j, 1,   Dimensions[VelocityField][[3]]}] ;

TransformedSurfaces = SurfaceField[VelocityField, Plane] ;

Visualization

In[53]:=

Plots of X axis coordinates

In[54]:=

PlotChannel[TransformedSurfaces, 1]

[Graphics:../HTMLFiles/index_158.gif]

Plots of Y axis coordinates

In[50]:=

PlotChannel[TransformedSurfaces, 2]

[Graphics:../HTMLFiles/index_164.gif]

Plots of Z axis coordinates

In[51]:=

PlotChannel[TransformedSurfaces, 3]

[Graphics:../HTMLFiles/index_170.gif]

Velocity vectors at points on transformed surfaces.

In[55]:=

[Graphics:../HTMLFiles/index_172.gif]

Out[55]=

-Graphics3D -

Output Surfaces

melEncoding
Requires a 2D List of 3D vectors and integer number for labeling purposes.  Begin formatting array of vectors for export by converting to a string and replacing ','s with a space.  Initialize counters.  'i' for CV's in u direction. 'j' for CV's in v direction. 'd' gives size of image.  Then move through lists and replace characters with mel code to select the surface and move the CV according to the SurfaceArray vectors.  Finally add mel code header that creates the nurbs suface.  Return String of mel code that creates nurbsPlane and moves CV's to locations in 2D list.

In[57]:=

melSurfaceCompile
Takes the list of surface coordinates and produces one surface at each time step.

In[58]:=

In[71]:=

melCode = melSurfaceCompile[TransformedSurfaces] ;

Export strings into .mel file.

In[72]:=

Export[projectPath <> sys <> iteration  <> ".mel", melCode, "Text"]

Out[72]=

D:\\My Documents\\Columbia\\Algorithmic Morphologies\\Cellular01.mel

In[56]:=

Export[projectPath <> sys <> iteration  <> "-01.jpg", FieldPlot, "JPEG", ImageSize→ {800, 800}]

Out[56]=

D:\\My Documents\\Columbia\\Algorithmic Morphologies\\Cellular01-01.jpg


Created by Mathematica  (October 23, 2006) Valid XHTML 1.1!