Find the intersection between two lines in a polar notation

1.1k Views Asked by At

I've a polar chart in an application, which displays a curve: enter image description here

I would like to add a functionality when I click on the plot.

When I click(at the point M here), I know the orientation and amplitude of:

  • CA(and CA')
  • CB(and CB')
  • CM

For the functionality I required, I need to get the amplitude of CX(and CX')(I already have the orientation, which the same that of CM.

I can imagine finding this with a lot of cos and sin, but what would be the easiest way to make it(which should works in every quadrant of the chart)?

I'm sure there should be some kind of geometric computation that I can do, but I can't find it.

1

There are 1 best solutions below

1
On

I'd write your points as complex numbers for the moment, since that avoids all those vectors and trigonometric functions all over the place. So you have

$$ z_A=r_Ae^{i\varphi_A}\qquad z_B=r_Be^{i\varphi_B}\qquad z_M=r_Me^{i\varphi_M}\qquad z_X=r_Xe^{i\varphi_M} $$

So you want to find $r_X\in\mathbb R$ based on the additional constraint that $z_A,z_B,z_X$ are collinear, which you can express as

$$\frac{z_X-z_A}{z_B-z_A}\in\mathbb R$$

A number is real if it is equal to its own complex conjugate, so you get

\begin{align*} (z_X-z_A)(\bar z_B-\bar z_A)&=(\bar z_X-\bar z_A)(z_B-z_A) \\ z_X\bar z_B - z_A\bar z_B - z_X\bar z_A&=\bar z_Xz_B-\bar z_Az_B-\bar z_Xz_A \\ r_Xe^{i\varphi_M}(\bar z_B-\bar z_A) - z_A\bar z_B&= r_Xe^{-i\varphi_M}(z_B-z_A) - \bar z_Az_B \\ r_X\bigl(e^{i\varphi_M}(\bar z_B-\bar z_A)-e^{-i\varphi_M}(z_B-z_A)\bigr) &= z_A\bar z_B - \bar z_Az_B \\ r_X &= \frac{z_A\bar z_B - \bar z_Az_B} {e^{i\varphi_M}(\bar z_B-\bar z_A)-e^{-i\varphi_M}(z_B-z_A)} \end{align*}

Both numerator and denominator are the difference between a complex number and its complex conjugate. Since $(a+ib)-(a-ib)=2ib$, both are purely imaginary numbers, so their quotient is real. You could also formulate this in terms of imaginary parts:

$$ r_X = \frac{\operatorname{Im}\bigl(z_A\bar z_B\bigr)} {\operatorname{Im}\bigl(e^{i\varphi_M}(\bar z_B-\bar z_A)\bigr)} $$

Both numerator and denominator are the imaginary part of some product, and the second factor is a complex conjugate number. The imaginary part of such a product is

$$\operatorname{Im}\bigl((a+ib)(c-id)\bigr)=bc-ad =-\begin{vmatrix}a&c\\b&d\end{vmatrix}$$

So you might as well interpret numerator and denominator as determinants and write

$$r_X=\frac{\begin{vmatrix} r_A\cos\varphi_A & r_B\cos\varphi_B \\ r_A\sin\varphi_A & r_B\sin\varphi_B \end{vmatrix}} {\begin{vmatrix} \cos\varphi_M & r_B\cos\varphi_B - r_A\cos\varphi_A \\ \sin\varphi_M & r_B\sin\varphi_B - r_A\sin\varphi_A \end{vmatrix}}= \frac{r_Ar_B\sin(\varphi_B-\varphi_A)}{\begin{vmatrix} \cos\varphi_M & r_B\cos\varphi_B - r_A\cos\varphi_A \\ \sin\varphi_M & r_B\sin\varphi_B - r_A\sin\varphi_A \end{vmatrix}} $$

The simplification in the numerator makes use of the fact that the determinant of two unit-length vectors is equal to the sine of the angle between them.