koch-island


Information

Created with NetLogo version NetLogo 3.0
Running with NetLogoLite.jar version 302.


WHAT IS IT?


-------
A short model to draw a koch island
COPYRIGHT & LICENSE
---------------
Copyright (C) 2005 James P. Steiner, Some Rights Reserved.
This work is licensed under the Creative Commons
Attribution-NonCommercial-ShareAlike License.
To view a copy of this license, visit
http://creativecommons.org/licenses/by-nc-sa/2.0/
or send a letter to
Creative Commons
559 Nathan Abbott Way
Stanford, California 94305, USA

Procedures

NetLogo Version: NetLogo 3.0

;; SUMMARY
;;;;  A Koch Island fractal is drawn.
;; COPYRIGHT & LICENSE
;;;; Copyright (C) 2005 James P. Steiner
;;;; Some Rights Reserved.
;;;; Creative Commons Attribution-NonCommercial-ShareAlike License v. 2.0.
;;;; Visit http://creativecommons.org/licenses/by-nc-sa/2.0/ for more information.
;; APPLET DIMENSIONS (width x height)
;;;; 710 x 550
;;
globals
[ step
  steps
]

to setup
   ca
end

to go
   do-koch-island line-color
end

to do-koch-island [ hue ]
     ; island-size is a slider
     ; island-freq is a slider
     set steps screen-edge-x * (island-size * .01) * sqrt 3
     set step 1 / (screen-size-x * 3 / sqrt 3)
     create-turtles 1
     ask turtle 0
     [
       ;; position turtle so that island will be centered
       home
       set heading 0
       jump steps / sqrt 3
       ;; why sqrt 3? check back with your geometry, and the properties of 30/60/90 triangles!
       rt 150 ;; think 180 - 30
       set color hue
       pd ;; draws lines on the drawing layer
       koch-island steps island-freq
       pu
       ;; mark the starting/ending spot
       ;; set color white
       die
     ]
end

to koch-island [ isle-size isle-level ]
     repeat 3
     [ k-side isle-size isle-level
       rt 120
     ]
end

to k-side [ side-size side-level ]
     ifelse side-level = 0
     [ jump side-size ]
     [ set side-size side-size / 3 ; local copies of inputs can be changed!
       set side-level side-level - 1
       k-side side-size side-level   lt 60
       k-side side-size side-level   rt 120
       k-side side-size side-level   lt 60
       k-side side-size side-level
     ]
end



                    


Download Link

View or download the complete model file (to download: right-click, save-link-as):
-- Download koch-island --