def bezier_radialrange(seg, origin, return_all_global_extrema=False):
def _radius(tau):<EOL><INDENT>return abs(seg.point(tau) - origin)<EOL><DEDENT>shifted_seg_poly = seg.poly() - origin<EOL>r_squared = real(shifted_seg_poly) ** <NUM_LIT:2> +imag(shifted_seg_poly) ** <NUM_LIT:2><EOL>extremizers = [<NUM_LIT:0>, <NUM_LIT:1>] + polyroots01(r_squared.deriv())<EOL>extrema = [(_radius(t), t) for t in extremizers]<EOL>if return_all_global_extrema:<EOL><INDENT>raise NotImplementedError<EOL><DEDENT>else:<EOL><INDENT>seg_global_min = min(extrema, key=itemgetter(<NUM_LIT:0>))<EOL>seg_global_max = max(extrema, key=itemgetter(<NUM_LIT:0>))<EOL>return seg_global_min, seg_global_max<EOL><DEDENT>
returns the tuples (d_min, t_min) and (d_max, t_max) which minimize and
    maximize, respectively, the distance d = |self.point(t)-origin|.
    return_all_global_extrema:  Multiple such t_min or t_max values can exist.
    By default, this will only return one. Set return_all_global_extrema=True
    to return all such global extrema.