Ejemplo n.º 1
0
def run():
    clear()
    wireframe()
    view('front')
    linewidth(2)
    n = 6 # number of generations

    # We use the lima module to create six generations of the Koch line
    F = [ Formex(lima("F",{"F":"F*F//F*F"},i,
                      { 'F' : 'fd();', '*' : 'ro(60);', '/' : 'ro(-60);' }),i)
          for i in range(n) ]

    # scale each Formex individually to obtain same length
    sc = [ 3**(-i) for i in range(n) ]
    sz = sc[0]/3.
    F = [F[i].scale(sc[i]) for i in range(n)] 

    # display all lines in one (randomly choosen) of three ways 
    mode = random.randint(3)
    if mode == 0:
        # all on top of each other
        draw([F[i].translate([0,sz*(i-1),0]) for i in range(n)])

    elif mode == 1:
        # one above the other
        draw([F[i].translate([0,sz*n,0]) for i in range(n)])

    else:
        # as radii of an n-pointed star
        draw([F[i].rotate(360.*i/n) for i in range(n)])

    zoomAll()
Ejemplo n.º 2
0
"""Koch line

level = 'beginner'
topics = ['geometry']
techniques = ['colors']

"""

from plugins.lima import lima

wireframe()
linewidth(2)
n = 6 # number of generations

# We use the lima module to create six generations of the Koch line
F = [ Formex(lima("F",{"F":"F*F//F*F"},i,
                  { 'F' : 'fd();', '*' : 'ro(60);', '/' : 'ro(-60);' }),i)
      for i in range(n) ]
# and display them in series
clear()
# scale each Formex individually to obtain same length
sc = [ 3**(-i) for i in range(n) ]
sz = sc[0]/3.

F = [F[i].scale(sc[i]) for i in range(n)] 


mode = random.randint(3)
if mode == 0:
    # on top of each other
    draw([F[i].translate([0,sz*(i-1),0]) for i in range(n)])
Ejemplo n.º 3
0
"""Koch line

level = 'beginner'
topics = ['geometry']
techniques = ['colors']

"""

from plugins.lima import lima

wireframe()
linewidth(2)
n = 6  # number of generations

# We use the lima module to create six generations of the Koch line
F = [Formex(lima("F", {"F": "F*F//F*F"}, i, {"F": "fd();", "*": "ro(60);", "/": "ro(-60);"}), i) for i in range(n)]
# and display them in series
clear()
# scale each Formex individually to obtain same length
sc = [3 ** (-i) for i in range(n)]
sz = sc[0] / 3.0

F = [F[i].scale(sc[i]) for i in range(n)]


mode = random.randint(3)
if mode == 0:
    # on top of each other
    draw([F[i].translate([0, sz * (i - 1), 0]) for i in range(n)])

elif mode == 1: