[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

LOGO-L> Seirpinski's Carpet



Thanks, Olga, for making your students' websites available to us.
I am teaching pre-service teachers and this semester we are exploring
fractals using Hans Laurewerier's book: Fractals. By the way, does
anyone know the proper pronunciation of his last name?  We are using
PC Logo2 and after looking at the Seirpinski triangle developed by
Alex, I used his approach for the Seirpinski carpet.  It works best
if the side length is a multiple of three to the power of the highest
level.  I also found that the highest level I can display is 5.
to sq_seirp
     window setpc 0
     pu setxy [ -200 -190] pd
     print [input the side length and recursion level
     make "side read
     make "level read
     fs
     carpet :side :level
     carpetfill :side :level
end

to carpet :side :level
     if :level < 1 [stop]
     repeat 4 [ carpet :side/3 :level-1 fd :side/3 /
         carpet :side/3 :level-1 fd 2*:side/3 rt 90]     
end

to carpetfill :side :level
      if :level < 2 [stop]  
      if :level = 2 [setpc 9]
      if :level = 3 [setpc 12]
      if :level = 4 [setpc 10]
      if :level = 5 [setpc 14]
      pu rt 45 fd 2*(:side/3) pd fill pu bk 2*(:side/3) lt 45 
      fd :side/3  
      carpetfill :side/3 :level-1
      fd :side/3 
      carpetfill :side/3 :level-1
      fd :side/3  rt 90 fd :side/3
      carpetfill :side/3 :level-1
      fd :side/3 
      carpetfill :side/3 :level-1
      fd :side/3 rt 90 fd :side/3
      carpetfill :side/3 :level-1
      fd :side/3  
      carpetfill :side/3 :level-1
      fd :side/3 rt 90 fd :side/3
      carpetfill :side/3 :level-1
      fd :side/3
      fd :side/3 rt 90
     carpetfill :side/3 :level-1    
end

---------------------------------------------------------------
Please post messages to the Logo forum to logo-l@gsn.org.  Mail
questions about the list administration to logofdn@gsn.org.  To
unsubscribe send    unsubscribe logo-l    to majordomo@gsn.org.



Global SchoolNet Foundation - Linking Kids Around the World!
Copyright GSN - All Rights Reserved - Comments & Questions
Visit GSN's Global Schoolhouse for more exciting learning resources!
Search our Site - Home