LOGO-L> logo fractal 2: snowflake 
Author Message
 LOGO-L> logo fractal 2: snowflake

------ =_NextPart_000_01BCFE8A.A298DC00
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit

Here is another set of routines which produce a space-filling curve in Logo.
Again, the pattern fills a regular hexagon. I think this pattern looks better
than the first because 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...

This time, I am including the source code as text. The included zip file
is a .bmp image of the individual patterns a, b, c, and d. They are a little
more complicated than the patterns for the previous fractal.

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

------ =_NextPart_000_01BCFE8A.A298DC00
Content-Type: application/x-zip-compressed; name="flakediag.zip"
Content-Transfer-Encoding: base64

<encoded_portion_removed>
AABPCwAAAAA=

------ =_NextPart_000_01BCFE8A.A298DC00--

---------------------------------------------------------------





Fri, 19 May 2000 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. logo fractal: snowflake

2. LOGO-L> Logo fractal 3: flower

3. LOGO-L> logo fractal

4. LOGO-L> Apple logo/MSW Logo

5. LOGO-L> Reseach Machines Logo (RM LOGO)

6. LOGO-L> What is a Fractal

7. LOGO-L> Dragon Fractal

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