Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 7 additions & 11 deletions code/polygon.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,13 @@ def arc(t, r, angle):
r: radius
angle: angle subtended by the arc, in degrees
"""
arc_length = 2 * math.pi * r * abs(angle) / 360
n = int(arc_length / 4) + 3
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)

resolution = 69
total_circumference = 2 * math.pi * r #circumference of a circle with same radius as the arc
segment_length = total_circumference/ resolution
LT_angle = 360/resolution
ratio = angle/360 #ratio that the arc is of a circle with the same radius as the arc
resolution = int(resolution * ratio)
polyline(t, resolution, segment_length, LT_angle)

def circle(t, r):
"""Draws a circle with the given radius.
Expand Down