Star Fractal

Star Fractal preview image

1 collaborator

Uri_dolphin3 Uri Wilensky (Author)

Tags

mathematics 

Tagged by Reuven M. Lerner about 9 years ago

Model group CCL | Visible to everyone | Changeable by group members (CCL)
Model was written in NetLogo 5.0.4 • Viewed 239 times • Downloaded 25 times • Run 0 times
Download the 'Star Fractal' modelDownload this modelEmbed this model

Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)


WHAT IS IT?

This model creates a fractal-like structure consisting of stars drawn at various scales, the number of which is specified by the user. The structure is drawn by generations of turtles that draw stars at a given scale and hatch successive generations to draw new ones at smaller scales.

HOW TO USE IT

The FRACTAL-LEVEL slider controls the number of levels the structure is drawn in. For instance, a fractal level of 0 results in a single star, while a fractal level of 1 draws a star with smaller stars that begin at each of its 5 corners. This pattern is repeated as the level increases.

Click the SETUP button to initialize the structure and GO to begin drawing it.

THINGS TO NOTICE

The figure drawn embodies the most important fractal quality: self-similar structure at smaller scales. This means that no matter how far you "zoom in" to it, you will still see the same shape (namely, a star). The fractal level determines to how small a scale this property holds, so the greater the level the more you can "zoom in" and still see stars.

Notice that at a fractal level greater than 1, the model begins with one turtle, which hatches new turtles at each corner, and these turtles similarly hatch new ones at each of their corners as well. This behavior is made possible by a powerful mathematical technique called recursion. A process is called recursive when its workings involve "performing itself". In this case, the process performed by each turtle at each step is to draw a new side of its star and then create new turtles to perform the very same process. A helpful property of recursive processes is that the instructions are often short, because each performer is executing the same instructions. Hence the brevity of Star Fractal's procedures.

The ideas behind fractal scaling (the property of self-similar structures at different scales) and recursion are essentially the same. This is suggested by the fact that a recursive process is able to generate a fractal-like structure, as in this model. One way to think about it is that recursion applies these ideas to processes (like NetLogo models), and fractal scaling applies them to physical or mathematical structures (like the figure drawn by Star Fractal).

THINGS TO TRY

Edit GO so that it's not a forever button, and/or use the speed slider to slow the model down, and note what happens during each tick. Notice that what begins as a single drawing multiplies into many drawings, each of which is at a smaller scale but proceeds exactly like the larger one that spawned it. Thus, recursion begets self-sameness at different scales.

Try the model initially with small fractal levels and work your way up to higher ones. Try to figure out how many more stars are incorporated into the figure each time the level increases by one. What kind of general rule you can come up with? That is, given a generation of turtles g, how many turtles will be in the generation g + 1? Start from g = 0. (This is a recursive rule.)

EXTENDING THE MODEL

In increasing order of difficulty:

Change the color scaling so that the smaller stars are brighter than the larger ones.

Change the model so that it draws shapes other than stars. Will any shape work?

The structure that this model draws is only "fractal-like", because even when you "zoom in" and look at smaller scales, the smaller stars aren't actually part of the larger ones; they're just connected to them at a vertex. An important property of fractals is that the larger structures are composed of the smaller ones, something which clearly doesn't hold here. For a tougher exercise, try changing the model so that the smaller stars (or whatever shapes are being drawn) are actually part of the larger ones, for instance by drawing them in the middle of their sides. Such a figure will be a lot less "noisy" than this one, in terms of how difficult it is to discern individual stars, and it will have different properties when you zoom in.

NETLOGO FEATURES

This model makes use of an important NetLogo command: hatch. hatch allows one turtle to create a new one on the same patch and give it some initial instructions. In this case, the parent turtle sets the length of the star its offspring will draw, its initial heading, and several other variables. Notice that the new turtle uses the values of its parent turtle's variables in the body of the hatch procedure.

Another useful primitive this model uses is scale-color. It is used to make the brightness of the color the turtles are drawing inversely proportional to the turtle's generation, so that larger stars are brighter than smaller ones (this was done to make the larger ones more visible). This code:

scale-color red (fractal-level - generation) -1 (fractal-level + 1)

works as follows: Subtract the value of generation from that of fractal-level. The higher that resulting value is on the scale from -1 to (fractal-level + 1), the darker the shade of red the turtle will draw with.

