# Given Two Lines, How to Find a Point on Line $2$ given a Specific Distance From Line $1$?

I have two lines (U and V). What is the method to calculate a point on V given a specified distance (d) from U? The lines may be assumed that they do intersect (are not parallel) and are straight lines (only intersect once). My first assumption is to start with perpendiculars from U, but I am not sure of the easy way to find the point on V. I keep expecting to have to iterate.

I can assume that the lines are not parallel, but do intercept each other at some point.

Edit 1-7-2014:6:56: The lines are defined as endpoints, which I then find the directional vectors. On a different part of my problem, I use the directional vectors to calculate a point along the line.

The lines are complanar.

## 4 Answers

This is a small variant of the solution given by user44197 which might be a bit easier to understand conceptually.

Let $ax+by+c=0$ be the equation of line $U$ and, instead, use a parametric description $$x(t)=mt+x_0,\qquad y(t)=nt+y_0$$ of line $V$ (here $P_0=(x_0,y_0)$ is just any point on $V$ and $(m,n)$ os a vector parallel to it). Then the problem is reduced to solve the equation in $t$ obtained equating the distance between $P=(x,y)$ and $U$ with the desired amount $d$, namely $$\frac{|ax(t)+by(t)+c|}{\sqrt{a^2+b^2}}=d.$$ Note that if one chooses $P_0$ to be the intersection point of $U$ and $V$ the above equation has the somewhat simpler form $$\frac{|(am+bn)t |}{\sqrt{a^2+b^2}}=d.$$

• So in the final equation, what happens to the terms: $$ax_0 + by_0$$ – orion Jan 8 '14 at 1:05
• @orion : sorry I made a cut-and-paste error. When $P_0$ is the intersection point $ax_0+by_0+c=0$. I'll edit the answer. – Andrea Mori Jan 8 '14 at 1:09
• So what defines m,n, and t. I am not quite sure what I am solving for in the final equation. – orion Jan 8 '14 at 1:13
• $m$ and $n$ are the components of a (chosen) vector parallel to $V$. The only unknown in the final equation is the parameter $t$. – Andrea Mori Jan 8 '14 at 1:16
• Are there any guidelines or rules for choosing the vector parallel to V? – orion Jan 8 '14 at 1:21

Hint: Calculate the intersection point and the intersection angle of the two lines and apply some basic trigonometry.

How are the lines specified?

If a line is given by $$a x + b y + c = 0$$

and if $P=(u,v)$ is a point, then the distance of $P$ from the line is given by $$d = \frac{\left|a u + b v + c \right|}{\sqrt{a^2+b^2}}$$ or better yet $$d^2 = \frac{\left(a u + b v + c \right)^2}{{a^2+b^2}}$$

Suppose the other line is given by $$\hat a x + \hat b y + \hat c = 0$$ then since $P$ has to be on this line you have to solve the two equations $$d^2 = \frac{\left(a x + b x + c \right)^2}{{a^2+b^2}}, \text{ and } \hat a x + \hat b y + \hat c=0$$ You can eliminate $x$ or $y$ from the second equation and substitute in the first to get a quadratic equation.

For two general lines there may be many such points, and without a reference point on one of the lines, you have one equation and two scalar unknowns (the parameters of the lines). As a consequence, your solution would be a function, and not a point/s..

We assume the parametric expressions for the lines ($|\boldsymbol{U_1}|=|\boldsymbol{V_1}|=1$):
$$\boldsymbol {U}(u)= \boldsymbol{U_0} + u \boldsymbol{U_1}, \boldsymbol {V}(v)= \boldsymbol{V_0} + v \boldsymbol{V_1}$$ I use bold face capital letters to denote points/vectors (No need to distinguish in this case), and non bold face lower letters for scalars.

Your requirement translates to finding $v=v'$ for which this holds: $$d^2=|\boldsymbol{U}(u) - \boldsymbol{V}(v')|^2=|\boldsymbol{U}(u)|^2+|\boldsymbol{V}(v')|^2-2(\boldsymbol{U}(u)\cdot \boldsymbol{V}(v'))=|\boldsymbol{U}(u)|^2+|\boldsymbol{V_0}|^2+v'^2-2(\boldsymbol{U}(u)\cdot \boldsymbol{V_0})+2v'[(\boldsymbol{V_0}-\boldsymbol{U}(u))\cdot\boldsymbol{V_1}]$$ And so: $$v'^2+2v'[(\boldsymbol{V_0}-\boldsymbol{U}(u))\cdot\boldsymbol{V_1}]+[|\boldsymbol{V_0}|^2+|\boldsymbol{U}(u)|^2-2(\boldsymbol{U}(u)\cdot \boldsymbol{V_0})-d^2]=0$$ Solve this for $u \mapsto v'$ using the quadratic formula (Disregard complex valued solutions: $b^2-4ac$ should be non-negative :), and the required points shall be $\boldsymbol {V}(v')$ as functions of $u$.