p = .1
r = 40
t_e = sqrt(p^2+1)/r
x = copy(p)
y = 1
t = 0
d = 0.0001
dogPoints = [(x,y)]
for i in [0..(1/d)]:
x_1 = x + (r*d*(t-x)/(sqrt((t-x)^2+y^2)))
y_1 = y + (r*d*(-y)/(sqrt((t-x)^2+y^2)))
t = t + d
dogPoints = dogPoints + [(x_1,y_1)]
x = copy(x_1)
y = copy(y_1)
if sqrt(y^2+(x-t)^2) <= .001:
stop = x
break
show(point(dogPoints) + plot(1, (x,0,1)) + point((t_e,0), color='red', marker="D"), xmin=0, xmax=1, ymin=0, ymax=1)
print "p=",p
print "r=",r
print "t_{expected}=",t_e
print "t_{computer}=",stop