Answer the question
In order to leave comments, you need to log in
Determine the time of cloud contact - what's wrong?
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)
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
Answer the question
In order to leave comments, you need to log in
Distance between centers:
Moment of contact:
Hence:
We substitute the data, we get
And no graphics needed.
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.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question