[Tutor] Using trigonometry to draw a circle

Phil phillor9 at gmail.com
Tue May 18 03:21:54 EDT 2021


While this question is not exactly Python related, I'm trying to 
understand how I can incorporate trig functions into Python code.

Take for example a circle.

radius = 60
x_centre = 100
y_centre = 100

for angle in range(0,45):
     x = math.cos(angle) * radius + x_centre
     y = math.sin(angle) * radius + y_centre
     plot(x, y)

Increasing the steps in the range function adds more points to the 
circle, but still draws a full circle. How would I draw part of a circle 
by giving a function the starting and ending angles along the circumference?

I spent most of the afternoon searching the Internet for an answer and, 
while I found many articles on unit circles, I couldn't find the answer 
I was looking for.

-- 
Regards,
Phil



More information about the Tutor mailing list