6
$\begingroup$

In a Cartesian system, I've got the slope, start point and distance of a line segment. What's the formula to find the endpoint?

3 Answers 3

7

An equivalent way to Arturo's answer is as follows: from the slope $m$, you can determine the cosine and the sine of the angle from the horizontal axis of a line with that slope:

$$c=\frac{1}{\sqrt{1+m^2}} \qquad s=\frac{m}{\sqrt{1+m^2}}$$

(exercise: verify that they are the cosine and sine of a certain angle)

From this construction, you can easily determine the two points at a distance r from your starting point $(h,k)$ as $(h,k)\pm r(c,s)$.

  • 0
    I think c is actually the sine of the angle, s is the cosine of the angle. See JavaScript, for a slope of 3: Math.sin(Math.atan2(1,3)) === 1 / Math.sqrt(1 + Math.pow(3, 2)); // true Math.cos(Math.atan2(1,3)) === 3 / Math.sqrt(1 + Math.pow(3, 2)); // true2014-12-28
  • 0
    @fisherwebdev, you are aware that the argument order is `atan2(y,x)=atan(y/x)` in JS?2015-05-01
  • 0
    It would be really nice to have an answer that is more clear as a final answer of X2 = something ... Y2 = something. For those of us 25 years out of touch with math needing help, the above answer "(h,k)±r(c,s)" doesn't provide a clear answer.2018-02-19
  • 1
    @Darren, to be more explicit, the two endpoints are $$(h-rc,k-rs)$$ and $$(h+rc,k+rs)$$ where the variables are defined as above. If you're programming this formula in, having shared variables so that stuff is only computed once is a good idea.2018-02-26
4

If the point is $(a,b)$, then the distance from $(a,b)$ to $(x,y)$ is $$\sqrt{(x-a)^2 + (y-b)^2}.$$

If the point is $(a,b)$, then the points that lie on the line through $(a,b)$ with slope $m$ are the points of the form $$(x,y) = (a,b) + k(1,m)$$ where $k$ is a constant.

Putting the two together, if you know the start point $(a,b)$, and the slope $m$, and the distance $d$, then find the (two) values of $k$ that will give you a distance of $d$ by plugging in and solving for $k$.

This gives us the following formula for $k$ (where $d$ is the distance): $$k = \pm \frac{d}{\sqrt{1+m^2}}$$ When putting this in the above formula, we find $(x,y)$.

  • 1
    Another way of looking at it is that you're finding the intersections of the line with the given slope and passing through the given point, and the circle centered at the given point whose radius is the given distance.2010-11-08
  • 2
    The observation of points a,b + k 1,m was interesting, but we still need an actual equation. The equation will complete the lesson you started.2012-04-26
0

Y=mx+c is the equation of the line you have. (x1,y1) is the point and D is the distance. (x,y) is the point you don't know.

D= sqrt((x1-x)^2 +(y1-y)^2)

sub in for y

D= sqrt((x1-x)^2 +(y1-(mx+c))^2)

then solve for the only unknown, x. this is your x co-ord (2 values). then y=mx+c gives the y.

  • 2
    For some basic information about writing math at this site see e.g. [here](http://meta.math.stackexchange.com/questions/5020/), [here](http://meta.stackexchange.com/a/70559/155238), [here](http://meta.math.stackexchange.com/questions/1773/) and [here](http://math.stackexchange.com/editing-help#latex).2013-03-14