In Exercise 4.1(c) in Section 4.12 (Chapter 4) of Python for Software Design it is claimed that the following version of function arc()
,
def arc(t, r, angle):
"""Draws an arc with the given radius and angle.
t: Turtle
r: radius
angle: angle subtended by the arc, in degrees
"""
arc_length = 2 * math.pi * r * abs(angle) / 360
n = int(arc_length / 4) + 1
step_length = arc_length / n
step_angle = float(angle) / n
# making a slight left turn before starting reduces
# the error caused by the linear approximation of the arc
lt(t, step_angle/2)
polyline(t, n, step_length, step_angle)
rt(t, step_angle/2)
is "better" than the original one from Section 4.7:
def arc(t, r, angle):
arc_length = 2 * math.pi * r * angle / 360
n = int(arc_length / 3) + 1
step_length = arc_length / n
step_angle = float(angle) / n
polyline(t, n, step_length, step_angle)
(You can look up the code of subroutines, such as polyline()
, here).
I'm trying to understand why the former version is better, in particular, by which metric. How can we define the true circle we are approximating? Any ideas?