How To: Find a Point on a Line Given a Point and a Distance

I faced a little mathematical challenge recently. It is as follow:

Given a line with a known equation, a point (x_a, y_a) and a distance d, find the coordinates of the point (x_b, y_b) that is at a distance d from (x_a, y_a).

The equation of the line is:

y=mx+c

Which is equivalent to:

y=m(x-x_0)+y_0

The trick here is to use the circle formula:

x^2+y^2=r^2

In our case, the center of the circle is (x_a, y_a) and the radius is the distance d. Using this formula, we will be able to find x_b. After that, it is as simple as using the line formula to find y_b.

Let’s start by finding x_b.

x_b^2+y_b^2=r^2
(x_b-x_a)^2+(y_b-y_a)^2=d^2
(x_b-x_a)^2+m^2(x_b-x_a)^2=d^2 \text{ (Replace with the line formula)}
(x_b-x_a)^2(1+m^2)=d^2
(x_b-x_a)^2=d^2/(1+m^2)
x_b = x_a + d/\sqrt(1+m^2)

Now that we have x_b, we can find y_b by using the line formula:

y_b = mx_b+c

And there you go, you have found (x_b, y_b)!

Add a Comment

Your email address will not be published. Required fields are marked *