I've been trying to write a function that would graph a circle.I tried using the distance formula in order to calculate my points:
def distance_form(x1, y1, x2, y2):
d = sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2)
return d
That didn't work, so I took a look at someone else's code for a circle.Here it is:
def circle(page, radius, g, h):
for x in range(g, g + radius):
y = h + (math.sqrt(radius ** 2 - ((x - g) ** 2)))
plot(page, x, y)
plot(page, x, 2 * h - y)
plot(page, 2 * g - x, y)
plot(page, 2 * g - x, 2 * h - y)
I'm decent at math, but I'm not really sure what this means.