Snowflakes in the Ice Help


#1

Stuck on the snowflake portion of Snowflakes in the Ice. The first rotation works fine, but I can’t get it to do the rest of the rotations. My code is

def flake(start, end):
    # To create a hexagonal flake we need to create 6 line fractals rotated by 60 degrees each time.
    side = Vector.subtract(end, start)
    a = start
    b = end
    for i in range(6):
        line(a, b)
        # To get the next edge, we need to rotate the side 60 degrees.
        rotation = Vector.rotate(side, degreesToRadians(60))
        # Now need to reset a and b with the beginning and end points for the new side.
        a = b
        b = Vector.add(rotation, a)`

Obviously I have to use the i variable somewhere, but for the life of me I cannot figure out how or where. I know correct code isn’t given out on the forums, but can someone give me a hint?


#2

Nevermind, I got it. Feel free to lock or delete the thread.


#3

@BigPanda71 - Hi, Can you advice on where I am getting wrong. I am stuck at rotating and re-initiating the line for making the sides of the hexagon.

my hexagon definition code
def flake(start, end):
    #flake(Vector(64, 52), Vector(52, 52))
    # To create a hexagonal flake we need to create 6 line fractals rotated by 60 degrees each time.
    side = Vector.subtract(end, start)
    a = start
    b = end
    for i in range(6):
        line(a, b)
        # To get the next edge, we need to rotate the side 60 degrees.
        side = Vector.rotate(side, degreesToRadians(60))
        # Now need to reset a and b with the beginning and end points for the new side.
        a = b
        b = side.y