0
$\begingroup$

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]$?

$\endgroup$

1 Answer 1

0
$\begingroup$

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]$$

$\endgroup$
5
  • $\begingroup$ Seems quite logical. I tried using your formula for p, but it seems that I might have a mistake, using my values in the formula returns the same as $1 / (1 - (r1/r2))$. Using your formula for $r1=175, r2=125, l=50, I get p = 3.5; 1/3.5 = 0.28....; 1 - (1/3.5) = 0.72....; 1 / (1 - 1/3.5) = 1.4 = r1/r2$ $\endgroup$
    – michaeln
    Commented Aug 23, 2014 at 12:23
  • $\begingroup$ Oh, I guess I'm using $\ell$ to mean something different from what you had above. Let me change some variable names. $\endgroup$ Commented Aug 23, 2014 at 12:39
  • $\begingroup$ I'd appreciate that. $\endgroup$
    – michaeln
    Commented Aug 23, 2014 at 13:18
  • $\begingroup$ It'll have to wait a day or so. You can do it yourself if you want: I wrote $\ell$ for the distance between $A$ and $B$. In those terms, the distance between $E_A$ and $E_B$ (which is what you're calling $l$) is $$\ell - (\ell - r_1) - (\ell - r_2) = r_1 + r_2 - \ell.$$ $\endgroup$ Commented Aug 23, 2014 at 13:46
  • $\begingroup$ Alright, using your $l$ it works quite good now, although I seem to have some rounding errors, but it works for now, thank you! $\endgroup$
    – michaeln
    Commented Aug 23, 2014 at 14:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .