Cellular Automata Experiment: 02

Intialize

Defines System Name for file export later

In[86]:=

sys = "Cellular" ;

iteration = "02" ;

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

In[138]:=

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

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

Show[picture] ;

[Graphics:../HTMLFiles/index_186.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[63]:=

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[64]:=

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

In[65]:=

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

initial = imageSymb ;

duration = 3 ;

Run the Cellular Automat

In[68]:=

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[69]:=

Produce still initial velocity and calculate velocity field.

In[70]:=

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[72]:=

In[73]:=

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

TransformedSurfaces = SurfaceField[VelocityField, Plane] ;

Visualization

In[75]:=

Plots of X axis coordinates

In[76]:=

PlotChannel[TransformedSurfaces, 1]

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

Plots of Y axis coordinates

In[77]:=

PlotChannel[TransformedSurfaces, 2]

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

Plots of Z axis coordinates

In[78]:=

PlotChannel[TransformedSurfaces, 3]

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

Velocity vectors at points on transformed surfaces.

In[89]:=

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

Out[89]=

-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[80]:=

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

In[81]:=

In[82]:=

melCode = melSurfaceCompile[TransformedSurfaces] ;

Export strings into .mel file.

In[83]:=

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

Out[83]=

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

In[90]:=

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

Out[90]=

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


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