Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

Controlling Speed of a Moving Canvas

Hi all,

I have a script that practically create a circle and move it in a certain angle.

import numpy

my_canvas   = canvas()
BigR            = 150
SmallR          = BigR*5/6
xTiny0      = 0.01
yTiny0      = SmallR+((BigR-SmallR)/2)
RTiny       = (BigR-SmallR)/1.5
RES         = 200 # step resolution
TIME        =1# seconds
R           = yTiny0 # Circle radius

def move_by_angle(origin, angle, r):

    alpha = numpy.arctan(origin[1] / origin[0])
    angle_step = angle/RES

    path = []
    for point in range(0, RES):
        beta = alpha + point*angle_step
        path.append ([r*numpy.sin(beta), r*numpy.cos(beta)])
    return path


start = [yTiny0,xTiny0] * R
angle = numpy.pi*-0.5
path = move_by_angle(start, angle, R)

for step in range(0, RES):
    xTiny0, yTiny0 = path[step][0], path[step][1]
    TinyCircle = my_canvas.circle(xTiny0, yTiny0, RTiny, fill=True, color= '#404040')
    my_canvas.show()
    my_canvas.clear()

Though it works, my limited experience with programming is facing me with a problem. My problem is that the moving circle has sort of "innate speed"; it seems like the last "for" loop enforce the circle a speed that i'm not sure how to control. My goal is to determine or measure the speed and to change it according to a certain radius or angle.

Can anyone help me with that?

Thanks

Comments

Sign In or Register to comment.