########## # Task 1 # ########## def connect_ends(curve1, curve2): x1,y1,x2,y2 = x_of(curve1(1)),y_of(curve1(1)),x_of(curve2(0)),y_of(curve2(0)) x,y = x1 - x2, y1 - y2 return connect_rigidly(curve1,translate(x,y)(curve2)) ########## # Task 2 # ########## def show_points_gosper(level, num_points,initial_curve): return draw_points(num_points, squeeze_curve_to_rect (-0.5, -0.5, 1.5, 1.5)(repeated(gosperize,level)(initial_curve) )) ########## # Task 3 # ########## def your_gosper_curve_with_angle(level, angle_at_level): if level == 0: return unit_line else: return your_gosperize_with_angle(angle_at_level(level))(your_gosper_curve_with_angle(level-1, angle_at_level)) def your_gosperize_with_angle(theta): def inner_gosperize(curve_fn): return put_in_standard_position(connect_ends( rotate(theta)(curve_fn), rotate(-theta)(curve_fn))) return inner_gosperize