rep-4-tile

If you have a design you're proud of, share the cfdg file here. It's also a good place to ask for feedback and collaborate.

Moderators: MtnViewJohn, chris, mtnviewmark

Post Reply
Jay Kominek
Posts: 3
Joined: Fri Jun 03, 2005 9:45 am
Location: Boulder County, CO
Contact:

rep-4-tile

Post 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.)

User avatar
MtnViewJohn
Site Admin
Posts: 882
Joined: Fri May 06, 2005 2:26 pm
Location: Mountain View, California
Contact:

flip directive

Post 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.

User avatar
chris
Site Admin
Posts: 72
Joined: Wed May 04, 2005 10:57 am
Location: New York, NY
Contact:

Re: flip directive

Post 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.
Current Project: I'm creative director of OKCUPID at http://www.okcupid.com

User avatar
chris
Site Admin
Posts: 72
Joined: Wed May 04, 2005 10:57 am
Location: New York, NY
Contact:

the reflections thing

Post 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
Current Project: I'm creative director of OKCUPID at http://www.okcupid.com

User avatar
MtnViewJohn
Site Admin
Posts: 882
Joined: Fri May 06, 2005 2:26 pm
Location: Mountain View, California
Contact:

the reflections thing

Post 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.

Post Reply