logo fractal: snowflake 
Author Message
 logo fractal: snowflake

This is a multi-part message in MIME format.

--------------425A1B403B6A
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Here is a set of routines which produce a space-filling curve in Logo.
The pattern fills a regular hexagon.
Each image produced is a simple closed curve,
which means the curve does not intersect itself anywhere.
As a result, the entire region can be filled.
If you have a 1024x768 screen and MSW
Logo, try maximizing the MSWlogo window and then run flake 360 7.
flake 360 8 is also interesting because the curve is so convoluted, fill
can't fill the whole thing. Pushing the envelope, as it were...

Note: This is NOT the famous "snowflake curve." That's too easy...

The attatched zip file
is a .bmp image of the individual patterns a, b, c, and d.

Patterns a, b, and c turn a single line segment into 3 smaller segments.
These patterns eventually fill up an equilateral triangle.

Pattern d breaks a segment into 7 smaller segments, 2 of which meet
at a 180 degree angle, so they look like one segment. This pattern will
eventually fill a 60-120 rhombus (two triangles joined face to face.)

Of course, copy and modify this at your whim. Email me if you have any
questions. My name is David not George (he's my dad.) No, of course
he isn't you know who. :-)

to a :x :y :theta :dist :flip :depth :maxd
(if (:depth = :maxd)
  [ setxy :x :y seth :theta pd fd :dist ]
  [ localmake "x1 (:x + (((sin (:theta +(60 * :flip)))* :dist)/ 2))
    localmake "y1 (:y + (((cos (:theta +(60 * :flip)))* :dist)/ 2))
    localmake "x2 (:x1 + (((sin :theta)* :dist)/ 2))
    localmake "y2 (:y1 + (((cos :theta)* :dist)/ 2))
    c :x :y (:theta + (60 * :flip)) (:dist / 2) 1 -(:flip) (:depth + 1)
:maxd
    d :x1 :y1 :theta (:dist / 2) -(:flip) (:depth + 1) :maxd
    c :x2 :y2 (:theta - (60 * :flip)) (:dist / 2) -1 :flip (:depth + 1)
:maxd ])
end

to b :x :y :theta :dist :rev :depth :maxd
(if (:depth = :maxd)
  [ setxy :x :y seth :theta pd fd :dist ]
  [ (if (:rev = 1)
      [ b1 :x :y :theta :dist :rev :depth :maxd]
      [ b2 :x :y :theta :dist :rev :depth :maxd]) ])
end

to b1 :x :y :theta :dist :rev :depth :maxd
   localmake "x1 (:x + ((sin :theta) * :dist/2))
   localmake "y1 (:y + ((cos :theta) * :dist/2))
   localmake "x2 (:x1 + ((sin (:theta +30)) * :dist * :k1))
   localmake "y2 (:y1 + ((cos (:theta +30)) * :dist * :k1))
   localmake "d0 (:dist * :k1)
   b :x :y :theta (:dist / 2) 1 (:depth + 1) :maxd
   d :x1 :y1 (:theta + 30) :d0 -1 (:depth + 1) :maxd
   c :x2 :y2 (:theta  - 30) :d0 -1 1 (:depth + 1) :maxd
end

to b2 :x :y :theta :dist :rev :depth :maxd
   localmake "x1 (:x + (((sin (:theta - 30))* :dist) * :k1))
   localmake "y1 (:y + (((cos (:theta - 30))* :dist) * :k1))
   localmake "x2 (:x + (((sin :theta) * :dist)/2))
   localmake "y2 (:y + (((cos :theta) * :dist)/2))
   localmake "d0 (:dist  * :k1)
   c :x :y (:theta - 30) :d0 1 1 (:depth + 1) :maxd
   d :x1 :y1 (:theta + 30) :d0 1 (:depth + 1) :maxd
   b :x2 :y2 :theta (:dist /2) -1 (:depth + 1) :maxd
end

to c :x :y :theta :dist :rev :flip :depth :maxd
(if (:depth = :maxd)
  [ setxy :x :y seth :theta pd fd :dist ]
  [ (if (:rev = 1)
      [ localmake "x1 (:x +((sin (:theta - (30 * :flip)))* :dist * :k2))
        localmake "y1 (:y +((cos (:theta - (30 * :flip)))* :dist * :k2))
        localmake "x2 (:x1 +(((sin :theta) * :dist)/ 2))
        localmake "y2 (:y1 +(((cos :theta) * :dist)/ 2))
        b :x :y (:theta - (30 * :flip)) (:dist * :k2) 1 (:depth +1)
:maxd
        d :x1 :y1 :theta (:dist / 2) -(:flip) (:depth +1) :maxd
        c :x2 :y2 (:theta +(120 * :flip)) (:dist / 2) -1 -(:flip)
(:depth +1) :maxd ]
      [ localmake "x1 (:x +(((sin (:theta +(120 * :flip))) * :dist)/ 2))
        localmake "y1 (:y +(((cos (:theta +(120 * :flip))) * :dist)/ 2))
        localmake "x2 (:x +(((sin (:theta +(60 * :flip))) * :dist)/ 2))
        localmake "y2 (:y +(((cos (:theta +(60 * :flip))) * :dist)/ 2))
        c :x :y (:theta +(120 * :flip)) (:dist / 2) 1 -(:flip) (:depth +
1) :maxd
        d :x1 :y1 :theta (:dist / 2) :flip (:depth + 1) :maxd
        b :x2 :y2 (:theta - (30 * :flip)) (:dist *(sqrt 3)/ 2) -1
(:depth +1) :maxd ])])
end

to d :x :y :theta :dist :flip :depth :maxd
(if (:depth = :maxd)
  [ setxy :x :y seth :theta pd fd :dist ]
  [ localmake "x1 (:x + ((sin (:theta +(90 * :flip)))* :dist * :k2))
    localmake "y1 (:y + ((cos (:theta +(90 * :flip)))* :dist * :k2))
    localmake "x2 (:x1 + (((sin (:theta +(60 * :flip)))* :dist)/ 2))
    localmake "y2 (:y1 + (((cos (:theta +(60 * :flip)))* :dist)/ 2))
    localmake "x3 (:x2 + (((sin :theta)* :dist)/ 2))
    localmake "y3 (:y2 + (((cos :theta)* :dist)/ 2))
    localmake "x4 (:x3 + (((sin (:theta - (60 * :flip)))* :dist)/ 2))
    localmake "y4 (:y3 + (((cos (:theta - (60 * :flip)))* :dist)/ 2))
    localmake "x5 (:x4 + (((sin (:theta - (120 * :flip)))* :dist)/ 2))
    localmake "y5 (:y4 + (((cos (:theta - (120 * :flip)))* :dist)/ 2))
    localmake "x6 (:x5 + (((sin (:theta - (120 * :flip)))* :dist)/ 2))
    localmake "y6 (:y5 + (((cos (:theta - (120 * :flip)))* :dist)/ 2))
    b :x :y (:theta +(90 * :flip)) (:dist * :k2) 1 (:depth +1) :maxd
    a :x1 :y1 (:theta +(60 * :flip)) (:dist / 2) :flip (:depth +1) :maxd
    d :x2 :y2 :theta (:dist / 2) :flip (:depth + 1) :maxd
    a :x3 :y3 (:theta - (60 * :flip)) (:dist / 2) :flip (:depth +1)
:maxd
    a :x4 :y4 (:theta - (120 * :flip)) (:dist / 2) :flip (:depth +1)
:maxd
    a :x5 :y5 (:theta - (120 * :flip)) (:dist / 2) -(:flip) (:depth + 1)
:maxd
    c :x6 :y6 :theta (:dist / 2) -1 -(:flip) (:depth + 1) :maxd ])
end

to flake :radius :maxd
 make "k1 (1 / (2 * sqrt 3))
 make "k2 ((sqrt 3) / 2)
 localmake "r (:radius / 2)
 localmake "x1 ((sin 30) * :r)
 localmake "y1 ((cos 30) * :r)
 localmake "x2 :r
 localmake "y2 0
 localmake "x3 ((sin 150) * :r)
 localmake "y3 ((cos 150) * :r)
 localmake "x4 ((sin 210) * :r)
 localmake "y4 ((cos 210) * :r)
 localmake "x5 -(:r)
 localmake "y5 0
 localmake "x6 ((sin 330) * :r)
 localmake "y6 ((cos 330) * :r)
 cs window ht
 pu
 a :x1 :y1 150 :r -1 1 :maxd
 a :x2 :y2 210 :r -1 1 :maxd
 a :x3 :y3 270 :r -1 1 :maxd
 a :x4 :y4 330 :r -1 1 :maxd
 a :x5 :y5 30 :r -1 1 :maxd
 a :x6 :y6 90 :r -1 1 :maxd
 pu setxy 0 0 fill
end

--------------425A1B403B6A
Content-Type: application/x-zip-compressed; name="flakediag.zip"
Content-Transfer-Encoding: base64
Content-Disposition: inline; filename="flakediag.zip"

<encoded_portion_removed>
AAA=
--------------425A1B403B6A--



Sat, 20 May 2000 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. LOGO-L> logo fractal 2: snowflake

2. Snowflake fractal for MSWLogo (ATTACHMENT) - snow1.lgo (0/1)

3. LOGO-L> Logo fractal 3: flower

4. LOGO-L> logo fractal

5. LOGO-L> What is a Fractal

6. LOGO-L> Dragon Fractal

7. another Logo fractal: flower

8. LOGO-L> animated fractal gifs

9. LOGO-L> octastar fractal

10. LOGO-L> Animated Koch's Fractal

11. LOGO-L> Shortest Fractal

12. LOGO-L> random based hexa fractal

 

 
Powered by phpBB® Forum Software