My problem is relatively straightforward. I have a line going through two points, A and B. The line can be at any angle (corresponding to the x-axis). I want to compute the point of a line continuation by a number, say ten units. I need the (x,y) coordinates of that point.

In practice, I am using this for a computer vision application where I want to extend a tool marked with two ArUco markers digitally. I calculated the slope, the shift, and the angle corresponding to the x-axis using the atan.

I added a quick scribble to explain the problem a bit better

enter image description here


1 Answer 1


Diagram showing three collinear points A, B and C, formed into right-angled triangles via the addition of points D, E and F

I've drawn the situation up with some coordinates, as well as some extra points. Since $A, B, C$ are collinear, the right triangles $ABD$ and $BCE$ are similar to each other. That means that the side lengths are in equal ratios, i.e.

$$\frac{BC}{AB} = \frac{CE}{BD} = \frac{BE}{AD}$$

We can calculate the vertical and horizontal side lengths from the coordinates:

$$\begin{eqnarray}AD & = & y_1 - y_2 \ BD & = & x_2 - x_1 \ BE & = & y_2 - y_3 \ CE & = & x_3 - x_2\end{eqnarray}

We're also given $BC = 20$, and we can use Pythagoras' Theorem to calculate $AB = \sqrt{AD^2 + BD^2}$. So we can set the first fraction to be a fixed constant, let's call it $r$, and we just have to solve two equations for the unknown coordinates $x_3$ and $y_3$:

$$\begin{eqnarray} \frac{x_3 - x_2}{x_2 - x_1} & = & r \\ \frac{y_2 - y_3}{y_1 - y_2} & = & r\end{eqnarray}$$

These are both pretty simple to rearrange through some basic algebra, which I'll leave to you.

Notice that because of the way the triangles were drawn in this instance the indices go in a particular order. You don't actually have to worry about that, as long as you keep the same direction within the same fraction (so in the first one I wrote it going bigger to smaller, and in the second smaller to bigger, but if you're coding it up it's probably best to be consistent everywhere).

  • $\begingroup$ Thank you. I didn't really understand the fixed constant r but this helped me a lot already! $\endgroup$
    – Chris
    Jul 6, 2022 at 5:20
  • $\begingroup$ Ah nvm. So r is the scaling factor by which I want to extend. Thank you! $\endgroup$
    – Chris
    Jul 6, 2022 at 5:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .