def transform(curve, tf):
def to_point(p):<EOL><INDENT>return np.array([[p.real], [p.imag], [<NUM_LIT:1.0>]])<EOL><DEDENT>def to_vector(z):<EOL><INDENT>return np.array([[z.real], [z.imag], [<NUM_LIT:0.0>]])<EOL><DEDENT>def to_complex(v):<EOL><INDENT>return v.item(<NUM_LIT:0>) + <NUM_LIT> * v.item(<NUM_LIT:1>)<EOL><DEDENT>if isinstance(curve, Path):<EOL><INDENT>return Path(*[transform(segment, tf) for segment in curve])<EOL><DEDENT>elif is_bezier_segment(curve):<EOL><INDENT>return bpoints2bezier([to_complex(tf.dot(to_point(p)))<EOL>for p in curve.bpoints()])<EOL><DEDENT>elif isinstance(curve, Arc):<EOL><INDENT>new_start = to_complex(tf.dot(to_point(curve.start)))<EOL>new_end = to_complex(tf.dot(to_point(curve.end)))<EOL>new_radius = to_complex(tf.dot(to_vector(curve.radius)))<EOL>return Arc(new_start, radius=new_radius, rotation=curve.rotation,<EOL>large_arc=curve.large_arc, sweep=curve.sweep, end=new_end)<EOL><DEDENT>else:<EOL><INDENT>raise TypeError("<STR_LIT>"<EOL>"<STR_LIT>")<EOL><DEDENT>
Transforms the curve by the homogeneous transformation matrix tf