Best way to find the Coordinates of a Point on a Line-Segment a specified Distance Away from another Point

I have 4 points: $Q, R, S, T$.

I know the following

• Coordinates for $R$, $T$, and $S$;
• Length of $\overline{RQ}$
• That segment $\overline{RT} < \overline{RQ} < \overline{RS}$;
• I need to figure out the coordinates of $Q$.

$R$, $T$, $S$ form a triangle and point $Q$ can be found on the line segment $\overline{TS}$. I need to get the coordinates for $Q$.

I have solutions for this problem, but they are all so convoluted and long I know I must be doing something wrong. I feel certain there must a simple elegant way to solve this. The best solution would be the simplest one since this needs to be programmed.

• I suspect you can improve the question. In particular it seems you also know the length of $RQ$ to be $d=25$. A circle centered at $R$ of radius $25$ will meet the (extended) line $TS$ $0$, $1$ or $2$ times, and some of these may be between $T$ and $S$. Commented Sep 2, 2011 at 8:00
• However because RT < RQ < RS we know that there is exactly one point on segment TS. The length of RQ is irrelevant since I need a formula not specific number. Commented Sep 2, 2011 at 8:05
• Is the length e known? Otherwise, your problem's underdetermined. Commented Sep 2, 2011 at 8:06
• @David: The key point is whether you know the length of $RQ$, as well as knowing it is more than $RT$ and less than $RS$. Commented Sep 2, 2011 at 8:09
• BTW: I don't see a point $I$ in your diagram. Commented Sep 2, 2011 at 8:11

This is the problem of finding the intersection of a straight line and a circle, as commented by J.M.. The more elementary method using analytical geometry, without rotate or translate the coordinate axes (which would make the computation easier$^1$), although not being a compact one, is the following (see sketch).

The equation defined by points $S(N,J)$ and $T(M,I)$ is given by $$y-J=m(x-N),\qquad m=\frac{I-J}{M-N}\tag{1}.$$ The equation of the circle centered at $R$ with radius $d=\overline{RQ}$ is $$(x-L)^{2}+(y-H)^{2}=d^{2}.\tag{2}$$ You need to solve the following system $$\left\{ \begin{array}{c} y-J=m(x-N) \\ (x-L)^{2}+(y-H)^{2}=d^{2}, \end{array}\tag{3} \right.$$ which is equivalent to $$\left\{ \begin{array}{c} x=\frac{y-J+mN}{m} \\ \left(\frac{y-J+mN}{m}-L\right)^{2}+(y-H)^{2}=d^{2}.\tag{4} \end{array} \right.$$ Solving the quadratic equation yields (with the help of SWP): $$y=\frac{1}{ m^{2}+1 }\left( -mN+Lm+J+m^{2}H\pm \sqrt{\Delta}\right), \tag{5}$$ where the discriminant is

$$\begin{eqnarray*} \Delta &=&A+B, \\ \text{with } A &=&-m^{4}N^{2}+m^{4}d^{2}-m^{4}L^{2}-m^{2}J^{2}-m^{2}H^{2}+d^{2}m^{2}-2m^{3}NH, \\ B &=&2Lm^{3}H+2Jm^{2}H+2m^{4}NL-2m^{3}JL+2m^{3}JN.\tag{6} \end{eqnarray*}$$

The information $\overline{RT}<\overline{RQ}<\overline{RS}$ will define the signal of the term $\pm \sqrt{\Delta}$. The coordinates of $Q$ are $O=x,K=y$.

$^1$By making the translation $X=x-L$ and $Y=y-H$, and computing the new coordinates of the points in this $X,Y$ system, the above formulae simplify (it is equivalent to set $L=H=0$ in them). In the end they should be convert back to the original $x,y$ system.

• Slightly OT: may I ask what scanner you use for your sketches? Commented Sep 2, 2011 at 17:31
• @J.M.: It is a HP Deskkjet F380 all-in-one printer, scanner, copier. Commented Sep 2, 2011 at 17:38
• Thanks, I'm canvassing for scanners and remembered that you post scans of your sketches. :) Commented Sep 2, 2011 at 17:48
• @Americo I envy the extremely neat work with the sketch :-). Commented Sep 2, 2011 at 18:06
• @Srivatsan: Thanks! I think it is a result of the job I had and of my age (before the computers). Commented Sep 2, 2011 at 18:10

I suppose that the distance $d$ is known because it is mentioned in the title. The point $Q$ is the intersection of the circe with the radius $d$ around $R$ and the line $TS$.

Circle: $$(X - R)^2 = d^2$$

Line $TS$: $$X(t) = (T-S) t + S$$

Intersection (exists since $\overline{RT} < \overline{RQ} < \overline{RS}$): $$(T-S)^2 t^2 + 2(T-S) \cdot (S-R) t + (S-R)^2 = d^2$$

Here, $T-S$ etc. are the vectors given by subtracting the respective point coordinates, '$\cdot$' means the scalar product, and the power 2 of a vector is its squared length. Solve this quadratic equation for $t$ yielding at most two solutions $t_1, t_2$. Since the parameter $t$ corresponds to the position of $Q$ at the line segment $TS$, take that $t_i$ for which $0 \le t_i \le 1$. Then $Q = X(t_i)$.

Let $d$ be the length $RQ$. Solve $(tM+(1-t)N-L)^2 + (tI+(1-t)J-H)^2 = d^2$ for $t$. As a quadratic this will give two solutions. If $RT < RQ < RS$ then one of these solutions will be between $0$ and $1$, so pick that one.

Then the co-ordinates of $Q$ are $(O,K)=(tM+(1-t)N,tI+(1-t)J)$.

• There's actually a quick way to pick out the smaller solution of a quadratic equation: use the "Citardauq" formula (thanks André! ;)), $-\frac{2c}{b+\mathrm{sign}(b)\sqrt{b^2-4ac}}$. Commented Sep 2, 2011 at 8:25

since you know Coordinates for R, T, and S so you know the equation of line ST. so you can write Coordinates of point Q in terms of a variable say x (x coordinates is x and y coordinates in terms of x using equation of ST. Now just apply distance formula for Lenght of QR as you know the length of QR and now u have x and hence you have coordinate of Q.