cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Browse apps to extend the software in the new JMP Marketplace
Choose Language Hide Translation Bar
Craige_Hales
Super User
Tile JSL part 1

8424_penroseSmall.png

Here's the first part of the code for the video in the previous post.  This is a straight-forward translation/conversion of the reference.  The generator recursively subdivides the starting space, using a set of rules that make a valid Penrose tiling.  Sorry, can't explain the rules, just the code to apply them.

// http://martinpblogformasswritingproject.blogspot.com/2011/06/penrose-tiling-in-pyprocessing.html
DELTA = PI()/5;
cx=0;
cy=0;
ca=-DELTA;
repeat=1;
W=function({lev},{sx,sy,sa},// "YBF2+ZRF4-XBF[-YBF4-WRF]2+";
lev--;if(lev>= 0,
Y(lev);B(lev);F(lev);NUMB(2);PLUS();Z(lev);R(lev);F(lev);NUMB(4);SUB();X(lev);B(lev);F(lev);sx=cx;sy=cy;sa=ca;SUB();Y(lev);B(lev);F(lev);NUMB(4);SUB();W(lev);R(lev);F(lev);cx=sx;cy=sy;ca=sa;NUMB(2);PLUS();
));
X= function({lev},{sx,sy,sa},// "+YBF2-ZRF[3-WRF2-XBF]+";
lev--;if(lev>= 0,
PLUS();Y(lev);B(lev);F(lev);NUMB(2);SUB();Z(lev);R(lev);F(lev);sx=cx;sy=cy;sa=ca;NUMB(3);SUB();W(lev);R(lev);F(lev);NUMB(2);SUB();X(lev);B(lev);F(lev);cx=sx;cy=sy;ca=sa;PLUS();
));
Y=function({lev},{sx,sy,sa},//"-WRF2+XBF[3+YBF2+ZRF]-";
lev--;if(lev>= 0,
SUB();W(lev);R(lev);F(lev);NUMB(2);PLUS();X(lev);B(lev);F(lev);sx=cx;sy=cy;sa=ca;NUMB(3);PLUS();Y(lev);B(lev);F(lev);NUMB(2);PLUS();Z(lev);R(lev);F(lev);cx=sx;cy=sy;ca=sa;SUB();
));
Z=function({lev},{sx,sy,sa},// "2-YBF4+WRF[+ZRF4+XBF]2-XBF";
lev--;if(lev>= 0,
NUMB(2);SUB();Y(lev);B(lev);F(lev);NUMB(4);PLUS();W(lev);R(lev);F(lev);sx=cx;sy=cy;sa=ca;PLUS();Z(lev);R(lev);F(lev);NUMB(4);PLUS();X(lev);B(lev);F(lev);cx=sx;cy=sy;ca=sa;NUMB(2);SUB();X(lev);B(lev);F(lev);
));
B = function({lev},0);
F = Function( {lev}, /*draw cx,cy,ca*/
  If( lev == 0,
  new_xpos = cx + 20 * Cos( ca );
  new_ypos = cy - 20 * Sin( ca );
  dt << addrows( 1 );
  dt:x1 = cx;
  dt:y1 = cy;
  dt:x2 = new_xpos;
  dt:y2 = new_ypos;
  cx = new_xpos;
  cy = new_ypos;
  )
);
R = function({lev},0);
PLUS=function({},ca += DELTA * repeat; repeat = 1);
SUB=function({},ca -= DELTA * repeat; repeat = 1);
NUMB=function({n},repeat=n); // 2,3,4
// this table isn't used, except for the test image
dt=New Table( "Untitled",
  Add Rows( 0 ),
  New Column( "x1", Numeric, Continuous, Format( "Best", 12 ), Set Values( [] ) ),
  New Column( "y1", Numeric, Continuous, Format( "Best", 12 ), Set Values( [] ) ),
  New Column( "x2", Numeric, Continuous, Format( "Best", 12 ), Set Values( [] ) ),
  New Column( "y2", Numeric, Continuous, Format( "Best", 12 ), Set Values( [] ) )
);
level=4;//5;//8;
local({i,sx,sy,sa},
  for(i=1,i<=5,i++, //AXIOM = "2+2+2+2+";
  sx=cx;sy=cy;sa=ca;
  X(level);
  cx=sx;cy=sy;ca=sa;
  NUMB(2);
  PLUS();
  );
);
// http://www.maths.surrey.ac.uk/hosted-sites/R.Knott/Fibonacci/fibFormula.html
// seems to be a Fibonacci sequence.  estimate the axis size.
size = 22 * (1.61803398874989 ^ level);
New Window( "Example",
  Graph Box(framesize(600,600),xscale(-size,size),yscale(-size,size),transparency(.3),
  foreachrow(
  Line({dt:x1,dt:y1},{dt:x2,dt:y2} ));
  )
);

 

On line 49, set the level, up to about 8 if you have time.

In Part 2, code to isolate the polygons, remove duplicates, and make them all have the same handedness. https://community.jmp.com/t5/Uncharted/More-tile/ba-p/21047 https://community.jmp.com/t5/Uncharted/Tile/ba-p/21259

Last Modified: May 26, 2017 4:48 PM