N
N
Nikolai Sidorenko2014-11-27 22:12:21
Python
Nikolai Sidorenko, 2014-11-27 22:12:21

Determine the time of cloud contact - what's wrong?

265bed0c916747aea8fccff3d3502d95.JPG
Here is the code, where half of the solution is mathematically correct, but the time is incorrect:

from turtle import *
x1, y1, r1, v1 = 32, 34, 3, 3
x2, y2, r2, v2 = -13, 34, 1, 3
t = 0
up()
goto(x1,y1)
a = distance(x2,y2)  #Нахожу дистанцию от центра до центра
done()
t = 0
n = 0
while n == 0:
    if r1 + r2 < a:
       r1 += v1 * t
       r2 += v1 * t
       t += 0.00001
    else
        n = 1

print(t)

You can solve it completely graphically in any way, but nowhere can I find a function that determines that the figures intersect)
t = 0
while False:
    speed(100)
    r1 += v1 * t
    r2 += v2 * t
    up()
    goto(x1,y1)
    down()
    color('#9E9456')
    begin_fill()
    circle(r1)
    end_fill()
    up()
    goto(x2,y2)
    down()
    begin_fill()
    color('#829551')
    circle(r2)
    end_fill()
    t += 0.00001
    if :     #Вставить бы сюда функцию и все
        break

like this (

Answer the question

In order to leave comments, you need to log in

3 answer(s)
R
Rsa97, 2014-11-27
@NSidorov

Distance between centers:
Moment of contact:
Hence:
We substitute the data, we get
And no graphics needed.

X
xmoonlight, 2014-11-27
@xmoonlight

There
are two circles:
If the distance between the centers is less than the sum of the radii:
if (sqrt((x2-x1)^2+(y2-y1)^2)<(r1+r2)) then intersect.

V
Va1ery, 2014-11-30
@Va1ery

Out of respect for the answerers, at least rotate the picture

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question