# Find parametric line between two 2D line segments that is an exact distance from a point

Given two 2D line segments, $\overline{ab}$ and $\overline{cd}$, and a point $p$, I would like to find a scalar value $t$ such that the line segment between $\overline{ab}(t)$ and $\overline{cd}(t)$ is at a distance of exactly $L$ from $p$.

Clarifications:

• $\overline{ab}(t)$ is the point $a * (1 - t) + b * t$

• The points $a$, $b$, $c$, $d$, and $p$ are known. The distance $L$ is known. Only the scalar value $t$ is unknown. • I think there are many such segments for this picture., so many values of $t$. Draw a circle of radius $L$ about $P$ and use any tangent to the circle that meets both $ab$ and $cd$. There are cases in which there are no such segments. – Ethan Bolker May 25 '15 at 22:04
• The value of $t$ must be the same on both segments. So not any line tangent to the circle will do. I believe that this is a well constrained problem with only two solutions. – Nicholas Bishop May 25 '15 at 22:36
• I agree that if the value of $t$ must be the same then there is at most one answer. There may still be none. Try writing the equation of the tangent to the circle from $ab(t)$, then finding the value of "$t$" for the intersection with $cd$. As $t$ increases from $0$ to $1$ the corresponding value on $cd$ (when it exists) will decrease. – Ethan Bolker May 26 '15 at 0:03

Since $\frac{(-ab(t)+p).(cd(t)-ab(t))}{(cd(t)-ab(t))^2}(cd(t)-ab(t))$ is the projection $-ab(t)+p$ onto $cd(t)-ab(t)$, $$L^2=(-ab(t)+p)^2-\left(\frac{(-ab(t)+p).(cd(t)-ab(t))}{(cd(t)-ab(t))^2}(cd(t)-ab(t))\right)^2$$ I believe it's the equation for $t$ you're looking for :)
• How would I go about isolating $t$ from that equation? I've been trying to make WolframAlpha solve it (e.g. solve u=a*(1-t)+b*t, v=c*(1-t)+d*t, L^2=(-u+p)^2-((((-u+p).(v-u))/(v-u)^2)*(v-u))^2 for t) but haven't figured out the magic incantation yet. – Nicholas Bishop May 30 '15 at 3:26