def segment_length(curve, start, end, start_point, end_point,<EOL>error=LENGTH_ERROR, min_depth=LENGTH_MIN_DEPTH, depth=<NUM_LIT:0>):
mid = (start + end)/<NUM_LIT:2><EOL>mid_point = curve.point(mid)<EOL>length = abs(end_point - start_point)<EOL>first_half = abs(mid_point - start_point)<EOL>second_half = abs(end_point - mid_point)<EOL>length2 = first_half + second_half<EOL>if (length2 - length > error) or (depth < min_depth):<EOL><INDENT>depth += <NUM_LIT:1><EOL>return (segment_length(curve, start, mid, start_point, mid_point,<EOL>error, min_depth, depth) +<EOL>segment_length(curve, mid, end, mid_point, end_point,<EOL>error, min_depth, depth))<EOL><DEDENT>return length2<EOL>
Recursively approximates the length by straight lines