Page 1 of 1

rep-4-tile

Posted: Fri Jun 03, 2005 10:13 am
by Jay Kominek
Image

Code: Select all

startshape reptile

rule sub-reptile {
// middle
 flip-reptile { rotate -180 y 173.204 x 400 }
// left
 flip-reptile { }
// right
 flip-reptile { x 300 }
// top
 reptile { rotate 120 y 346.408 x 400 }
}

rule reptile {
  side { rotate 30 }
  side { y 86.602 x -50 rotate 30 }
  side { rotate 90 }
  side { rotate 90 x -100 }
  side { rotate 90 x -200 }
  side { rotate -30 x -300 }
  side { rotate -30 x -150 y 86.602 }
  side { rotate 90 x -150 y 86.602 }
  sub-reptile { size 0.5 x -300 }
}

rule sub-flip-reptile {
// middle
 reptile { rotate 180 x -100 y 173.204 }
// left
 reptile { }
// right
 reptile { x 300 }
// top
 flip-reptile { rotate -120 y 346.408 x -100 }
}

rule flip-reptile {
  side { rotate -30 }
  side { y 86.602 x 50 rotate -30 }
  side { rotate -90 }
  side { rotate -90 x 100 }
  side { rotate -90 x 200 }
  side { rotate 30 x 300 }
  side { rotate 30 x 150 y 86.602 }
  side { rotate -90 x 150 y 86.602 }
  sub-flip-reptile { size 0.5 x 150 }
}

rule side 6 {
 plain-side { }
}

// uncomment the CIRCLE rules to get cool random dots added

rule side 1 {
 plain-side { }
 //CIRCLE { x 0 size 10 }
}

rule side 1 {
 plain-side { }
 //CIRCLE { x 50 size 10 }
}

rule side 1 {
 plain-side { }
 //CIRCLE { x 100 size 10 }
}

rule plain-side {
  line { y 0 }
  line { y 10 }
  line { y 20 }
  line { y 30 }
  line { y 40 }
  line { y 50 }
  line { y 60 }
  line { y 70 }
  line { y 80 }
  line { y 90 }
}

rule line {
  SQUARE { y 0 }
  SQUARE { y 1 }
  SQUARE { y 2 }
  SQUARE { y 3 }
  SQUARE { y 4 }
  SQUARE { y 5 }
  SQUARE { y 6 }
  SQUARE { y 7 }
  SQUARE { y 8 }
  SQUARE { y 9 }
}
if you uncomment the mentioned circle rules, you get:
Image

rep-tiles: http://mathworld.wolfram.com/Rep-Tile.html

this would be a lot cleaner with: 1) a 'flip' directive, 2) a line primitive and 3) some way to say "if we're at/near the shape limit, switch to using this version of rule $foo, rather than the other versions". with rep-n-tiles, the outlines of the smallest versions of the rep-n-tile 'merge' to produce the outline of the largest ones. so only the last iteration of rules actually needs to draw any lines. (i hope that is clear.)

flip directive

Posted: Fri Jun 03, 2005 11:40 am
by MtnViewJohn
I have been thinking along these lines too:
  • flipx: reflect through line y=0
  • flipy: reflect through line x=0
  • flipxy: reflect through line x-y=0 (x=y)
  • flip_xy: reflect through line x+y=0
The flips would transform the x and y parameters according to the reflection and reverse the sense of rotations.

Re: flip directive

Posted: Sat Jun 04, 2005 10:37 am
by chris
MtnViewJohn wrote:I have been thinking along these lines too:
  • flipx: reflect through line y=0
  • flipy: reflect through line x=0
  • flipxy: reflect through line x-y=0 (x=y)
  • flip_xy: reflect through line x+y=0
The flips would transform the x and y parameters according to the reflection and reverse the sense of rotations.
Holy cow, I *JUST* posted on this.

the reflections thing

Posted: Sun Jun 05, 2005 1:49 pm
by chris
I was thinking that rather than having separate flips by axis, the parameter of the flip directive is just the angle of the line it's reflected over.

So you could say

rule thing2 {
thing1 {flip 10}
}

it would just flip it over the line at angle theta=10.

cc

the reflections thing

Posted: Mon Jun 06, 2005 11:21 am
by MtnViewJohn
That is a much better way to do it.
  • The flip angle is always reduced to the range 0-90
  • Flipping reflects translations through the specified angle and changes the sign of all rotations.
  • Flipping on top of a previous flip is equivalent to a rotate by the sum of the two flip angles, with the translation and rotation reflections removed.