HOW TO CITE

If you mention this model in a publication, we ask that you include these citations for the model itself and for the NetLogo software:

  • Wilensky, U. (1999). NetLogo Star Fractal model. http://ccl.northwestern.edu/netlogo/models/StarFractal. Center for Connected Learning and Computer-Based Modeling, Northwestern Institute on Complex Systems, Northwestern University, Evanston, IL.
  • Wilensky, U. (1999). NetLogo. http://ccl.northwestern.edu/netlogo/. Center for Connected Learning and Computer-Based Modeling, Northwestern Institute on Complex Systems, Northwestern University, Evanston, IL.

COPYRIGHT AND LICENSE

Copyright 1999 Uri Wilensky.

CC BY-NC-SA 3.0

This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/3.0/ or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.

Commercial licenses are also available. To inquire about commercial licenses, please contact Uri Wilensky at uri@northwestern.edu.

This model was created as part of the project: CONNECTED MATHEMATICS: MAKING SENSE OF COMPLEX PHENOMENA THROUGH BUILDING OBJECT-BASED PARALLEL MODELS (OBPML). The project gratefully acknowledges the support of the National Science Foundation (Applications of Advanced Technologies Program) -- grant numbers RED #9552950 and REC #9632612.

This model was converted to NetLogo as part of the projects: PARTICIPATORY SIMULATIONS: NETWORK-BASED DESIGN FOR SYSTEMS LEARNING IN CLASSROOMS and/or INTEGRATED SIMULATION AND MODELING ENVIRONMENT. The project gratefully acknowledges the support of the National Science Foundation (REPP & ROLE programs) -- grant numbers REC #9814682 and REC-0126227. Converted from StarLogoT to NetLogo, 2001.

Comments and Questions

Please start the discussion about this model! (You'll first need to log in.)

Click to Run Model

turtles-own [
  moves         ;; how many sides the turtles has drawn so far
  star-side     ;; The length of the side that the turtle is drawing
  generation    ;; How many generations of turtles have come before it.  So,
]               ;; if the turtle was hatched from a turtle that was hatched
                ;; by another turtle, it's generation is 2

to setup
  clear-all
  crt 1 [
    set size 8                    ;; so turtles are easy to see
    set ycor max-pycor * 0.9      ;; place near top of world
    set star-side ycor * 1.97538  ;; length of the sides of the star it will draw
    pen-down
    set heading 180 + 18
    recolor
  ]
  reset-ticks
end 

to go
  if not any? turtles [ stop ]
  ask turtles [
    fd star-side
    rt 180 + 36
    if generation < fractal-level [      ;; If it's not drawing at the deepest level of the figure,
      hatch 1 [                          ;;  hatch a new turtle to draw at a lower level
        set generation generation + 1
        set star-side star-side / 2
        recolor
        set moves 0
        rt 18
      ]
    ]
    set moves moves + 1
    if moves > 5 [ die ]        ;; When the turtle has completed its star, it's done
  ]
  tick
end 

to recolor  ;; turtle procedure
  set color scale-color red (fractal-level - generation) -1 (fractal-level + 1)
end 


; Copyright 1999 Uri Wilensky.
; See Info tab for full copyright and license.

There are 10 versions of this model.

Uploaded by When Description Download
Uri Wilensky over 9 years ago Updated to NetLogo 5.0.4 Download this version
Uri Wilensky almost 10 years ago Updated version tag Download this version
Uri Wilensky almost 10 years ago Updated to version from NetLogo 5.0.3 distribution Download this version
Uri Wilensky over 10 years ago Updated to NetLogo 5.0 Download this version
Uri Wilensky over 12 years ago Updated from NetLogo 4.1 Download this version
Uri Wilensky over 12 years ago Updated from NetLogo 4.1 Download this version
Uri Wilensky over 12 years ago Updated from NetLogo 4.1 Download this version
Uri Wilensky over 12 years ago Updated from NetLogo 4.1 Download this version
Uri Wilensky over 12 years ago Model from NetLogo distribution Download this version
Uri Wilensky over 12 years ago Star Fractal Download this version

Attached files

File Type Description Last updated
Star Fractal.png preview Preview for 'Star Fractal' over 9 years ago, by Uri Wilensky Download

This model does not have any ancestors.

This model does not have any descendants.