1
$\begingroup$

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.

Diagram of the problem

$\endgroup$
  • $\begingroup$ 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. $\endgroup$ – Ethan Bolker May 25 '15 at 22:04
  • 1
    $\begingroup$ 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. $\endgroup$ – Nicholas Bishop May 25 '15 at 22:36
  • $\begingroup$ 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. $\endgroup$ – Ethan Bolker May 26 '15 at 0:03
1
$\begingroup$

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 :)

| cite | improve this answer | |
$\endgroup$
  • $\begingroup$ 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. $\endgroup$ – Nicholas Bishop May 30 '15 at 3:26
  • $\begingroup$ Hm. I believe it's a general quartic equation, so numeric methods would do, or, for explicit formulas, Ferrari's solution $\endgroup$ – Alexey Burdin May 30 '15 at 5:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.