How can I play with a turtle and how can I use a turtle?
I have trouble getting the thing to work as in the picture shown below (ignore the colors).
from turtle import * from math import * def formulaX(R, r, p, t): x = (R-r)*cos(t) - (r + p)*cos((R-r)/r*t) def formulaY(R, r, p, t): y = (R-r)*sin(t) - (r + p)*sin((R-r)/r*t) def t_iterating(R, r, p): t = 2*pi up() goto(formulaX, formulaY) down() while (True): t = t + 0.01 formulaX(R, r, p, t) formulaY(R, r, p, t) def main(): R = int(input("The radius of the fixed circle: ")) r = int(input("The radius of the moving circle: ")) p = int(input("The offset of the pen point, between <10 - 100>: ")) if p < 10 or p > 100: input("Incorrect value for p!") t_iterating(R, r, p) input("Hit enter to close...") main()'
I am trying to make that kind of shape. Here is the coding I have done so far.
Advertisement
Answer
Try changing your t_iterating
function to this:
def t_iterating(R, r, p): t = 2*pi # It seems odd to me to start from 2*pi rather than 0. down() while t < 20*pi: # This loops while t goes from 2*pi to 20*pi. t = t+0.01 goto(formulaX(R, r, p, t), formulaY(R, r, p, t)) up()