def bezier_by_line_intersections(bezier, line):
<EOL>assert len(line[:]) == <NUM_LIT:2><EOL>assert line[<NUM_LIT:0>] != line[<NUM_LIT:1>]<EOL>if not any(p != bezier[<NUM_LIT:0>] for p in bezier):<EOL><INDENT>raise ValueError("<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>")<EOL><DEDENT>shifted_bezier = [z - line[<NUM_LIT:0>] for z in bezier]<EOL>shifted_line_end = line[<NUM_LIT:1>] - line[<NUM_LIT:0>]<EOL>line_length = abs(shifted_line_end)<EOL>rotation_matrix = line_length/shifted_line_end<EOL>transformed_bezier = [rotation_matrix*z for z in shifted_bezier]<EOL>transformed_bezier_imag = [p.imag for p in transformed_bezier]<EOL>coeffs_y = bezier2polynomial(transformed_bezier_imag)<EOL>roots_y = list(polyroots01(coeffs_y))  <EOL>transformed_bezier_real = [p.real for p in transformed_bezier]<EOL>intersection_list = []<EOL>for bez_t in set(roots_y):<EOL><INDENT>xval = bezier_point(transformed_bezier_real, bez_t)<EOL>if <NUM_LIT:0> <= xval <= line_length:<EOL><INDENT>line_t = xval/line_length<EOL>intersection_list.append((bez_t, line_t))<EOL><DEDENT><DEDENT>return intersection_list<EOL>
Returns tuples (t1,t2) such that bezier.point(t1) ~= line.point(t2).