How much displacement of x and y to satisfy a given value

45 Views Asked by At

Consider two circles $C_1((x,y),r)$ and $C_2((x_1,y_1),R)$

the two circles insects when the distance $d=\sqrt{(x-x_1)^2+(y-y_1)^2}$ between the two circles is less than $d < r+R$

I want to know how much I should move $C_1$ by $(d_x ,d_y)$ away/ towards $C_2$ to satisfy the distance $d= m*(r+R)$ where $m \in [0,1.0]$

In other ways, I want the intersection between $C_1$ an $C_2$ to be 20% or 30% and so on, which means $d$ should be equal to $d=(1-\text{percentage})*(r +R)$

Example

$C_1((2,2),1)$ and $C_2((4,2),2)$ so the distance $d=2 < 1_r+2_R$ so in order to satisfy 20% intersection $C_2$ should move $d_x=0.4$ to point $(4.4,2)$ which gives $d=2.4 < 3$ but $2.4/3$ = $0.8$

Hope this example clarify what I want

Thank you in advance for the help

1

There are 1 best solutions below

1
On BEST ANSWER

The distance between circles $C_1:((x_1,y_1), r_1)$ and $C_2:((x_2,y_2), r_2)$, as you said, is: $$d=\sqrt{(x_2-x_1)^2+(y_2-y_1)^2}$$ You need $(d_x,d_y)$ such that $$d_{new}=\sqrt{(x_2 + d_x - x_1)^2+(y_2 + d_y - y_1)^2} = m (r+R)$$ for a given $m\in[0,1]$. Equivalently: $$(x_2 + d_x - x_1)^2+(y_2 + d_y - y_1)^2 = m^2 (r+R)^2$$ From there, you can obtain: $$(x_2 - x_1)^2 + d_x^2 + 2d_x(x_2-x_1) + (y_2 - y_1)^2 + d_y^2 + 2d_y(y_2-y_1) = m^2 (r+R)^2;$$ that is, $$d_x^2 + d_y^2 + 2d_x(x_2-x_1) + 2d_y(y_2-y_1) = m^2 (r+R)^2 - d^2.$$

Now, from what you said, I understand that the circles have to be moved along the line that initially joins their centers. For that reason, $$\frac{dy}{dx} = \frac{y_2-y_1}{x_2-x_1}.$$ Replacing this in the expression above, we have $$d_x^2 \left(1+ \frac{y_2-y_1}{x_2-x_1}\right)^2 + 2d_x\left(x_2-x_1 + \frac{(y_2-y_1)^2}{x_2-x_1}\right) = m^2 (r+R)^2 - d^2.$$ That is a second order equation for $d_x$ I assume you can solve.

Of course, the above is for $x_2\ne x_1$. But it can easily be adjusted for the case $x_1=x_2$.

In the particular case of your example, you get the equation $$d_x^2 + 4d_x = 0.8^2\cdot 9 - 4,$$ which gives the solutions $d_x=0.4$ (the one you got) and $d_x=-4.4$, the symmetric case in the other direction. The corresponding $d_y$ is 0 in both cases.