Intersecting two circles using vectors

990 Views Asked by At

I'm trying to programmatically find the intersection points of two circles with different radii. Solving their equotations would be an option, but I thought of using vectors to do so.

Assuming I have two circles A and B (A, B as center, $r_1$, $r_2$ as radii), $\overrightarrow{AB}$ as direction vector of their straight, $E_A$ as endpoint of circle A, $E_B$ as endpoint of circle B. I can get the length $l$ between the two endpoints. The intersection points are on the normale of $V_{direction}$, starting from point X. $$ A = \bigg(\begin{array}(u\\v\end{array}\bigg); B = \bigg(\begin{array}(x\\y\end{array}\bigg); r_1 = k; r_2 = m \\ \overrightarrow{AB} = \overrightarrow{B} - \overrightarrow{A} \\ \overrightarrow{V_{direction}} = \overrightarrow{AB^0} \\ \overrightarrow{E_{A}} = \overrightarrow{A} + r_1\cdot\overrightarrow{V_{direction}} \\ \overrightarrow{E_{B}} = \overrightarrow{B} - r_2\cdot\overrightarrow{V_{direction}} \\ \overrightarrow{D} = \overrightarrow{E_{B}} - \overrightarrow{E_{A}} \\ l = |\overrightarrow{D}| \\ \overrightarrow{X} = \overrightarrow{E_A} + l \cdot factor \cdot \overrightarrow{V_{direction}} $$

If both circles had the same radius, X would be located in the center between Ea and Eb. In my case, I used $A = (350 ; 350), B = (150 ; 200), r_1 = 175, r_2 = 125$. X was about X = (226.326 ; 257.245). After thinking about it, I came up with the idea, that X has to be located at (r2/r1)*l.

But $(r_2/r_1) = (125/175) = 0.7142857142857143$, I measured a relation of $0.6896173016811695$.

Red cross = $\overrightarrow{E_B} + \overrightarrow{V_{direction}}*(r_2/r_1)*l$, green cross = correct point of intersection

enter image description here

My question:

How do the radii correlate to splitting the straight $[E_AE_B]$?

1

There are 1 best solutions below

5
On BEST ANSWER

Rotate the coordinates so that $A$ is located at the origin and $B$ is located at $(\ell, 0)$. This simplifies the system of equations to

$$\left\{\begin{array}{l}x^2 + y^2 = r_1^2 \\ (x-\ell)^2 + y^2 = r_2^2\end{array}\right.$$

Subtracting, we obtain

$$2 x \ell - \ell^2 = r_1^2 - r_2^2;$$

solving,

$$x = \frac{r_1^2 - r_2^2 + \ell^2}{2 \ell}.$$

Since you asked about thinking of this as a fraction of the distance along the line segment $\overline{AB}$, that fraction is not $(r_2/r_1)$ but rather

$$\rho := \frac{x}{\ell} = \frac{r_1^2 - r_2^2 + \ell^2}{2 \ell^2} = \frac{1}{2}\left[\left(\frac{r_1}{\ell}\right)^2 - \left(\frac{r_2}{\ell}\right)^2 + 1\right]$$