polygon.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:Python_Learning 作者: mafanhe 项目源码 文件源码
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
    t.lt(step_angle/2)
    polyline(t, n, step_length, step_angle)
    t.rt(step_angle/2)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号