Find points on a line with specific distance to another point

333 Views Asked by At

What is the best way to find the distances of points $X_1$ and $X_2$ from point $A$, using their distance $R$ from point $B$, the positions of points $A$ and $B$, and a normalized vector $V$ defining a line going through point $A$? Everything is happening in 2D. Note, that I'm interested only in their distance from the point $A$ and so far the best solution is to calculate their positions first. I feel there must be a simpler solution.

enter image description here

3

There are 3 best solutions below

0
On BEST ANSWER

Ok, because I needed only the closest point anyway, I ended up using this equation:

$$-\frac{d \cdot v + \sqrt{\vphantom{\bigl(}r^2 \lVert d\rVert^2 - \lVert d \times v\rVert}}{\lVert d\rVert^2}$$

$v$ is unit vector with the direction of the line

$d$ is the vector $A-B$

$r$ is the distance from $B$

0
On

With $p = (x,y)$ the solution is at the intersection of two locus. A line $L$ and a circle $C$

$$ \cases{ L\to p = A + \lambda \vec v\\ C\to ||p-B|| = r } $$

so

$$ ||A+\lambda\vec v-B||^2=r^2 $$

or

$$ ||A-B||^2-2\lambda (A-B)\cdot \vec v + \lambda^2||\vec v||^2 = r^2 $$

now solving for $\lambda$ we have one two or no outcomes at all. One in case of tangency, two in case of strict intersection or none in case of no intersection. Supposing we have strict intersection, then having two outcomes $\lambda^*_1,\lambda^*_2$ we have

$$ X_1 = A+\lambda^*_1\vec v\\ X_2 = A+\lambda^*_2\vec v\\ $$

We can have directly those distances if previously the vector $\vec v$ was normalized.

0
On

Let $H$ be the midpoint of $[X_1 X_2]$. Compute the distance $BH$ : it is the distance between point $B$ and line $(X_1X_2)$.

Now, use Pythagoras theorem to compute the distances $AH$, $HX_1$ and $HX_2$.

You now have $AX_1 = AH - HX_1$ and $AX_2 = AH + HX_1$.